Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/honkster/cache-store-api

Ruby cache methods built on top of Rails and Sinatra caching.
https://github.com/honkster/cache-store-api

Last synced: 3 months ago
JSON representation

Ruby cache methods built on top of Rails and Sinatra caching.

Awesome Lists containing this project

README

        

# CacheStoreApi

## lazy_cache

Lazily cache the contents of the block. It takes the cache key and time to expiration as arguments.

CacheStoreApi.lazy_cache("cache-key", 1.week) do
@my_expensive_models = Model.all(:conditions => "some-expensive-query")
render_to_string(:template => "my/template/path/index.html")
end.tap do |html|
render :text => html
end

## expire

Expires the given cache key.

CacheStoreApi.expire("cache-key")

## cache

Access to the raw cache object.

CacheStoreApi.cache.instance_variable_get("@pool")