Class: MetalArchives::Cache::Memory
- Inherits:
-
Base
- Object
- Base
- MetalArchives::Cache::Memory
show all
- Defined in:
- lib/metal_archives/cache/memory.rb
Overview
Instance Attribute Summary
Attributes inherited from Base
#options
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#[](key) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/metal_archives/cache/memory.rb', line 14
def [](key)
if keys.include? key
MetalArchives.config.logger.debug "Cache hit for #{key}"
keys.delete key
keys << key
else
MetalArchives.config.logger.debug "Cache miss for #{key}"
end
cache[key]
end
|
#[]=(key, value) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/metal_archives/cache/memory.rb', line 26
def []=(key, value)
cache[key] = value
keys.delete key if keys.include? key
keys << key
pop if keys.size > options[:size]
end
|
#clear ⇒ Object
36
37
38
39
|
# File 'lib/metal_archives/cache/memory.rb', line 36
def clear
cache.clear
keys.clear
end
|
#delete(key) ⇒ Object
45
46
47
|
# File 'lib/metal_archives/cache/memory.rb', line 45
def delete(key)
cache.delete key
end
|
#include?(key) ⇒ Boolean
41
42
43
|
# File 'lib/metal_archives/cache/memory.rb', line 41
def include?(key)
cache.include? key
end
|