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

feature request: related model caching

Open kesor opened this issue 13 years ago • 0 comments

I am using this technique in some of my models to cache related objects of GenericRelation(s), would this be a possible feature for django-orm-cache to implement?

Code

  • https://gist.github.com/1260033

Example of this kind of caching:

comp = Computer.objects.get(pk=1)
comp.labels.all()                     # queries db and puts comp's labels in the cache
comp.labels.all()                     # returns objects from the cache instead of db
comp.labels.create(name="new label")  # invalidates the cache for comp.labels
comp.labels.all()                     # queries db and puts comp's labels in the cache
comp.labels.get(pk=1).delete()        # invalidates comp's label cache

kesor avatar Oct 03 '11 20:10 kesor