Class: Redpomo::FileCache

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/redpomo/file_cache.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_pathObject

Returns the value of attribute cache_path.



8
9
10
# File 'lib/redpomo/file_cache.rb', line 8

def cache_path
  @cache_path
end

Class Method Details

.get(key, &block) ⇒ Object



10
11
12
# File 'lib/redpomo/file_cache.rb', line 10

def self.get(key, &block)
  instance.get(key, &block)
end

Instance Method Details

#get(key, &block) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/redpomo/file_cache.rb', line 14

def get(key, &block)
  return existing_keys[key] if existing_keys.has_key?(key)
  if block_given?
    value = block.call
    set(key, value)
    value
  end
end