Redis Cache Settings

Source: Internet
Author: User
Tags allkeys

1. Be sure to set the maximum cache size and set the cache policy

If you do not set the maximum cache, the Redis crashes when the new data is added, if the maximum memory is exceeded!

Setting mode: MaxMemory 1GB

After logging in using REDIS-CLI, use the Info command to view the memory situation:

# Memory
used_memory:882920
How much memory is consumed by used_memory_human:862.23k data
used_memory_rss:2412544
used_memory_rss_human:2.30m
used_memory_peak:898688
used_memory_peak_human:877.62k
total_system_memory:4044341248
total_system_memory_human:3.77g
used_memory_lua:37888
used_memory_lua_human:37.00k
maxmemory:0
maxmemory_human:1.00g the peak of memory consumption
Maxmemory_policy:noeviction
mem_fragmentation_ratio:2.73
mem_allocator:libc

2. Cache Policy

When the maxmemory limit arrives, the exact behavior that Redis will take is configured by the Maxmemory-policy configuration directive.

    • Noeviction-Returns an error when memory limit is reached
    • ALLKEYS-LRU-Recycles The least recently used (LRU) key to make room for new data.
    • VOLATILE-LRU-Recycles The least recently used (LRU) key, but reclaims only the keys that have expired settings, freeing up space for new data.
    • Allkeys-random-Reclaim random keys to make room for new data.
    • Volatile-random-reclaims random keys, but reclaims only the keys that are set to expire, freeing up space for new data.
    • Volatile-ttl-Recycle a key with set expiration, try to reclaim the key from the minimum TTL time to make room for new data.

Redis Cache Settings

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.