Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to choose the protocol for pickle. #37

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

twidi
Copy link
Contributor

@twidi twidi commented Apr 23, 2012

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
arshaver@2042168

Twidi

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

jezdez and others added 7 commits January 23, 2011 01:10
…d reverted a few unneeded changes.

This also handles the key better internally to prevent multiple "making" of the key.
We can't inherit a class from a basestring and instantiate it, so I changed
the base class to 'object' so we can still to the type checking.

I also discovered a bug with the Django 1.3 compatibility work.  In the
incr_version method, we were using the Redis's rename function to move the key,
but in Redis 2.0 you cannot rename a volitile key.

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

Based on
arshaver@2042168
@jezdez
Copy link
Contributor

jezdez commented Jun 2, 2012

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.

@sebleier
Copy link
Owner

sebleier commented Jul 6, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants