{"id":23546,"library":"disklru","title":"disklru","description":"A disk-based LRU (Least Recently Used) cache for Python that stores cached data on disk, providing persistent caching across sessions. Current version 2.0.4 supports Python >=3.8, with a simple decorator and function-based API. Release cadence is irregular, with updates as needed.","status":"active","version":"2.0.4","language":"python","source_language":"en","source_url":"https://github.com/zackees/disklru","tags":["disklru","cache","lru","disk-cache","persistent-cache"],"install":[{"cmd":"pip install disklru","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"`discache` was a function in earlier versions; now use DiskLRU class or decorator.","wrong":"from disklru import discache","symbol":"DiskLRU","correct":"from disklru import DiskLRU"},{"note":"Decorator for disk-based caching, similar to functools.lru_cache.","wrong":"","symbol":"lru_cache","correct":"from disklru import lru_cache"}],"quickstart":{"code":"from disklru import DiskLRU\n\ncache = DiskLRU(capacity=10, cache_dir='/tmp/my_cache')\n@cache.cache()\ndef expensive_function(key):\n    return f'result for {key}'\n\nprint(expensive_function('a'))  # cached\n","lang":"python","description":"Create a disk-based LRU cache and use the decorator to cache function results."},"warnings":[{"fix":"Replace `from disklru import discache` with `from disklru import DiskLRU` and use `cache = DiskLRU(...); @cache.cache()`","message":"In version 2.0.0, the API changed significantly. The old `discache` function is removed. Use `DiskLRU` class with `@cache.cache()` decorator instead of `@discache()`. Also, the `lru_cache` decorator was added.","severity":"breaking","affected_versions":"<2.0.0 to >=2.0.0"},{"fix":"Delete the cache_dir or implement versioning in the cache key.","message":"The cache directory persists between runs. If you change the function logic, you must manually clear the cache directory to invalidate stale entries.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure all cached data can be serialized with pickle.","message":"Pickle is used for serialization, so cached objects must be picklable. Custom objects may fail.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from disklru import DiskLRU` and instantiate it: `cache = DiskLRU(...)` then `@cache.cache()`","cause":"The `discache` function was removed in version 2.0.0.","error":"ImportError: cannot import name 'discache' from 'disklru'"},{"fix":"Ensure you have created a DiskLRU instance, and use `@cache_instance.cache()` decorator (with parentheses).","cause":"Using `@cache.cache` without calling `DiskLRU` first, or misspelling the method name.","error":"AttributeError: 'DiskLRU' object has no attribute 'cache'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}