A Ruby and Rack cache layer with model binding and hierarchical invalidation for application logic caching.
Garner is a cache layer for Ruby and Rack applications that implements various caching strategies with a focus on model binding and hierarchical invalidation. It solves the problem of manual cache management by automatically invalidating cached results when bound model instances or classes change, ensuring data consistency. The library gathers data from multiple sources and makes it readily available through a unified caching interface.
Ruby developers building Rack-based web applications, especially those using Mongoid or ActiveRecord ORMs, who need efficient and automated caching solutions to improve performance and reduce database load.
Developers choose Garner for its seamless integration with Ruby ORMs, automatic cache invalidation through model bindings, and pluggable strategies that allow customization without sacrificing simplicity. It reduces boilerplate code by handling cache key generation and invalidation logic out-of-the-box.
A set of Rack middleware and cache helpers that implement various caching strategies.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Binds cache results to model instances or classes using strategies like Touch, automatically invalidating caches when data changes, as shown in examples with `garner.bind(current_user)`.
Provides Rack middleware and mixins that compose cache keys from request parameters and path by default, reducing boilerplate for web applications.
Includes mixins for Mongoid and ActiveRecord, enabling cached find operations (e.g., `garnered_find`) and identity-based binding without database queries.
Offers configurable binding key and invalidation strategies, allowing developers to tailor cache behavior, as seen in `Garner.config.binding_key_strategy` settings.
The README notes breaking changes between versions (e.g., 0.3.x to 0.5.x), requiring careful migration and potentially disrupting existing implementations.
Primarily supports Mongoid and ActiveRecord; other Ruby ORMs lack built-in mixins, forcing custom integrations or workarounds.
Numerous configurable options like `mongoid_identity_fields` and context key strategies add complexity, making optimal setup non-trivial for beginners.