Module: Lawnchair
- Defined in:
- lib/lawnchair.rb,
lib/view/helper.rb,
lib/storage_engine/redis.rb,
lib/storage_engine/abstract.rb,
lib/storage_engine/composite.rb,
lib/storage_engine/in_process.rb
Defined Under Namespace
Modules: StorageEngine, View
Classes: Cache
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.redis ⇒ Object
Returns the value of attribute redis.
16
17
18
|
# File 'lib/lawnchair.rb', line 16
def redis
@redis
end
|
Class Method Details
.cache(key, options = {}, &block) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/lawnchair.rb', line 18
def cache(key, options={}, &block)
if options[:in_process]
store = Lawnchair::StorageEngine::Composite.new(:in_process, :redis)
else
store = Lawnchair::StorageEngine::Redis
end
interpolate(options[:interpolate]) do
store.fetch(key, options, &block)
end
end
|
.connectdb(redis = nil) ⇒ Object
29
30
31
|
# File 'lib/lawnchair.rb', line 29
def connectdb(redis=nil)
@redis = (redis || Redis.new(:db => 11))
end
|
.flushdb ⇒ Object
33
34
35
|
# File 'lib/lawnchair.rb', line 33
def flushdb
redis.flushdb
end
|
.interpolate(interpolations, &block) ⇒ Object
37
38
39
40
|
# File 'lib/lawnchair.rb', line 37
def interpolate(interpolations, &block)
interpolations ||= {}
interpolations.inject(block.call){|cached_data, interpolated_data| cached_data.gsub(interpolated_data.first, interpolated_data.last) }
end
|