简体   繁体   English

Elasticache / Redis 新数据的时间戳

[英]Elasticache / Redis Timestamp of new data

Does Elasticache store the time when a data is added to the cache? Elasticache 是否存储数据添加到缓存的时间? I want to filter data on my cache based on the time it was added but I can't find a clear answer if this information is stored in Elasticache automatically or if I have to add this information (timestamp) manually for each data inserted in the cache?我想根据添加时间过滤缓存中的数据,但如果此信息自动存储在 Elasticache 中,或者我必须为插入的每个数据手动添加此信息(时间戳),我无法找到明确的答案缓存?

Thanks!谢谢!

Neither Redis nor ElastiCache's Redis-compatible service store the timestamp automatically. Redis 和 ElastiCache 的 Redis 兼容服务都不会自动存储时间戳。

This would be inneficient as many use causes don't require it, so it's a client application implementation detail.这将是低效的,因为许多使用原因不需要它,因此它是客户端应用程序实现细节。

You may use a sorted set to store this information, so you can query for date ranges.您可以使用排序集来存储此信息,以便您可以查询日期范围。 And you can use Redis server time automatically if you use a Lua script.如果您使用 Lua 脚本,您可以自动使用 Redis 服务器时间。 See How to store in Redis sorted set with server-side timestamp as score?请参阅如何将服务器端时间戳作为分数存储在 Redis 排序集中? . .

This is particularly important if you have multiple nodes connecting, as they may have clock differences.如果您有多个节点连接,这一点尤其重要,因为它们可能存在时钟差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM