Class: ActiveSupport::Cache::Litecache

Inherits:
Store
  • Object
show all
Includes:
Strategy::LocalCache
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.



17
18
19
20
21
# File 'lib/active_support/cache/litecache.rb', line 17

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

Returns:

  • (Boolean)


13
14
15
# File 'lib/active_support/cache/litecache.rb', line 13

def self.supports_cache_versioning?
  true
end

Instance Method Details

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



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

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

#clearObject



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

def clear
  @cache.clear
end

#countObject



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

def count
  @cache.count
end

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



36
37
38
39
# File 'lib/active_support/cache/litecache.rb', line 36

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

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



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_support/cache/litecache.rb', line 23

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
  # @cache.transaction(:immediate) do
  if (value = read(key, options))
    value = value.to_i + amount
    write(key, value, options)
  end
  # end
end

#max_sizeObject



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

def max_size
  @cache.max_size
end

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



41
42
43
# File 'lib/active_support/cache/litecache.rb', line 41

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

#sizeObject



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

def size
  @cache.size
end

#statsObject



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

def stats
  @cache.stats
end