I'd rather do the cleanup in a middleware class. 2011/4/11 Alexander Schepanovski <suor....@gmail.com>
> On 11 апр, 17:45, λq <lamb...@gmail.com> wrote: > > Hi list, > > > > I am building a Django website, but some part of the code is slow so I > > migrated data and view functions to Redis. This is how I integrate it: > > > > In views.py > > > > redis_db = redis.Redis(host='', db='') > > > > def _redis_cleanup(sender, **kwargs): > > try: > > redis_db.connection.disconnect() > > except (KeyboardInterrupt, SystemExit, MemoryError): > > raise > > except: > > pass > > > > request_finished.connect(_redis_cleanup) > > > > And use redis_db.get() and redis_db.set() in view functions > > > > Is this the best practice? > > Why are you disconnecting after each request? > I prefer using single connection for worker. > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.