-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.rb
39 lines (34 loc) · 1.34 KB
/
cache.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'active_support/cache'
require 'forwardable'
class Cache
extend Forwardable
@@cache = nil
def_delegator :@@cache, :cleanup , :'self.cleanup'
def_delegator :@@cache, :clear , :'self.clear'
def_delegator :@@cache, :decrement, :'self.decrement'
def_delegator :@@cache, :delete, :'self.delete'
def_delegator :@@cache, :delete_matched , :'self.delete_matched'
def_delegator :@@cache, :exist? , :'self.exist?'
def_delegator :@@cache, :fetch, :'self.fetch'
def_delegator :@@cache, :fetch_multi , :'self.fetch_multi'
def_delegator :@@cache, :increment, :'self.increment'
def_delegator :@@cache, :instrument, :'self.instrument'
def_delegator :@@cache, :instrument= , :'self.instrument='
def_delegator :@@cache, :key_matcher , :'self.key_matcher'
def_delegator :@@cache, :mute , :'self.mute'
def_delegator :@@cache, :read, :'self.read'
def_delegator :@@cache, :read_multi , :'self.read_multi'
def_delegator :@@cache, :silence! , :'self.silence!'
def_delegator :@@cache, :write , :'self.write'
class << self
def setup(store='MemoryStore', options={})
@@cache = "ActiveSupport::Cache::#{store}".constantize.new(options)
end
alias :new :setup
alias :init :setup
alias :initialize :setup
def cache
@@cache
end
end
end # class Cache