Class: ActiveSupport::Cache::Litecache

Inherits:
Store
  • Object
show all
Defined in:
lib/active_support/cache/litecache.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Litecache

Returns a new instance of Litecache.



19
20
21
22
23
# File 'lib/active_support/cache/litecache.rb', line 19

def initialize(options = {})
  super
  @options[:return_full_record] = true
  @cache = ::Litecache.new(@options) # reachout to the outer litecache class
end

Class Method Details

.supports_cache_versioning?Boolean

prepend Strategy::LocalCache

Returns:

  • (Boolean)


15
16
17
# File 'lib/active_support/cache/litecache.rb', line 15

def self.supports_cache_versioning?
  true
end

Instance Method Details

#cleanup(limit = nil, time = nil) ⇒ Object



52
53
54
# File 'lib/active_support/cache/litecache.rb', line 52

def cleanup(limit = nil, time = nil)
  @cache.prune(limit)
end

#clear(options = nil) ⇒ Object



56
57
58
# File 'lib/active_support/cache/litecache.rb', line 56

def clear(options = nil)
  @cache.clear
end

#countObject



60
61
62
# File 'lib/active_support/cache/litecache.rb', line 60

def count
  @cache.count
end

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



43
44
45
46
# File 'lib/active_support/cache/litecache.rb', line 43

def decrement(key, amount = 1, options = nil)
  options = merged_options(options)
  increment(key, -1 * amount, options)
end

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_support/cache/litecache.rb', line 25

def increment(key, amount = 1, options = nil)
  key = key.to_s
  options = merged_options(options)
  # todo: fix me
  # this is currently a hack to avoid dealing with Rails cache encoding and decoding
  # and it can result in a race condition as it stands
  # @cache.transaction(:immediate) do
  # currently transactions are not compatible with acquiring connections
  # this needs fixing by storing the connection to the context once acquired
  if (value = read(key, options))
    value = value.to_i + amount
    write(key, value, options)
  else
    write(key, amount, options)
  end
  # end
end

#max_sizeObject



68
69
70
# File 'lib/active_support/cache/litecache.rb', line 68

def max_size
  @cache.max_size
end

#prune(limit = nil, time = nil) ⇒ Object



48
49
50
# File 'lib/active_support/cache/litecache.rb', line 48

def prune(limit = nil, time = nil)
  @cache.prune(limit)
end

#sizeObject



64
65
66
# File 'lib/active_support/cache/litecache.rb', line 64

def size
  @cache.size
end

#statsObject



72
73
74
# File 'lib/active_support/cache/litecache.rb', line 72

def stats
  @cache.stats
end