Re: Using redis in django views
Hello,
I just tried with django-redis by using redis as a cache.
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': '/tmp/vgbet_redis.sock',
'OPTIONS': {
'DB': 1,
'PASSWORD': None,
'PARSER_CLASS': 'redis.connection.HiredisParser'
},
},
}
And I still have the same result if I open two tabs in my browser. The
second view is blocked for 5 seconds, as if everything is synchronous.
from django.core.cache import cache
def test_view(request):
if cache.get('test') != None:
print 'Locked'
else:
cache.set('test', '', 60)
for i in range(5):
print '%i locked' % i
time.sleep(1)
cache.delete('test')
return render_to_response("test.html", {
}, context_instance=RequestContext(request))
If I open two terminals, I have no issue reading and writing in redis.
So I really don't understand why I'm not able to use the cache in
views.
Regards,
--
Ashe
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home