Search code examples
redisazure-redis-cache

Is changing the max-memory policy in Redis an expensive operation?


fairly new to Redis and working on a Azure Cache for Redis implementation.

In the Azure documentation around Redis trouble shooting it's stated that there can be long-running commands and that the redis command documentation shows the time complexity of all commands.

I couldn't find anything around the config set maxmemory-policy command.

Is my assumption correct that setting/changing the maxmemory-policy itself is not an expensive command (unlike e.g. resharding/rebalancing a cluster)?

(I know, "expensive" does not really have a proper definition here :) )

Thanks for any hints or answers!


Solution

  • Yes, the config set command itself is not an expensive command. It iterates the config array which contains about 200 items, to find the config, and set it. That's all.

    However, after the setting, Redis might need to free memory for evicted items periodically or for each command. That's a cost.