{"id":5142,"library":"cacheout","title":"Cacheout Caching Library","description":"Cacheout is a comprehensive caching library for Python, offering in-memory, dictionary-based caching. It supports various eviction policies including FIFO, LIFO, LRU, MRU, LFU, and RR. Key features include configurable maximum cache size, time-to-live (TTL) expiration per entry, thread-safety, bulk operations, and memoization decorators for functions. The library is actively maintained and is currently at version 0.16.0.","status":"active","version":"0.16.0","language":"en","source_language":"en","source_url":"https://github.com/dgilland/cacheout","tags":["caching","cache","memory cache","memoization","thread-safe"],"install":[{"cmd":"pip install cacheout","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Cache","correct":"from cacheout import Cache"},{"symbol":"CacheManager","correct":"from cacheout import CacheManager"},{"symbol":"memoize","correct":"from cacheout import memoize"},{"note":"Other specific cache types (LIFOCache, LRUCache, MRUCache, LFUCAche, RRCache) are imported similarly.","symbol":"FIFOCache","correct":"from cacheout import FIFOCache"}],"quickstart":{"code":"from cacheout import Cache\nimport time\n\n# Initialize a cache with a max size and default TTL (in seconds)\ncache = Cache(maxsize=100, ttl=60)\n\n# Set a value\ncache.set('key1', 'value1')\n\n# Get a value\nprint(f\"Value for key1: {cache.get('key1')}\")\n\n# Set a value with a custom TTL (overriding the default)\ncache.set('key2', 'value2', ttl=5)\n\n# Check cache size and keys\nprint(f\"Cache size: {cache.size()}\")\nprint(f\"Cache keys: {cache.keys()}\")\n\n# Wait for key2 to expire\ntime.sleep(6)\n\n# Try to get expired key (will return None by default)\nprint(f\"Value for key2 after 6 seconds: {cache.get('key2')}\")\n\n# Use a callable default for missing keys (and set it if missing)\nprint(f\"Value for key3 (missing): {cache.get('key3', default=lambda k: f'computed_for_{k}')}\")\nprint(f\"Value for key3 (now cached): {cache.get('key3')}\")\n","lang":"python","description":"This quickstart demonstrates initializing a Cache, setting and retrieving values, using TTL, and handling missing keys with a callable default."},"warnings":[{"fix":"Ensure your project uses Python 3.7 or a later version.","message":"Python 3.6 support was dropped in v0.14.0. Users must upgrade to Python 3.7 or newer to use cacheout >= 0.14.0.","severity":"breaking","affected_versions":">= 0.14.0"},{"fix":"Replace `cache.setup(...)` with `cache.configure(...)`.","message":"The `Cache.setup()` method was renamed to `Cache.configure()` in v0.2.0. Direct calls to `setup()` will no longer work.","severity":"breaking","affected_versions":">= 0.2.0"},{"fix":"Explicitly set `maxsize` during Cache initialization if a specific size is required (e.g., `Cache(maxsize=300)`).","message":"The default `Cache.maxsize` changed from 300 to 256 in v0.7.0. If your application relied on the previous default, this might lead to earlier evictions.","severity":"breaking","affected_versions":">= 0.7.0"},{"fix":"Update calls to use `cache.get_many(filter=...)` or `cache.delete_many(filter=...)` with appropriate filter arguments (list, string, regex, or function).","message":"In v0.9.0, `Cache.get_many_by()` and `Cache.delete_many_by()` were removed, and their functionality merged into `Cache.get_many()` and `Cache.delete_many()` respectively.","severity":"breaking","affected_versions":">= 0.9.0"},{"fix":"Review logic for `Cache.get()` calls where `default` is a callable to ensure this side-effect of setting the value is intended. If not, adjust your logic or use a non-callable default.","message":"In v0.10.0, the behavior of the `default` argument in `Cache.get()` when it's a callable changed. If the key is missing and `default` is a callable, its return value will now be set in the cache for that key.","severity":"breaking","affected_versions":">= 0.10.0"},{"fix":"Always assume TTL is in seconds unless a custom `timer` function is provided that specifies a different unit.","message":"TTL values are in seconds by default, as the default timer function is `time.time`. Be mindful of this unit when setting `ttl` values for caches or individual entries.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}