Django Sessions

前端 未结 5 1385
野趣味
野趣味 2021-01-31 15:34

I\'m looking at sessions in Django, and by default they are stored in the database. What are the benefits of filesystem and cache sessions and when should I use them?

5条回答
  •  离开以前
    2021-01-31 16:05

    The filesystem backend is only worth looking at if you're not going to use a database for any other part of your system. If you are using a database then the filesystem backend has nothing to recommend it.

    The memcache backend is much quicker than the database backend, but you run the risk of a session being purged and some of your session data being lost.

    If you're a really, really high traffic website and code carefully so you can cope with losing a session then use memcache. If you're not using a database use the file system cache, but the default database backend is the best, safest and simplest option in almost all cases.

提交回复
热议问题