Django会话 [英] Django Sessions

查看:128
本文介绍了Django会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看Django中的会话,默认情况下它们存储在数据库中。文件系统和缓存会话的好处是什么,何时应该使用?

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?

推荐答案

文件系统后端只是值得一看您不会为系统的其他任何部分使用数据库。如果您正在使用数据库,则文件系统后端没有任何推荐。

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.

memcache后端比数据库后端快得多,但是您遇到会话的风险被清除,并且您的一些会话数据丢失。

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.

这篇关于Django会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆