LRU key evictions

To demonstrate the various options for key evictions in Redis, we'll start with a simple example by setting a small memory Redis instance that the maxmemory directive sets to 1 megabyte. The maxmemory directive allows you set a hard upper bound on the amount of memory that is available to a running Redis instance. Echoing the warnings in the default redis.conf file, setting the maxmemory has ramifications that we'll now see. To start with, we'll just create a very simple Redis key schema, that of generating and storing a unique id for a web application. After connecting to a Redis instance through Redis-cli, we'll run the following commands to clear out our datastore and then set the maxmemory directive to 1 megabyte:

127.0.0.1:6379> ...

Get Mastering Redis now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.