Class: Sprockets::Cache::RiakStore
- Inherits:
-
Object
- Object
- Sprockets::Cache::RiakStore
- Defined in:
- lib/sprockets-cache-riak/riak_store.rb
Overview
Instance Method Summary collapse
-
#[](key) ⇒ Object
Lookup value in cache.
-
#[]=(key, value) ⇒ Object
Save value to cache.
-
#initialize(riak_client, bucket = "sprockets") ⇒ RiakStore
constructor
A new instance of RiakStore.
Constructor Details
#initialize(riak_client, bucket = "sprockets") ⇒ RiakStore
Returns a new instance of RiakStore.
11 12 13 14 |
# File 'lib/sprockets-cache-riak/riak_store.rb', line 11 def initialize(riak_client, bucket = "sprockets") @riak = riak_client @bucket = @riak.bucket(bucket) end |
Instance Method Details
#[](key) ⇒ Object
Lookup value in cache
17 18 19 20 |
# File 'lib/sprockets-cache-riak/riak_store.rb', line 17 def [](key) object = @bucket.get_or_new sanitize_key(key) object.data if object.data end |
#[]=(key, value) ⇒ Object
Save value to cache
23 24 25 26 27 28 29 |
# File 'lib/sprockets-cache-riak/riak_store.rb', line 23 def []=(key, value) object = @bucket.get_or_new sanitize_key(key) object.raw_data = Marshal.dump(value) object.content_type = "application/x-ruby-marshal" object.store value end |