从 rdb 恢复过期密钥重新启动 redis 服务器

Restart redis server from rdb restoring expired keys

我从服务器获取了快照 rdb 文件。在快照时,有使用 EXPIRE 命令定义 ttl 的密钥。使用密钥 --dbfilename dump.rdb 在本地启动服务器后,所有具有定义的 ttl 的密钥都已过期。 对我来说,二进制文件中似乎应该有密钥。

如果有帮助:快照是在 AWS elasticache 环境中创建的。

是否可以从备份和恢复密钥启动服务器?

没有。来自文档(强调我的):

Keys expiring information is stored as absolute Unix timestamps (in milliseconds in case of Redis version 2.6 or greater). This means that the time is flowing even when the Redis instance is not active.

https://redis.io/commands/expire

如果您希望备份无限期存在,则必须保留所有密钥。

Redis Labs 的免费 RedisInsight 工具具有从 RDB 文件恢复的功能,并带有“忽略过期”选项。查看“批量操作”下的内容。

https://redislabs.com/redis-enterprise/redis-insight/