class Sprockets::Cache

Public: Wrapper interface to backend cache stores. Ensures a consistent API even when the backend uses get/set or read/write.

Public cache interface

Always assign the backend store instance to Environment#cache=.

environment.cache = Sprockets::Cache::MemoryStore.new(1000)

Environment#cache will always return a wrapped Cache interface. See the methods marked public on this class.

Backend cache interface

The Backend cache store must implement two methods.

get(key)

key - An opaque String with a length less than 250 characters.

Returns an JSON serializable object.

set(key, value)

Will only be called once per key. Setting a key "foo" with value "bar",
then later key "foo" with value "baz" is an undefined behavior.

key   - An opaque String with a length less than 250 characters.
value - A JSON serializable object.

Returns argument value.

clear(options)

Clear the entire cache. Be careful with this method since it could
affect other processes if shared cache is being used.

The options hash is passed to the underlying cache implementation.