Django:限制数据库支持的会话的大小? [英] Django: Limit to size of database-backed sessions?

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

问题描述

Django 的文档(此处) 声明基于 cookie 的会话可以超过每个 cookie 4096 字节的标准".

Django's documentation (here) state that cookie-based sessions can exceed the 'standard' of 4096 bytes per cookies.

数据库支持的会话怎么样,session中可以存储的数据量有限制吗?我在文档和 SO 上都没有看到任何内容.

What about database-backed sessions, is there a limit to the amount of data that can be stored in the session? I didn't see anything in the documentation, nor on SO.

对于我的项目,我需要将 ~50KB 保存到用户的数据库支持的会话中.如果您需要更多信息,请告诉我.

For my project, I'll need to save ~50KB to a user's database-backed session. Let me know if you need more info.

推荐答案

数据库后端将会话数据存储在 TextField 在数据库中.

The database backend stores the session data in a TextField in the database.

该字段的大小限制取决于您的数据库后端,例如,对于 Postgres(存储为 text)它无限制,对于 MySQL(存储为 longtext),大约是 4GB.

The size limit of this field depends on your database backend, e.g., for Postgres (stored as text) it is unlimited, and for MySQL (stored as longtext) it is approximately 4GB.

无论哪种方式,限制都将远远高于 ~50KB!

Either way the limit is going to be far higher than ~50KB!

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

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