How to make hot redis are stored in the data?

When the maximum memory redis use more memory than the setting, the trigger key redis elimination mechanism of 6 out of redis3.0 strategy are as follows:

 (1) noeviction: do not delete the policy. When the maximum memory limit, if you need more memory, simply return an error message (redis out of default policy)

   (2) allkeys-lru: Priority delete the least recently used (less recently used, LRU) is key in all the key.

   (3) allkeys-random: random delete key part in all the key

 (4) volatile-lru: set the timeout (expire) in the key delete key priority least recently used

 (5) volatile-random: to delete a portion of the random key provided in the key timeout

 (6) volatile-ttl: the set key timeout in priority to delete the remaining time (time to live, TTL) of the key

 

Scenes:

There 2000w data in the database, but only 100w redis data, how to ensure redis are stored in hot data?

 

Program:

Redis limited amount of memory, according to its own data redis will phase out strategy, leaving the hot data to memory. It is possible to calculate data about 100w occupied memory,

Then you can set about redis memory limit, and eliminate policy is set to allkeys-lru or volatile-lru.

 

Set the maximum memory for redis:

Open redis profiles, settings maxmemory parameters, maxmemory bytes bytes type is Oh!

maxmemory 268435456

Set expiration policy:

maxmemory-policy volatile-lru

 

Guess you like

Origin www.cnblogs.com/wffzk/p/11972894.html