Module: SolidCacheMongoid::Store::Api

Included in:
SolidCacheMongoid::Store
Defined in:
lib/solid_cache_mongoid/store/api.rb

Constant Summary collapse

DEFAULT_MAX_KEY_BYTESIZE =
1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#max_key_bytesizeObject (readonly)

Returns the value of attribute max_key_bytesize.



8
9
10
# File 'lib/solid_cache_mongoid/store/api.rb', line 8

def max_key_bytesize
  @max_key_bytesize
end

Instance Method Details

#cleanup(options = nil) ⇒ Object

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/solid_cache_mongoid/store/api.rb', line 34

def cleanup(options = nil)
  raise NotImplementedError.new("#{self.class.name} does not support cleanup")
end

#clear(options = nil) ⇒ Object



38
39
40
# File 'lib/solid_cache_mongoid/store/api.rb', line 38

def clear(options = nil)
  entry_clear
end

#decrement(name, amount = 1, options = nil) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/solid_cache_mongoid/store/api.rb', line 25

def decrement(name, amount = 1, options = nil)
  options = merged_options(options)
  key = normalize_key(name, options)

  instrument :decrement, key, amount: amount do
    adjust(name, -amount, options)
  end
end

#increment(name, amount = 1, options = nil) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/solid_cache_mongoid/store/api.rb', line 16

def increment(name, amount = 1, options = nil)
  options = merged_options(options)
  key = normalize_key(name, options)

  instrument :increment, key, amount: amount do
    adjust(name, amount, options)
  end
end

#initialize(options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/solid_cache_mongoid/store/api.rb', line 10

def initialize(options = {})
  super(options)

  @max_key_bytesize = options.fetch(:max_key_bytesize, DEFAULT_MAX_KEY_BYTESIZE)
end