Redis Settings - redis.config
ServerMemory usage limits
Default value
- 32bit System: 3GB
- 64bit System: 0
- 0: Unlimited use of operating system virtual memory (swap)
When memory is full, remove the key according to the uninstall policy.
It must be greater than the maximum memory usage for one Cache.
maxmemory 1gb
1k | 1kb | 1m | 1mb | 1g | 1gb |
1,000 bytes | 1024 bytes | 1,000,000 bytes | 1024*1024 bytes | 1,000,000,000 bytes | 1012*1024*1024 bytes |
Remove Policy
LFU support starting with Redis 4.0
Use the DEL command to remove the key.
- DEL commands are executed in Main Thread.
maxmemory-policy volatile-lru
noeviction
Do not run the uninstall policy.An error occurs when a write operation is performed with full memory.
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: OOM command not allowed when used memory > 'maxmemory'.] with root cause
io.lettuce.core.RedisCommandExecutionException: OOM command not allowed when used memory > 'maxmemory'.
volatile
Execute an uninstall policy on the EXPIRE SET (the set of keys with Expire set).
If there is no object to be removed, it acts like noeviction.
volatile-lru | The LRU algorithm removes the longest unreferenced key.(Recommended if you want to keep a single cache server, key permanently |
volatile-lfu | The LFU algorithm removes the key with the least number of references. |
volatile-random | Optionally remove the key.(Recommended if you want to keep a single cache server, key permanently |
volatile-ttl | Remove the key with the least time-to-live (TTL) value (recommended if you use a different TTL for each key). |
allkeys
Enable uninstall policy for all keys
allkeys-lru | The LRU algorithm removes the longest unreferenced key.(Recommended if only certain keys are used a lot in some cases) |
allkeys-lfu | The LFU algorithm removes the key with the least number of references. |
allkeys-random | Optionally remove the key.(Recommended if all keys are used uniformly) |
Number of candidates to be removed
Compare and eliminate candidate groups that meet the elimination policy.
maxmoery-samples 3
Asynchronous Removal (Redis 4.0)
Settings to prevent Blocking from occurring when the purge policy is run, removing multiple keys at once
If yes is set, LazyFreeThread is performed in the background using the UNLINK command rather than the DEL command.
lazyfree-lazy-eviction yes
- Use the UNLINK command to asynchronously remove the key when the uninstall policy is executed.
lazyfree-lazy-expire yes
- Use the UNLINK command to delete expired keys.
lazyfree-lazy-server-del yes
- Use UNLINK commands when executing SET or RENAME commands for keys that already exist.
lazyfree-lazy-user-del yes
- The DEL command works internally as a UNLINK command.(Redis 6.0)
slave-lazy-flush yes
- When replicating the entire data on the Master server to the Clone server, it is deleted with the FLUSHALL async command.Although synchronization speed is fast, additional memory may be required because new data is received without all existing data being deleted.
Reference