best place to clear cache when restarting django server

后端 未结 5 1770
野的像风
野的像风 2020-12-13 00:45

I want memcached to be flushed on every restart/reload of django server. I use cherrypy for production and builtin server for development.

I would add this to settin

5条回答
  •  醉酒成梦
    2020-12-13 01:22

    How about this? Define a boolean value in settings.py, for example CLEAR_CACHE_ON_RESTART = True and then check in other place if it is True. If it is, then clear cache and set it to False. This code can be placed in any view (like a main view) and probably even in manage.py or urls.py (although I didn't check this and it doesn't look too good). Give it a try!

提交回复
热议问题