Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Ruby
  3. MemoWise

MemoWise

MITRuby

A high-performance Ruby gem for memoizing instance, class, and module methods with thread safety and advanced features.

GitHubGitHub
632 stars26 forks0 contributors

What is MemoWise?

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.

Target Audience

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.

Value Proposition

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.

Overview

The wise choice for Ruby memoization

Use Cases

Best For

  • Speeding up expensive calculations in Ruby applications
  • Memoizing methods in Rails view helpers or other modules
  • Caching API or database query results in thread-safe environments
  • Optimizing performance in frozen object graphs
  • Implementing memoization with inheritance in class hierarchies
  • Replacing slower or less feature-rich memoization gems like dry-core or memery

Not Ideal For

  • Applications where methods frequently take block arguments, as MemoWise explicitly cannot memoize them.
  • Lightweight scripts or prototypes where the overhead of a full-featured memoization gem is unnecessary.
  • Memory-constrained environments where caching numerous unique results could lead to excessive memory consumption.

Pros & Cons

Pros

Benchmark-Proven Speed

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.

Comprehensive Feature Set

Supports resetting and presetting memoized values, frozen object compatibility, inheritance, and thread safety, all highlighted in the README as key strengths.

Thread Safety Guarantees

Provides clear documentation on concurrent access, ensuring deterministic behavior after memoization and safe handling before, as explained in the thread safety section.

Privacy Preservation

Maintains method privacy for private methods when memoized, demonstrated in the usage example with private_slow_method.

Cons

No Block Argument Support

Cannot memoize methods with implicit or explicit block arguments, limiting its use for common Ruby patterns that rely on blocks.

Testing Complexity

Memoization can persist across tests in shared instances, requiring manual resets as warned in the README, which adds maintenance and potential for bugs.

Metaprogramming Overhead

Relies on prepend for method interception, which might complicate debugging or conflict with other metaprogramming in complex codebases.

Frequently Asked Questions

Quick Stats

Stars632
Forks26
Contributors0
Open Issues8
Last commit1 month ago
CreatedSince 2020

Tags

#metaprogramming#thread-safety#caching#performance-optimization#benchmarks#memoization#ruby-gem#optimization#ruby#performance

Built With

R
Ruby

Included in

Ruby14.1k
Auto-fetched 18 hours ago

Related Projects

VirtusVirtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects

Stars3,746
Forks231
Last commit5 years ago
HashieHashie

Hashie is a collection of classes and mixins that make Ruby hashes more powerful.

Stars3,038
Forks315
Last commit1 month ago
HamsterHamster

Efficient, Immutable, Thread-Safe Collection classes for Ruby

Stars1,911
Forks92
Last commit4 years ago
AddressableAddressable

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. It is flexible, offers heuristic parsing, and additionally provides extensive support for IRIs and URI templates.

Stars1,611
Forks279
Last commit27 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub