简体   繁体   English

数据应该在Redis Cache中存放多长时间?

[英]How long should data be stored in Redis Cache?

I know I'm sure this answer will vary greatly depending on business needs, but any insights on this?我知道我确定这个答案会根据业务需求而有很大差异,但是对此有什么见解吗? If my main purpose to use Redis Cache is for a fast in memory data storage and retrieval, should I set the expiry time for data to be 10 minutes?如果我使用 Redis Cache 的主要目的是为了 memory 数据的快速存储和检索,我是否应该将数据的过期时间设置为 10 分钟? 15 minutes? 15分钟? 1 hour? 1小时? 1 day? 1天?

Probably for as long as it doesn't get stale?可能只要它不陈旧就可以了? Sometimes it's set to minutes, hours or even days.有时它被设置为几分钟、几小时甚至几天。

However, if this means that your cache will just start filling up and hitting memory limits, then you might experience other issues due to overhead with OOM errors, evictions, higher page faulting etc.但是,如果这意味着您的缓存将刚刚开始填满并达到 memory 限制,那么由于 OOM 错误、逐出、更高的页面错误等开销,您可能会遇到其他问题。

So how long data stays in the cache will likely need to be a balance between ensuring that your cache has up-to-date data but at the same time always leaves some room and generally tries to not run at full memory all the time.因此,数据在缓存中保留多长时间可能需要在确保您的缓存具有最新数据但同时始终留有一些空间并且通常尝试不始终以满 memory 运行之间取得平衡。

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

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