Maxmemory allkeys-lru policy evict older keys

Hi,

We are trying to implement maxmemory for evicting keys once memory threshold is reached.

Even reading the documentation, I fail to understand a few details. In our case, all keys are created with the same TTL, but we would like to make sure that our oldest accessed keys are deleted.

To check this, we ran this simple test:

  • maxmemory configured to 10mb
  • created keys using this for loop
for i in $(seq 0 80000) ; do echo "SET $i 'un valor cualquiera' EX 1800" ; done | redis-cli --pipe

The command takes less than 3 seconds to execute and results in a total of 35.869 keys evicted and 63737 left. The part that I fail to understand is that I would expect that I should have “nil” when getting keys from 0 to 35.869, and “un valor cualquiera” from keys 35870 to the last one (100.000). But this is not the case since I do get “nil” when for example, executing GET 37000.

What am I missing? My fear is to put this into production and users start losing their relevant keys instead of the actual least accesed ones.