memcached key 的生存时间 (TTL) 可以设置为无限吗?
我已经在基于 PHP-MySQL 的应用程序中实现了 memcache,并且它会从后端进程定期更新。
由于某些数据与过期时间和其他后端进程冲突,所以我想出了一个解决方案,但为此我必须使 TTL = 无限。
I have implemented memcache in my PHP-MySQL based app and it gets updated regularly from a backend process.
Due to this some data is conflicting with the expiration time and other backend processes, so I came up with a solution but for that I would have to make the TTL = infinite.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
很简单 - 只需在那里写 0 即可。
Easy - just write 0 there.
您可以将 TTL 设置为 0,这意味着它“永不”过期。
但请记住,它永远不会真正是无限的。数据存储在内存中,在某些情况下会丢失,最明显的是服务器重新启动。 :)
当内存缓存发生故障时,您应该始终能够重建该数据。
更多详细信息请参见此处。
You can set the TTL to 0, which means that it should 'never' expire.
But remember that it will never really be infinite. The data is stored in memory and will be lost under some circumstances, the most obvious being the server being rebooted. :)
You should always have the possibility to reconstruct that data when the memcache fails.
More details to be found here.
据我所知,如果不设置ttl,它就永远不会过期。
但是,有一些密钥替换策略,您可以此处阅读相关内容
As far as I know, if you don't set a ttl, it will never expire.
However, there are replacing policies for keys, about which you can read here