A high-performance Ruby gem for memoizing instance, class, and module methods with thread safety and advanced features.
MemoWise is a Ruby gem that provides advanced memoization for instance, class, and module methods. It caches method return values based on arguments, eliminating redundant expensive computations and significantly speeding up repeated calls. It solves the problem of inefficient memoization in Ruby by offering high performance, thread safety, and features like resetting and presetting values.
Ruby developers building performance-sensitive applications, especially those using memoization to cache expensive calculations, API calls, or database queries. It's ideal for projects where thread safety, inheritance, or frozen object support are concerns.
Developers choose MemoWise for its benchmark-proven speed, comprehensive feature set, and robust handling of edge cases like frozen objects and concurrency. Unlike simpler memoization approaches, it offers reset/preset functionality, preserves method privacy, and works seamlessly across instance, class, and module methods.
The wise choice for Ruby memoization
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks show MemoWise outperforms competitors like memery and dry-core, with reads up to 20x faster in some cases, as detailed in the performance tables.
Supports resetting and presetting memoized values, frozen object compatibility, inheritance, and thread safety, all highlighted in the README as key strengths.
Provides clear documentation on concurrent access, ensuring deterministic behavior after memoization and safe handling before, as explained in the thread safety section.
Maintains method privacy for private methods when memoized, demonstrated in the usage example with private_slow_method.
Cannot memoize methods with implicit or explicit block arguments, limiting its use for common Ruby patterns that rely on blocks.
Memoization can persist across tests in shared instances, requiring manual resets as warned in the README, which adds maintenance and potential for bugs.
Relies on prepend for method interception, which might complicate debugging or conflict with other metaprogramming in complex codebases.