Add CacheStore, a store that uses Django's cache framework - #2304
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||
tim-schilling
left a comment
There was a problem hiding this comment.
Thank you for adding this. We'll need to add some documentation around this as well. I suspect you're just looking for feedback on the approach right now though. I have a few questions.
For me, I think I would have gone with a ContextVar to control the tracking of the cache panel similar to allow_sql, but this should be fine.
|
Another thought, I wonder if we can run the full test suite using |
|
Thanks for the review! A couple notes:
I'll look into your other comments today. Good stuff. |
|
An interesting discovery: The Is this acceptable behavior, or should we also prevent these SQL queries from being tracked? It should be possible to dynamically add the
|
f9572df to
c90b3ac
Compare
It seems like we should have the ability to disable all tracking from within the toolbar temporarily, but ideally also allow the user to view those events. I suspect this means we need to shift away from However, reducing our scope to just this change, I think ideally we'd prevent these SQL queries from being tracked. If it's not going to result in something horrible, I think we should do that. |
|
I refactored the tests a bit to test the various cache backends and added support for not tracking the self-generated SQL from the cache store using a database. |
tim-schilling
left a comment
There was a problem hiding this comment.
This is looking good! I think we'll want to write a little documentation about this and add it to the change log. I have yet to pull it down and run it in the example app, but I'm not super worried about finding something. It's more of a final sanity test.
8d1c975 to
3c54e0e
Compare
|
Sorry for the delay. I finally got around to adding some docs and updated the changes file. Let me know if there's anything else you'd like to see here. :) |
Use functools.wraps() in _UntrackedCache Use delete_many for efficiency Use deque for O(1) pops Add test to verify no self cache tracking Refactor tests with a `CommonStoreTestsMixin` Add tests for different cache backends
3c54e0e to
3a87785
Compare
tim-schilling
left a comment
There was a problem hiding this comment.
This looks good. I added a test that confirms the cache database operations are tracked when it's enabled. I moved the config documentation up to be alphabetical and added a :ref: link for the store backend class. I then squashed the commits and removed some of the unnecessary messages.
Summary
CacheStorethat uses Django's cache framework to persist toolbar dataCACHE_BACKENDandCACHE_KEY_PREFIXsettings to configure which cache and key prefix to use_UntrackedCacheproxyMotivation
By using Django's cache framework, users can choose any configured cache backend for toolbar storage. The interesting thing about this is that the
LocMemCachebackend can effectively act like theMemoryStore, and theDatabaseCachebackend can effectively act like theDatabaseStore.Notes
FileBasedCache)Checklist:
docs/changes.rst.AI/LLM Usage