Skip to content

jihaepat/django-cachedqueryset

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

django-cachedqueryset

This module provides a django QuerySet subclass that attempts to filter in-memory, without hitting the database. This is useful in cases where a dataset is accessed multiple times in a view via related objects: rather than querying the database once for each related object, pull the entire table into memory and filter from there.

Usage

Use CacheManager as the default manager for the models you wish to filter in memory:

from cachedqueryset import CacheManager

class MyModel(models.Model):
    objects = CacheManager()

Then, in your view, use the load_cache method to load all objects into memory:

def my_view(request):
    MyModel.objects.load_cache()

Warning

This is rough around the edges and could use some proper testing. Feel free to contribute ;)

Licence

Copyright © 2011 Omar Khan, released under the MIT licence.

About

In-memory filtering for django QuerySets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%