Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django,redis-redis重新启动时刷新的值_Python_Django_Redis_Django Redis - Fatal编程技术网

Python django,redis-redis重新启动时刷新的值

Python django,redis-redis重新启动时刷新的值,python,django,redis,django-redis,Python,Django,Redis,Django Redis,我正在使用 Redis 2.2.12 django redis==3.8.4 django 1.7 设置.py CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379/", } } python manage.py shell from django.core.cache import cache cache.set('k

我正在使用

  • Redis 2.2.12
  • django redis==3.8.4
  • django 1.7
设置.py

CACHES = {
"default": {
    "BACKEND": "django_redis.cache.RedisCache",
    "LOCATION": "redis://127.0.0.1:6379/",

} }
python manage.py shell

from django.core.cache import cache
cache.set('key','value',300000)
cache.get('key')
>>value
但是在
sudo服务redis服务器重启后

from django.core.cache import cache
cache.get('key')
>>NOTHING
redis 127.0.0.1:6379> keys *
(empty list or set)
与redis cli相同的问题

redis 127.0.0.1:6379> set key value
OK
redis 127.0.0.1:6379> keys *
1) "key"
但是在
sudo服务redis服务器重启后

from django.core.cache import cache
cache.get('key')
>>NOTHING
redis 127.0.0.1:6379> keys *
(empty list or set)
redis重新加载或重新启动时刷新数据


我看到我可以手动调用SAVE或BGSAVE,以便在服务器重新启动时保持热状态。在redis cli中,它工作正常。django redis怎么样

你意识到这是有意的行为吗?您有兴趣配置redis来持久化数据吗?@Wtower。AOF持久性记录服务器接收到的每个写入操作,但它的速度很慢,对吗?还有别的办法吗?没那么慢。只有在每次写入都同步的情况下。一秒钟的同步你几乎不会注意到。您可以使用redis benchmark对其进行测试