title: Customize Redis Expiration Keys Algorithm
body: <p>I have a performance issue in one of my microservice project, that is high latency in connecting or performing command to redis. After some investigation, I came into this:</p>
  <p>According to Redis documentation, redis algorithm for expiring keys is:</p>
  <blockquote>
  </blockquote>
  <ol>
  <li>Test 20 random keys from the set of keys with an associated expire.</li>
  <li>Delete all the keys found expired.</li>
  <li>If more than 25% of keys were expired, start again from step 1.</li>
  </ol>
  <p>In my project, 30 keys per second are created or updated, which has a ttl of 10 minutes, that is about one third of all stored keys.</p>
  <p>Does this mean in most execution of an algorithm we fulfil the condition of third step and redis consume most of its resource on expiring key? If this so, can I customize or override default behaviour of this algorithm by changing some config? Or is there any alternative solution?</p>