Sobes.tech
Senior

What TTL should be chosen for caching rates if rates change infrequently?

sobes.tech AI

Answer from AI

If tariffs change infrequently, the TTL (Time To Live) for cache can be set quite high to reduce system load and decrease the number of requests to the data source.

Recommendations:

  • Set TTL in the range of several hours to a day (e.g., 6-24 hours), depending on business requirements and the frequency of tariff changes.
  • When tariffs change, implement a cache invalidation mechanism (e.g., via an event or manual update) so as not to wait for TTL expiration.
  • If possible, use a cache update strategy based on events (cache invalidation) instead of pure TTL.

Thus, for tariffs that change rarely, a TTL of 12-24 hours is a reasonable choice, balancing data relevance and performance.