Class: Sprockets::Cache::Torquebox
- Inherits:
-
Object
- Object
- Sprockets::Cache::Torquebox
- Defined in:
- lib/sprockets-torquebox-cache.rb
Overview
Utilites Torquebox Infinispan Cache for Sprocket caching
environment.cache = Torquebox::Infinispan::Cache.new(...)
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Method Summary collapse
-
#[](key) ⇒ Object
Lookup value in cache.
-
#[]=(key, value) ⇒ Object
Save value to cache.
-
#initialize(cache) ⇒ Torquebox
constructor
A new instance of Torquebox.
Constructor Details
#initialize(cache) ⇒ Torquebox
Returns a new instance of Torquebox.
11 12 13 |
# File 'lib/sprockets-torquebox-cache.rb', line 11 def initialize(cache) @cache = cache end |
Instance Method Details
#[](key) ⇒ Object
Lookup value in cache
16 17 18 19 |
# File 'lib/sprockets-torquebox-cache.rb', line 16 def [](key) data = @cache.get key Marshal.load Base64.decode64(data) if data end |
#[]=(key, value) ⇒ Object
Save value to cache
22 23 24 25 |
# File 'lib/sprockets-torquebox-cache.rb', line 22 def []=(key, value) @cache.put key, Base64.encode64(Marshal.dump(value)) value end |