Answers.Body: <p>Based on my own assessment and looking at other resources, <code>allkeys-lru</code> is likely the best policy to use in many cases.</p>
  <p><a href="https://redis.io/docs/manual/eviction/" rel="nofollow noreferrer">https://redis.io/docs/manual/eviction/</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-14T11:30:31.157Z
Answers.LastActivityDate: 2022-10-14T11:30:31.157Z
Answers.UserDisplayName: James White
Body: <p>I have recently switched from memcached to Redis. The cache, session, template caching and mutex is now using Redis on a project. While Redis generally gets managed by Yii/Craft CMS, Redis features a few more configuration options than memcached, so I was looking for any further insight/advice on the best configuration when used with Craft CMS.</p>
  <p>The current data eviction policy which seems to be a default for most Redis provisioning is <code>volatile-lru</code>. There are other eviction policies available:</p>
  <ul>
  <li>noeviction: New values aren’t saved when memory limit is reached. When a database uses replication, this applies to the primary database</li>
  <li>allkeys-lru: Keeps most recently used keys; removes least recently used (LRU) keys</li>
  <li>allkeys-lfu: Keeps frequently used keys; removes least frequently used (LFU) keys</li>
  <li>volatile-lru: Removes least recently used keys with the expire field set to true.</li>
  <li>volatile-lfu: Removes least frequently used keys with the expire field set to true.</li>
  <li>allkeys-random: Randomly removes keys to make space for the new data added.</li>
  <li>volatile-random: Randomly removes keys with expire field set to true.</li>
  <li>volatile-ttl: Removes keys with expire field set to true and the shortest remaining time-to-live (TTL) value.</li>
  </ul>
  <p>Based on my own assessment <code>allkeys-lru</code>, <code>allkeys-lfu</code>, <code>volatile-lru</code> and <code>volatile-lfu</code> and likely the best options, but any Redis experts care to comment on their take?</p>
  
Tags: <craft3><cache><redis>
Title: Recommended Redis data eviction policy for Craft CMS
ThreadText: # Recommended Redis data eviction policy for Craft CMS
  
  (Asked by: username_0 on 2022-07-18)
  
  I have recently switched from memcached to Redis. The cache, session, template caching and mutex is now using Redis on a project. While Redis generally gets managed by Yii/Craft CMS, Redis features a few more configuration options than memcached, so I was looking for any further insight/advice on the best configuration when used with Craft CMS.
  
  The current data eviction policy which seems to be a default for most Redis provisioning is `volatile-lru`. There are other eviction policies available:
  
  * noeviction: New values aren’t saved when memory limit is reached. When a database uses replication, this applies to the primary database
  * allkeys-lru: Keeps most recently used keys; removes least recently used (LRU) keys
  * allkeys-lfu: Keeps frequently used keys; removes least frequently used (LFU) keys
  * volatile-lru: Removes least recently used keys with the expire field set to true.
  * volatile-lfu: Removes least frequently used keys with the expire field set to true.
  * allkeys-random: Randomly removes keys to make space for the new data added.
  * volatile-random: Randomly removes keys with expire field set to true.
  * volatile-ttl: Removes keys with expire field set to true and the shortest remaining time-to-live (TTL) value.
  
  Based on my own assessment `allkeys-lru`, `allkeys-lfu`, `volatile-lru` and `volatile-lfu` and likely the best options, but any Redis experts care to comment on their take?
  
  **Tags:** craft3, cache, redis
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-10-14. Score: 1
  
  Based on my own assessment and looking at other resources, `allkeys-lru` is likely the best policy to use in many cases.
  
  <https://redis.io/docs/manual/eviction/>
  
  
  ---
  
  