Skip to main content

An easy-to-use cache for Django models.

Project description

# django-model-cache

An easy-to-use cache for Django models.

This code has been developed and used in a production environment for one year.

## How to use
There follows some examples of use. For further examples, see `tests/simple/tests.py`.

```python
class Brand(models.Model):
name = models.CharField(max_length=128)

cache = CacheController(timeout=None)


class Product(models.Model):
code = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
brand = models.ForeignKey('Brand')
name = models.CharField(max_length=255)

cache = CacheController(fields=['code', ('brand_id', 'name')], related_fields=['brand'], timeout=None)

class Meta:
unique_together = ('name', 'brand')


# Get a product by pk.
product = Product.cache.get(pk=1)

# Get a product by a unique key.
product = Product.cache.get(code='A001')

# Load the related models.
product.load_related()
```

## How to test

Just run `tox` or install the dependencies and run `cd tests/ && ./manage.py test`.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-model-cache-1.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_model_cache-1.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file django-model-cache-1.0.1.tar.gz.

File metadata

  • Download URL: django-model-cache-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.4

File hashes

Hashes for django-model-cache-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1214c4b16417f418e8a94f387d7c278087e57645e1c1d69fd1a31ab87b3be2c9
MD5 fde1436ae2be47be774fc4ca2b0fdb23
BLAKE2b-256 43bb8818f56d32cf1709134965c1b018e5d7381291e1da9fdc0a1d7e3ecf45b5

See more details on using hashes here.

File details

Details for the file django_model_cache-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_model_cache-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.4

File hashes

Hashes for django_model_cache-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9730312b4a57d67afee4e2003c66deeb26f5b2cd4a0b48f4bfa02f658dbc3a17
MD5 c3680c844d8f5e57973a6bfd67d7764e
BLAKE2b-256 d8382f557e6aeec52e5e0342f5ae350394a625f3ca45e3655fad230e7547f884

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page