Skip to content

tmessi/django-natural-key-cache

Repository files navigation

Django Natural Key Cache

Build Status Coveralls Status Codecov Status Dependency Status Documentation Status PyPi version

Cache models via natural keys.

Quick Start

Add manager to model.

from django.db import models
from natural_key_cache.cache_manager import NaturalKeyCacheManager

class MyModel(models.Model):
    # Define natural keys, this can be ommited if id/pk is the natural key
    natural_keys = (
        'nat_key',
    )
    cache = NaturalKeyCacheManager(natural_keys)
    nat_key = models.CharField(max_length=32, unique=True)

Then access the cached model via the new manager.

MyModel.cache.get(nat_key='unique_instance')

About

Fast caching for django models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages