diff --git a/roles/redis/defaults/main.yml b/roles/redis/defaults/main.yml index b01d70a..d6736b9 100644 --- a/roles/redis/defaults/main.yml +++ b/roles/redis/defaults/main.yml @@ -11,6 +11,9 @@ redis_secret: ~ redis_config_bind_ip: "0.0.0.0" redis_config_unix_socket_path: ~ redis_config_unix_socket_perm: 775 +redis_config_max_memory_mb: ~ +redis_config_max_memory_policy: ~ # allkeys-lru + # Overwrite per-instance to be able to run many instances on the same host # prefix should be sth like 'matrix_', modifies mapped directories, container name and uer redis_prefix: "" diff --git a/roles/redis/templates/redis.conf.j2 b/roles/redis/templates/redis.conf.j2 index d0e3f52..133ac92 100644 --- a/roles/redis/templates/redis.conf.j2 +++ b/roles/redis/templates/redis.conf.j2 @@ -860,7 +860,9 @@ requirepass {{ redis_secret }} # limit for maxmemory so that there is some free RAM on the system for replica # output buffers (but this is not needed if the policy is 'noeviction'). # -# maxmemory +{% if redis_config_max_memory_mb %} +maxmemory {{ redis_config_max_memory_mb }}M +{% endif %} # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached. You can select one from the following behaviors: @@ -891,7 +893,9 @@ requirepass {{ redis_secret }} # # The default is: # -# maxmemory-policy noeviction +{% if redis_config_max_memory_policy %} +maxmemory-policy {{ redis_config_max_memory_policy }} +{% endif %} # LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated # algorithms (in order to save memory), so you can tune it for speed or