Methods
Public Class methods
[ show source ]
# File lib/active_support/cache.rb, line 45
45: def initialize
46: end
Public Instance methods
[ show source ]
# File lib/active_support/cache.rb, line 107
107: def decrement(key, amount = 1)
108: log("decrementing", key, amount)
109: if num = read(key)
110: write(key, num - amount)
111: else
112: nil
113: end
114: end
[ show source ]
# File lib/active_support/cache.rb, line 86
86: def delete(key, options = nil)
87: log("delete", key, options)
88: end
[ show source ]
# File lib/active_support/cache.rb, line 90
90: def delete_matched(matcher, options = nil)
91: log("delete matched", matcher.inspect, options)
92: end
[ show source ]
# File lib/active_support/cache.rb, line 94
94: def exist?(key, options = nil)
95: log("exist?", key, options)
96: end
Pass :force => true to force a cache miss.
[ show source ]
# File lib/active_support/cache.rb, line 55
55: def fetch(key, options = {})
56: @logger_off = true
57: if !options[:force] && value = read(key, options)
58: @logger_off = false
59: log("hit", key, options)
60: value
61: elsif block_given?
62: @logger_off = false
63: log("miss", key, options)
64:
65: value = nil
66: seconds = Benchmark.realtime { value = yield }
67:
68: @logger_off = true
69: write(key, value, options)
70: @logger_off = false
71:
72: log("write (will save #{'%.5f' % seconds})", key, nil)
73:
74: value
75: end
76: end
[ show source ]
# File lib/active_support/cache.rb, line 98
98: def increment(key, amount = 1)
99: log("incrementing", key, amount)
100: if num = read(key)
101: write(key, num + amount)
102: else
103: nil
104: end
105: end
[ show source ]
# File lib/active_support/cache.rb, line 78
78: def read(key, options = nil)
79: log("read", key, options)
80: end
[ show source ]
# File lib/active_support/cache.rb, line 48
48: def threadsafe!
49: @mutex = Mutex.new
50: self.class.send :include, ThreadSafety
51: self
52: end
[ show source ]
# File lib/active_support/cache.rb, line 82
82: def write(key, value, options = nil)
83: log("write", key, options)
84: end