{"repo":"jaemk/cached","free":true,"listed":false,"github":"https://github.com/jaemk/cached","clone":"git clone https://github.com/jaemk/cached.git","description":"Rust cache structures and easy function memoization","language":"Rust","stars":2075,"topics":["rust","cache","caching","lrucache","rustlang","memoization","rust-caching"],"license":"MIT","category":"dev-tools","readme_excerpt":"cached Caching structures and simplified function memoization cached provides implementations of several caching structures as well as macros for defining memoized functions. Requires Rust = 1.92. (The async core / async features do not compile before 1.92: the CachedGetOrSetAsync default bodies hit a borrowck limitation rustc attributes to rust-lang/rust#100013. rust-version is a single crate-level value, so the floor applies to every feature set.) Memoized functions defined using #[cached] / #[once] macros are thread-safe with the backing function-cache wrapped in a mutex/rwlock. #[concurrent cached] functions are thread-safe via the store's own internal synchronization: sharded stores use per-shard parking lot::RwLock ; Redis and disk stores rely on their respective server/file-system concurrency. By default, #[cached] uses no write synchronization: concurrent uncached calls for the same key may each compute independently and overwrite each other, matching the 2.x behavior and Python's functools.lru cache . Set sync writes = \"by key\" to deduplicate concurrent first calls for the same key through bucketed per-key locks. Set sync writes = true (or \"default\" ) to hold the whole-cache lock for the duration of each miss. Note: \"by key\" holds the per-key bucket lock across the entire function body, so it must not be used on recursive or re-entrant memoized functions (deadlock risk when keys in the active call chain share a bucket). #[once] defaults to no synchronization (add syn","default_branch":null,"files":null,"tree":[],"storefront":"/r/jaemk","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/jaemk/cached/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}