why does the redis memory usage not reduce when del half of keys

后端 未结 3 1630
生来不讨喜
生来不讨喜 2020-12-14 08:23

Redis is used to save data but it costs a lot of memory, and its memory usage up to 52.5%. I deleted half of the keys in redis, and the return code of the delete operation i

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-14 09:14

    Since Redis 4.0.0 there's a command for this:

    MEMORY PURGE
    

    Should do the trick: https://redis.io/commands/memory-purge

    Note however that command docs state:

    This command is currently implemented only when using jemalloc as an allocator, and evaluates to a benign NOOP for all others.

    And the README reminds us that:

    Redis is compiled and linked against libc malloc by default, with the exception of jemalloc being the default on Linux systems. This default was picked because jemalloc has proven to have fewer fragmentation problems than libc malloc.

提交回复
热议问题