On this page
article
Weakref Cache
Cache without preventing GC.
Category: weakref
Problem
Cache without preventing GC.
Solution
cache = weakref.WeakValueDictionary()
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path