Redis is used only as a cache configuration

Source: Internet
Author: User

If you want to use Redis as a cache and all keys have an expiration time, you might consider using the following settings (assuming a maximum memory usage of 2M):

maxmemory 2mbmaxmemory-policy allkeys-lru

The above settings do not require our app to use the expire (or similar command) command to set the expiration time for each key, because some keys are automatically deleted using the class LRU algorithm as long as memory usage reaches 2m,redis.

Using cache settings is a more efficient way to use memory than to store the expiration time of multiple keys with extra memory space. It is also a more recommended way to use LRU than when each key is fixed, because it allows the application's hot data (more frequently used keys) to stay in memory longer.

Redis is basically configured so that it can be used as a memcached.

When we use Redis as a cache, it is highly recommended to use two Redis instances if the application also needs to use Redis as a storage system. One is the cache, which is configured using the above method, the other is storage, is configured according to the application's persistence requirements, and only the data that does not need to be cached is stored.

Original: http://www.redis.cn/topics/config.html

Redis is used only as a cache configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.