Class: ActiveSupport::Cache::Litecache
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::Litecache
- Defined in:
- lib/active_support/cache/litecache.rb
Class Method Summary collapse
-
.supports_cache_versioning? ⇒ Boolean
prepend Strategy::LocalCache.
Instance Method Summary collapse
- #cleanup(limit = nil, time = nil) ⇒ Object
- #clear(options = nil) ⇒ Object
- #count ⇒ Object
- #decrement(key, amount = 1, options = nil) ⇒ Object
- #increment(key, amount = 1, options = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Litecache
constructor
A new instance of Litecache.
- #max_size ⇒ Object
- #prune(limit = nil, time = nil) ⇒ Object
- #size ⇒ Object
- #stats ⇒ Object
Constructor Details
Class Method Details
.supports_cache_versioning? ⇒ Boolean
prepend Strategy::LocalCache
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( = nil) @cache.clear end |
#count ⇒ Object
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, = nil) = () increment(key, -1 * amount, ) 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, = nil) key = key.to_s = () # 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, )) value = value.to_i + amount write(key, value, ) else write(key, amount, ) end # end end |
#max_size ⇒ Object
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 |
#size ⇒ Object
64 65 66 |
# File 'lib/active_support/cache/litecache.rb', line 64 def size @cache.size end |
#stats ⇒ Object
72 73 74 |
# File 'lib/active_support/cache/litecache.rb', line 72 def stats @cache.stats end |