Suor / django-cacheops

A slick ORM cache with automatic granular event-driven invalidation.
BSD 3-Clause "New" or "Revised" License
2.1k stars 227 forks source link

Ability to exclude models from cacheops #262

Closed srtonz closed 6 years ago

srtonz commented 6 years ago

We've used cacheops very successfully so far, but would love an option to blacklist certain models in the configuration. Something along the lines below, or maybe using a separate CACHEOPS_EXCLUDE setting:

CACHEOPS = {
    'module.*': {'ops': 'all', 'timeout': 60},
    'module.dontcache': {'exclude': True}
}

The reason is that in some of our larger modules we have django and non-django modules in the same models.py, which blows up when using the module.* notation. Before django-cacheops 4.0 we could simply override the _install_cacheops method on the manager, but that option has disappeared now.

Suor commented 6 years ago

You can set it to None:

CACHEOPS = {
    'module.*': {'ops': 'all', 'timeout': 60},
    'module.dontcache': None,
}

BTW, what do you mean by non-django models? And how do they still have manager?

srtonz commented 6 years ago

Thanks @Suor, I might have overlooked this in the docs somewhere. As for external models, a few DB connectors (django-cassandra-engine for example) provide completely different manager classes to integrate with django.