Class: Viscacha::Store
- Inherits:
-
ActiveSupport::Cache::Store
- Object
- ActiveSupport::Cache::Store
- Viscacha::Store
show all
- Defined in:
- lib/viscacha/store.rb
Constant Summary
collapse
- DEFAULT_DIR =
Pathname('tmp')
- DEFAULT_NAME =
'viscacha'
- DEFAULT_SIZE =
16.megabytes
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Store
also the minimum size, as localmemcache is unreliable below this value
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/viscacha/store.rb', line 12
def initialize(options = {})
super options
directory = options.fetch(:directory, DEFAULT_DIR)
name = options.fetch(:name, DEFAULT_NAME)
size = options.fetch(:size, DEFAULT_SIZE)
data_store_options = {
filename: Pathname.new(directory).join("#{name}-data.lmc").to_s,
size_mb: [DEFAULT_SIZE, size].max / 1.megabyte
}
meta_store_options = {
filename: Pathname.new(directory).join("#{name}-meta.lmc").to_s,
size_mb: data_store_options[:size_mb]
}
@data_store = LocalMemCache.new(data_store_options)
@meta_store = LocalMemCache.new(meta_store_options)
end
|
Instance Method Details
#cleanup(options = nil) ⇒ Object
38
39
40
|
# File 'lib/viscacha/store.rb', line 38
def cleanup(options = nil)
true
end
|
#clear(options = nil) ⇒ Object
32
33
34
35
36
|
# File 'lib/viscacha/store.rb', line 32
def clear(options = nil)
data_store.clear
meta_store.clear
self
end
|
#decrement(name, amount = 1, options = nil) ⇒ Object
46
47
48
|
# File 'lib/viscacha/store.rb', line 46
def decrement(name, amount = 1, options = nil)
raise NotImplementedError.new("#{self.class.name} does not support #{__method__}")
end
|
#delete_matched(matcher, options = nil) ⇒ Object
50
51
52
|
# File 'lib/viscacha/store.rb', line 50
def delete_matched(matcher, options = nil)
raise NotImplementedError.new("#{self.class.name} does not support #{__method__}")
end
|
#increment(name, amount = 1, options = nil) ⇒ Object
42
43
44
|
# File 'lib/viscacha/store.rb', line 42
def increment(name, amount = 1, options = nil)
raise NotImplementedError.new("#{self.class.name} does not support #{__method__}")
end
|