Categories: None [Edit]
safe_memoize
SafeMemoize is a production-ready, zero-dependency memoization library for Ruby. It uses Ruby's prepend mechanism to wrap methods with a thread-safe cache (Mutex + double-check locking) that correctly handles nil and false return values — fixing the silent bug in the common ||= pattern. Results are cached per unique argument combination, so parameterized methods only compute each variant once. Additional features include TTL expiration, LRU cache size limiting, conditional caching via if:/unless: predicates, lifecycle hooks for hit/eviction/expiration events, per-instance metrics (hit rate, miss rate, computation time), targeted cache invalidation, custom cache key generators, and introspection helpers. Method visibility (public, protected, private) is fully preserved.
Total
Ranking: 176,603 of 193,214
Downloads: 2,309
Daily
Ranking: 13,130 of 193,188
Downloads: 42
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
| Rank | Downloads | Name |
|---|
Depends on
| Rank | Downloads | Name |
|---|---|---|
| 97 | 470,376,754 | simplecov |
Owners
| # | Gravatar | Handle |
|---|---|---|
| 1 | eclecticCoding |