Redis Settings - redis.config

Server

Language :

Memory 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.

text

maxmemory 1gb
1k1kb1m1mb1g1gb
1,000 bytes1024 bytes1,000,000 bytes1024*1024 bytes1,000,000,000 bytes1012*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.

text

maxmemory-policy volatile-lru

noeviction

Do not run the uninstall policy.An error occurs when a write operation is performed with full memory.

text

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-lruThe LRU algorithm removes the longest unreferenced key.(Recommended if you want to keep a single cache server, key permanently
volatile-lfuThe LFU algorithm removes the key with the least number of references.
volatile-randomOptionally remove the key.(Recommended if you want to keep a single cache server, key permanently
volatile-ttlRemove 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-lruThe LRU algorithm removes the longest unreferenced key.(Recommended if only certain keys are used a lot in some cases)
allkeys-lfuThe LFU algorithm removes the key with the least number of references.
allkeys-randomOptionally 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.

text

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.

text

lazyfree-lazy-eviction yes
  • Use the UNLINK command to asynchronously remove the key when the uninstall policy is executed.

text

lazyfree-lazy-expire yes
  • Use the UNLINK command to delete expired keys.

text

lazyfree-lazy-server-del yes
  • Use UNLINK commands when executing SET or RENAME commands for keys that already exist.

text

lazyfree-lazy-user-del yes
  • The DEL command works internally as a UNLINK command.(Redis 6.0)

text

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

Key eviction

Cleaning up Redis server settings

민갤

Back-End Developer

백엔드 개발자입니다.