django-redis-cache icon indicating copy to clipboard operation
django-redis-cache copied to clipboard

Add a way to choose the protocol for pickle.

Open twidi opened this issue 13 years ago • 2 comments

Hi

To have a more efficient storage i needed to use another protocol for pickle, so i added a way to change the default one.

Default is 0, and change it by passing another protocol (1 or 2) in the OPTIONS dict of your cache declaration

This work is based on https://github.com/arshaver/django-redis/commit/204216808e31338023878dd8055689f0b9674e96

Twidi

PS : sorry for the noise in the list of commits, i don't now how to avoid this, but the diff is correct

twidi avatar Apr 23 '12 23:04 twidi

FWIW, I think this is a great idea as it would reduce the size of each cache item drastically. The default pickle protocol 0 is ASCII based, which means it'll convert complex data structures to huge values. pickle.HIGHEST_PROTOCOL (or 2 on most Python distributions) should provide a smaller footprint given it's a binary format.

jezdez avatar Jun 02 '12 22:06 jezdez

I added most of this to the 1.0 branch I'm working on. Thanks for your work on this and sorry of lollygaggin' :) I will close this pull request as soon as I merge it into master.

sebleier avatar Jul 06 '12 18:07 sebleier