Django Cache Magic
Project description
Django-Cache-Magic
================
Cache magic addresses two common scenarios for caching and cache invalidation
for django models: *instance caching* and *related objects caching*.
Instance caching: Storing instances of objects in your cache layer
as well as your database.
Related objects caching: Storing a collection of objects related to another
object referenced by relational constraints (ForeignKey, ManyToMany, etc.)
Installing
----------
pip install -e "git+https://github.com/ntucker/django-cache-magic#egg=cachemagic"
Usage
-----
To start autocaching model instances, add a CacheController to your model:
from django.db import models
from cachemagic import CacheController
class myModel(models.Model):
f1 = models.IntegerField()
f2 = models.TextField()
cache = CacheController()
myModel.cache.get(pk=27)
When using cachemagic, you should avoid django operations that update multiple
rows at once, since these operations typically don't emit the signals that
cachemagic relies on for cache invalidation. This includes methods like
[`Queryset.update`](https://docs.djangoproject.com/en/1.3/ref/models/querysets/#update),
[`Queryset.delete`](https://docs.djangoproject.com/en/1.3/ref/models/querysets/#delete),
and
[`RelatedManager.clear`](https://docs.djangoproject.com/en/1.3/ref/models/relations/#django.db.models.fields.related.RelatedManager.clear)
Find the complete documentation at [django-cache-magic.readthedocs.org](http://django-cache-magic.readthedocs.org/).
Thanks
------
Big thanks to [Travis Fischer](https://github.com/travisfischer) for drafting
a lot of documentation and tests!
================
Cache magic addresses two common scenarios for caching and cache invalidation
for django models: *instance caching* and *related objects caching*.
Instance caching: Storing instances of objects in your cache layer
as well as your database.
Related objects caching: Storing a collection of objects related to another
object referenced by relational constraints (ForeignKey, ManyToMany, etc.)
Installing
----------
pip install -e "git+https://github.com/ntucker/django-cache-magic#egg=cachemagic"
Usage
-----
To start autocaching model instances, add a CacheController to your model:
from django.db import models
from cachemagic import CacheController
class myModel(models.Model):
f1 = models.IntegerField()
f2 = models.TextField()
cache = CacheController()
myModel.cache.get(pk=27)
When using cachemagic, you should avoid django operations that update multiple
rows at once, since these operations typically don't emit the signals that
cachemagic relies on for cache invalidation. This includes methods like
[`Queryset.update`](https://docs.djangoproject.com/en/1.3/ref/models/querysets/#update),
[`Queryset.delete`](https://docs.djangoproject.com/en/1.3/ref/models/querysets/#delete),
and
[`RelatedManager.clear`](https://docs.djangoproject.com/en/1.3/ref/models/relations/#django.db.models.fields.related.RelatedManager.clear)
Find the complete documentation at [django-cache-magic.readthedocs.org](http://django-cache-magic.readthedocs.org/).
Thanks
------
Big thanks to [Travis Fischer](https://github.com/travisfischer) for drafting
a lot of documentation and tests!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-cache-magic-0.1.0.tar.gz
(16.0 kB
view details)
File details
Details for the file django-cache-magic-0.1.0.tar.gz
.
File metadata
- Download URL: django-cache-magic-0.1.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37d794560381b8c6077d88ca31414b1e683c803400b197e0e6e96761f43ce352 |
|
MD5 | 3259854a653c1c411803c3e5a9b9c9c4 |
|
BLAKE2b-256 | 62dd85eab50f5a76930086030bc100ee187ce5e599f69a0a749f0c30019f82f3 |