This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cachit.objects.all() | |
Cachit.objects.all().update(key_data=3) | |
Cachit.objects.create(key_data=5) | |
CacheIt.objects.all() # Likely to return stale data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objects = CachedManager(default_from_cache=True, cache_timeout=1200) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OurModel.objects.all().from_cache() # Will always hit the cache | |
OurModel.objects.all() # Will only hit the cache if __init__() method sets _retrieve_from_cache to True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cachit.objects.all() | |
Cachit.objects.all().update(key_data=3) | |
Cachit.objects.create(key_data=5) | |
CacheIt.objects.all() # Likely to return stale data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from caching.base import CachingMixing, CachingManager, CachingQuerySet | |
class OurModel(CachingMixin, models.Model): | |
data = models.IntegerField() | |
objects = CachedManager(default_from_cache=True, cache_timeout=1200) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from caching.base import CachingManager, CachingMixin | |
class CacheIt(CachingMixin, models.Model): | |
key_data = models.CharField(max_length=30) | |
related_stuff = models.ForeignKey('related.RelatedStuff') | |
objects = CachingManager() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from caching.base import CachingManager, CachingMixin | |
class CacheIt(CachingMixin, models.Model): | |
key_data = models.CharField(max_length=30) | |
related_stuff = models.ForeignKey('related.RelatedStuff') | |
objects = CachingManager() |
NewerOlder