Yes I agree. I never quite understood why the CACHE_MIDDLEWARE_KEY_PREFIX was implemented, but not at the lower level (did the cache API become available after the middleware caching?). Of course a custom backend can be written, but then there would need to be a different one for each backend type. This is a very simple change to BaseCache that provides a means off prefixing. I also added a default for `key_prefix' in BaseCache (so current custom backends don't need to be rewritten and will work as normal).
BTW, the patch passes all previous tests at that revision (with the exception of a non-related markup test?) and I also subclassed all the cache tests and added a CACHE_KEY_PREFIX (renamed from PROJECT_KEY_PREFIX) for those tests -- they all pass as well. I also added a preliminary snippet of documentation that most likely will need to be expanded on. I would appreciate any suggestions, criticisms, etc. On Jun 19, 1:26 pm, Mikhail Korobov <kmik...@googlemail.com> wrote: > This is a good feature and I also have my custom cache backend with > project-level key prefixes. It was easy to implement and doesn't > require changes in django core. But if this backend is in django core > (that's a good idea) then some other changes should be done. There > will be 2 similar options after this change: > CACHE_MIDDLEWARE_KEY_PREFIX and PROJECT_CACHE_PREFIX. I think the > patch should deprecate CACHE_MIDDLEWARE_KEY_PREFIX and maybe overhaul > key_prefix arguments (and their defaults) to make the code cleaner. > > On Jun 19, 4:46 am, Byron <bjr...@gmail.com> wrote: > > > > > Opened a ticket and added my > > patch..http://code.djangoproject.com/ticket/13795 > > > On Jun 15, 7:15 pm, Giuseppe Ciotta <gcio...@gmail.com> wrote: > > > > On Wed, Jun 16, 2010 at 1:04 AM, Giuseppe Ciotta <gcio...@gmail.com> > > > wrote: > > > > On Wed, Jun 16, 2010 at 12:46 AM, Jeremy Dunck <jdu...@gmail.com> wrote: > > > >> On Sun, Jun 13, 2010 at 7:18 AM, lenz <lenzhir...@googlemail.com> > > > >> wrote: > > > >>> Could you share your code with us? > > > >>> Thanks you! > > > > >> This might help: > > > >>http://gist.github.com/425403 > > > > > I have some similar code here:http://gist.github.com/439868 > > > > > It might be better because it wraps an arbitrary cache backend adding > > > > prefix handling, it's not limited to memcache. > > > > Uhm,http://gist.github.com/425403doesindeedsupport an arbitrary > > > backend, there's just a call to _get_memcache_timeout() which should > > > be changed in order to make it completely backend agnostic. I left > > > "*args, **kwargs" signatures everywhere to avoid dealing with > > > parameters. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.