Search code examples
cachingredis

Redis set maxmemory per database


Is it possible to set maxmemory and maxmemory-policy per database in redis?

I've tried to switch to db 1 and set those properties

SELECT 1
CONFIG SET maxmemory 100mb
CONFIG SET maxmemory-policy allkeys-lfu

But it looks like they are being set per instance not a specific database

SELECT 2
CONFIG GET maxmemory

1) "maxmemory"
2) "104857600"


CONFIG GET maxmemory-policy

1) "maxmemory-policy"
2) "allkeys-lfu"

So, are there any ways to set those properties on a database level or should I use different instances / nodes?


Solution

  • Redis DB is not completely independent, but logically independent. I think you can think of it as a namespace.

    The functionality you want will have to use another instance.