aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSachin Joshi <satchin.joshi@gmail.com>2019-07-19 11:50:47 +0545
committerSachin Joshi <satchin.joshi@gmail.com>2019-07-19 11:50:47 +0545
commit581756ccc50cc08823957a2f24f506bf23c7cd22 (patch)
treec488775f299d96fc3277af8463f37d3dada4c159
parentde9906ad56bd25d6c8c38bef1307192df2e95445 (diff)
downloadpleroma-581756ccc50cc08823957a2f24f506bf23c7cd22.tar.gz
update the docs
-rw-r--r--docs/config/howto_set_richmedia_cache_ttl_based_on_image.md15
1 files changed, 8 insertions, 7 deletions
diff --git a/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md b/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md
index 5846b6ab0..bfee5a9e6 100644
--- a/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md
+++ b/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md
@@ -4,20 +4,21 @@
Richmedia are cached without the ttl but the rich media may have image which can expire, like aws signed url.
In such cases the old image url (expired) is returned from the media cache.
-So to avoid such situation we can define a moddule that will set ttl based on image.
-
-The module must have a `run` function and it should be registered in the config.
+So to avoid such situation we can define a module that will set ttl based on image.
+The module must adopt behaviour `Pleroma.Web.RichMedia.Parser.TTL`
### Example
```exs
defmodule MyModule do
- def run(data, url) do
+ @behaviour Pleroma.Web.RichMedia.Parser.TTL
+
+ @impl Pleroma.Web.RichMedia.Parser.TTL
+ def ttl(data, url) do
image_url = Map.get(data, :image)
# do some parsing in the url and get the ttl of the image
- # ttl is unix time
- ttl = parse_ttl_from_url(image_url)
- Cachex.expire_at(:rich_media_cache, url, ttl * 1000)
+ # return ttl is unix time
+ parse_ttl_from_url(image_url)
end
end
```