Handling memcache limit

10 views
Skip to first unread message

Richard Lincoln

unread,
Nov 24, 2011, 11:14:00 AM11/24/11
to gae-se...@googlegroups.com
Hello,

Firstly, thank you very much for gaesessions. I have been using it in
Muntjac and it works great!

http://www.muntiacus.org/

However, one issue that I have been having is that my sessions often
exceed 1Mb in size, at which point memcache raises a ValueError "Values
may not be more than 1000000 bytes in length...". May I ask what the
best way to handle hitting this limit is?

The errors occur when save() is called in my_start_response, so
presumably the idea is to subclass SessionMiddleware and override the
__call__ method. Would that be your recommendation?

Thanks again,

Richard

David Underhill

unread,
Nov 28, 2011, 3:12:45 AM11/28/11
to gae-se...@googlegroups.com
On Thu, Nov 24, 2011 at 08:14, Richard Lincoln <r.w.l...@gmail.com> wrote:
Hello,

Firstly, thank you very much for gaesessions. I have been using it in Muntjac and it works great!

Thanks!  :)
 
http://www.muntiacus.org/

Neat project.  I've bookmarked it to go back and learn more about later.
 
However, one issue that I have been having is that my sessions often exceed 1Mb in size, at which point memcache raises a ValueError "Values may not be more than 1000000 bytes in length...". May I ask what the best way to handle hitting this limit is?

The errors occur when save() is called in my_start_response, so presumably the idea is to subclass SessionMiddleware and override the __call__ method. Would that be your recommendation?

I'd recommend patching the save() method itself.  You'll need to split up the data across multiple memcache keys.  These are pretty gigantic sessions though.  It might all be important data, but perhaps it could be reduced (or compressed?) in some way.  (You'll also need to patch the data loading code too).

Good luck,

~ David

 

Thanks again,

Richard

Reply all
Reply to author
Forward
0 new messages