module Plezi::Base::HasCache
Provides a thread-safe caching engine
Public Class Methods
extended(base)
click to toggle source
initializes the cache
# File lib/plezi/render/has_cache.rb, line 6 def self.extended(base) base.instance_variable_set :@_lock, Mutex.new base.instance_variable_set :@_cache, {}.dup end
Public Instance Methods
get(key)
click to toggle source
Retrieves data form the cache
# File lib/plezi/render/has_cache.rb, line 17 def get(key) @_lock.synchronize { @_cache[key] } end
Also aliased as: []
store(key, value)
click to toggle source
Stores data in the cache
# File lib/plezi/render/has_cache.rb, line 12 def store(key, value) @_lock.synchronize { @_cache[key] = value } end
Also aliased as: []=