fireproofsocks
Cachex example with TTL?
I’m trying to cache the result of an HTTP lookup – the HTTP response does include a valid “expires” header. My goal was to cache the response for a TTL that matches that expiration datetime. Cachex offers a simple interface for accessing values from cache and falling back to the HTTP lookup, but I don’t see where to set the TTL values of the cache keys. There’s a page in its docs about TTLs, but it doesn’t show how to actually implement them. Or am I missing something? Thanks!
Most Liked
fmcgeough
put something with a TTL of 60 seconds.
Cachex.put(:my_cache, "key", "value", ttl: :timer.seconds(60))
Maybe I’m misunderstanding your question.
fireproofsocks
Thank you! I constantly struggle with locating relevant information in the Hex docs. There’s a dedicated page helpfully titled “TTL” https://hexdocs.pm/cachex/ttl-implementation.html but it doesn’t contain examples or a link to the page you shared.
fmcgeough
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









