Django - 持久缓存
有没有办法可以使用默认的 django 缓存框架无限期地设置缓存键?我尝试将超时设置为 0,但不幸的是,这根本没有设置密钥。
Is there a way I can set a cache key indefinitely using the default django cache framework? I tried setting the timeout to 0, but that doesn't set the key at all unfortunately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Django 1.6 现在接受 None 作为超时参数来指定永远。
https://docs.djangoproject.com/en/dev/topics/缓存/#basic-usage
Django 1.6 now accepts None for the timeout argument to specify forever.
https://docs.djangoproject.com/en/dev/topics/cache/#basic-usage
最近有人在一个不相关的答案中提到了 Johnny Cache 。当提供
0
超时时,它提供无限缓存locmem
和memcached
后端。Someone recently mentioned Johnny Cache in an unrelated answer. It provides a infinite caching
locmem
andmemcached
backend when a timeout of0
is provided.