Re: [] Re: memcached - Errors and Solution - please provide comments!
Hello and thanks for the respond.
My knowledge on caching was little. I used it, but I never programmed it
my self. So I had no idea about how the keys would be stored.
The solution was... I did not mess with my memcached.py or anything
else. I just use it as everybody else is using it.
The problem was in my code. The keys where sometimes too long and '\n'
new line characters got inserted. But control characters are not
allowed.
Don't kill me know... I was thinking come one, maybe the guy who was
writing this bit of code had similar troubles and already corrected it.
I know this should have been the first approach but for some reason I
had the feeling that he did not see this sort of troubles.
################### Code ####################
But he saw it and fixed it already:
-----------------------------------
key = 'base_text' + sha1(url).hexdigest()
################### /Code ####################
so now there are no more troubles with long urls as keys.
Sorry for the noise!
Maybe some noobs (and me!) learned something!
Best wishes
ionic
On Sun, 2011-11-13 at 03:35 +0000, Cal Leeming [Simplicity Media Ltd]
wrote:
> +1 on hashing the key.
>
>
> Just my two cents worth but, the way our company does it as standard
> is something like this:
>
>
> import hashlib
> def generate_key(*args, **kwargs):
> return hashlib.sha224(pickle.dumps([args, kwargs])).hexdigest()
>
>
> Then you can do stuff like:
> lol = YourModel.objects.all()[0]
> generate_key('YourModel', lol.id, 'other stuff')
>
>
> We actually have a replacement caching class which does all this stuff
> behind the scenes that uses this approach, been doing this for almost
> a year with not a single problem so far (although ours still uses md5,
> rather than sha224)
>
>
> Cal
>
>
>
> On Thu, Nov 10, 2011 at 12:07 PM, Henrik Genssen
> <henrik.genssen@miadi.net> wrote:
> Hi inonc,
>
> >Why am I the only one who seems to be faced with such issues?
> >I thought millions out there do use memcached as their
> backend...?
> >Wouldn't be MD5 a great solution to all of us? The guys with
> small
> >sites, don't have issues with scaling, and the guys with big
> sites are
> >in the need of a stable memcached backend.
> >
> >Thanks for your help
> >ionic
>
>
> this is a question I stopped asking my self.
> We inherited the cache-module and overwrote simply the
> problematic function, where the key are generated (also to
> support caching POST requests).
> I was tiered, discussing the need for this (e.g. for XMLRPC
> requests - as 2 + 2 might always be 4 :-)
>
> regards
>
> Henrik
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To post to this group, send email to
> django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users
> +unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users
> +unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home