Registry / data / cachey

cachey

JSON →
library0.2.1pypiunverified

Cachey is a Python library from Dask designed for caching in analytic computations where the costs of recomputation and storage can vary significantly. Unlike traditional caching policies (e.g., LRU), Cachey is mindful of these varying costs. The latest PyPI version is 0.2.1, released in March 2020. The project README states it is 'new and not robust'.

pip install cachey
INSTALL
IMPORT
SIG · CACHEY
C
cachey
dataenv0.2.1
Install
1.6s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cache
✓ from cachey import Cache

This example demonstrates how to initialize `Cachey` with a memory limit and use the `@cache.memoize` decorator to cache the results of an expensive function. The `key` and `cost` parameters help Cachey manage its eviction policy effectively.

from cachey import Cache from time import sleep # Initialize a cache with a 2 GB limit cache = Cache(2 * 10**9) @cache.memoize(key='my-expensive-function', cost=100) # Define key and estimated cost def my_expensive_function(x): print(f"Computing for {x}...") sleep(0.1) # Simulate expensive computation return x + 1 # First call will compute and cache result1 = my_expensive_function(1) print(f"Result 1: {result1}") # Second call with same arguments will retrieve from cache result2 = my_expensive_function(1) print(f"Result 2: {result2}") # Call with different arguments will compute and cache separately result3 = my_expensive_function(2) print(f"Result 3: {result3}")
Debug
Known issues
gotchaThe official GitHub README for Cachey explicitly states: 'Cachey is new and not robust.' Users should be aware that the library might have unaddressed issues or lack full stability, and it may not be suitable for critical production systems without thorough testing.
fix
Thoroughly test `cachey` in your specific use case. Consider alternative, more mature caching libraries for robust production environments if stability is a primary concern.
affects: All versions (0.1.0 - 0.2.1)
deprecatedThe last release of Cachey (v0.2.1) was on March 11, 2020. This indicates a lack of active development and maintenance, which may lead to unpatched bugs, security vulnerabilities, or incompatibility with newer Python versions or related libraries.
fix
Review the project's GitHub repository for any recent activity not reflected in PyPI releases. For new projects, evaluate more actively maintained caching solutions. If using Cachey, be prepared to address potential compatibility issues or maintain the code yourself.
affects: <=0.2.1
Errors
Common errors & fixes
Unexpected cache misses or stale data when using @cache.memoize
The `key` parameter in `@cache.memoize` might not fully represent all differentiating inputs to the function, leading to cache collisions or incorrect retrieval. Alternatively, the cache eviction policy might be removing items prematurely due to incorrect `cost` estimation.
fix
Ensure the `key` argument of `@cache.memoize` is a unique identifier derived from all relevant function inputs. For example, if a function takes multiple arguments, combine them into a tuple for the key. Re-evaluate the `cost` parameter to accurately reflect the relative expense (computation + storage) of recomputing and storing the function's output.
MemoryError: Cannot allocate memory for cache
The `Cache` object is initialized with a `nbytes` parameter (total memory limit) that is too large for the available system memory, or the `cost` attributed to cached items is underestimated, causing the cache to attempt to store more data than it can hold or than the system can provide.
fix
Reduce the initial `nbytes` value passed to the `Cache` constructor. Profile the actual memory usage of the objects being cached and adjust the `cost` parameter in `@cache.memoize` to better reflect their true memory footprint. Monitor system memory usage to identify if other processes are competing for resources.
Upgrade
Version history
0.2.1latest on PyPI · released Mar 11, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
1
Resources

No resource links recorded.

cachey — pip install cachey · libregistry