tencent cloud

Feedback

Basic Usage Guidelines

Last updated: 2023-10-20 10:39:47

    Cache-Only Policy

    Redis is only used to cache data. It stores all data in memory for quicker access. However, using it to persist data may result in data loss because it can’t store data in memory persistently after a power failure.

    Non-Unique Data Source Policy

    Since Redis is used for caching, cache misses are possible, so it cannot be relied upon as the sole source of data. In case of an exception when accessing Redis, the backend database needs to be queried.

    Key Eviction Policy

    Set the maxmemory-policy as needed. The default policy is noeviction, which means that keys will not be deleted. When memory is used up, OOM will occur. So we recommend that you modify the eviction policy once the instance is created to reduce OOM.

    Configurable memory eviction policy

    Select one of the following eviction policies for maxmemory-policy when the Redis in-memory cache was used up. LRU (least recently used) and TTL (time to live) are implemented by randomized and approximation algorithms.
    allkeys-lru: Delete keys based on the LRU algorithm, regardless of whether the data has a timeout attribute, until enough space is freed up.
    allkeys-random: Randomly delete keys until enough space is freed up.
    volatile-lru: Delete expired keys based on the LRU algorithm until enough space is freed up.
    volatile-random: Randomly delete expired keys until enough space is freed up.
    volatile-ttl: Delete data that is about to be expired based on the TTL attribute of key-value pairs. If there is no recently expiring data, the policy will fall back to "noeviction".
    noeviction: Evict no data, reject all write operations, and return the error message "(error) OOM command not allowed when used memory" to the client. Redis will only respond to read operations.

    Suggestions

    When Redis is used as a cache, it is recommended to use the "allkeys-lru" eviction policy. This policy evicts the keys least frequently used. By default, if a key is least frequently used, it is also less likely to be accessed in the future, so it is evicted.
    When Redis is used as data persistence and caching in a hybrid manner, the volatile-lru policy can be used. As Redis is not recommended to store data persistently, it is only considered as an alternative.

     

    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support