Can Azure Cache for Redis set default TTL in config?

Shengyu Xiong 20 Reputation points Microsoft Employee
2024-05-09T09:55:18.42+00:00

We found there exist much persistent keys in azure cache for redis, wonder whether there exist way to set default TTL in config when redis key do not set.

Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
258 questions
{count} votes

Accepted answer
  1. ShaktiSingh-MSFT 15,336 Reputation points
    2024-05-09T10:22:27.86+00:00

    Hi Shengyu Xiong •,

    Welcome to Microsoft Q&A forum.

    As I understand, you want to set default TTL in Azure Cache for Redis.

    Choose an eviction policy that works for your application. The default policy for Azure Cache for Redis is volatile-lru, which means that only keys that have a TTL value set with a command like EXPIRE are eligible for eviction. If no keys have a TTL value, then the system won't evict any keys. If you want the system to allow any key to be evicted if under memory pressure, then you may want to consider the allkeys-lru policy.

    volatile-ttl: Removes the key with the shortest time to live based on the expiration set for it.

    Hope this helps. Let us know for more queries.

    Thanks

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.