Redis operation and maintenance and development study notes (7) memory management and expiration policies
Article Directory
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
- 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
- The output data
were written 108 data this time we'll see the changes in the data set