Redis operation and maintenance and development study notes (7) memory management and expiration policies

Redis operation and maintenance and development study notes (7) memory management and expiration policies

Memory recovery strategy

Inert delete

When used in an inert remove the key with the client read timeout property, if the expiration time has exceeded the set key will delete operation and returns empty. No maintenance process chain TTL expired delete key. If there is a key has never been accessed, then there is a problem. We need to delete a scheduled task

To delete a scheduled task

Default performed once every 10 seconds, is controlled by the configuration hz. Timing task adaptive algorithm. The key expiration ratio using a fast and slow recovery rate

maxmemory

Memory Trigger memory overflow control strategy maxmemory-policy limit is reached maxmemory: six strategies

noeviction Default does not delete, reject all write operations
volatile-lru According to LRU algorithm deletes a timeout property
allkeys-lru According lru delete key algorithm, regardless of the data have not set the timeout property
volatile-random Random delete expired key until sufficient space
volatile-ttl According ttl attribute key object, remove recently to expire data, if there is no fallback to noeviction
allkeys-random Random delete all the keys, until there is enough free space

Expiration policy allkeys-lru from the main building test

From the main building is completed

2M open space, entered, and write data. 1024

  1. Data is written using a script
for ((i=1;i<1024;i++))
do
    echo -en "helloworld1" | redis-cli -c -p 7010 -x set name$i
done
  1. The output data
    were written 108 data this time we'll see the changes in the data set

Test Results

volatile-lru test results

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-If4Ld9SW-1572053750520) (media / 15662043330552 / 15674243431626.jpg)]

volatile-ttl test results

Here Insert Picture Description

allkeys-lru

Here Insert Picture Description

Published 257 original articles · won praise 223 · views 320 000 +

Guess you like

Origin blog.csdn.net/csdn_kou/article/details/102753120