Skip to content

RFC: Cache arbitrary and m2m models #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

blag
Copy link

@blag blag commented Jan 4, 2016

Add configuration for caching arbitrary models, including ManyToManyField.through models.

This should solve #23 and (if I understand it correctly) #1.

This change requires users to add caching to their INSTALLED_APPS setting and to register all models they want to cache with the new CACHE_MACHINE_MODELS setting, including ManyToManyField.through models. That means there's two different places to set up caching your own models, which I'm not happy with. But this is good enough to get some review and comments, so here it is!

A few caveats:

  1. Tests for the added functionality have not been implemented yet - at all. If you get to this before me I would be grateful.
  2. It would not be difficult (and I am considering) implementing a CachedManyToManyField field that automatically caches the through model. Please comment on this if you have any insight.
  3. Full documentation of these changes is not complete yet, but the current README.rst should be complete enough to get testers up and running. I will finish this up before asking for this PR to be merged.

@blag
Copy link
Author

blag commented Jan 4, 2016

The second commit fixed flake8 issues, but didn't change any of the relevant logic, meaning that this PR doesn't break anything that's tested! 😄

@tobiasmcnulty
Copy link
Member

Hi @blag, apologies for the delay on this. Overall I very much like the idea of adding support for caching arbitrary models, but monkey-patching __bases__ seems too magical (not that I can think of a better way, unfortunately...).

Rather than merge this into django-cache-machine proper, what I might suggest instead is documenting this in a Gist or blog post as a workaround for people needing this feature. If there is sufficient interest and field testing this might be possible to refactor and merge this at some point!

@blag
Copy link
Author

blag commented Oct 14, 2017

I don't mind this being closed, but this functionality is definitely wanted from your users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants