Skip to main content
Version: Next

Caching stores

Built-in stores

In-memory store

This is the default store used as part of the cache_store setting.

This cache store is implemented as part of the Marten::Cache::Store::Memory class. This cache stores all data in memory within the same process, making it a fast and reliable option for caching in single process environments. However, it's worth noting that if you're running multiple instances of your application, the cache data will not be shared between them.

For example:

Marten.configure do |config|
config.cache_store = Marten::Cache::Store::Memory.new(expires_in: 24.hours)
end

Null store

A cache store implementation doesn't store any data.

This cache store is implemented as part of the Marten::Cache::Store::Null class. This cache store does not store any data, but provides a way to go through the caching interface. This can be useful in development and testing environments when caching is not desired.

For example:

Marten.configure do |config|
config.cache_store = Marten::Cache::Store::Null.new(expires_in: 24.hours)
end

Other stores

Additional cache stores shards are also maintained under the umbrella of the Marten project or by the community itself and can be used as part of your application depending on your specific caching requirements:

info

Feel free to contribute to this page and add links to your shards if you've created cache stores that are not listed here!