Class: Jerakia::Cache::File
Instance Method Summary
collapse
#bucket, #get, #in_bucket?
Constructor Details
#initialize ⇒ File
Returns a new instance of File.
6
7
8
|
# File 'lib/jerakia/cache/file.rb', line 6
def initialize
super
end
|
Instance Method Details
#add(index, data) ⇒ Object
19
20
21
22
23
|
# File 'lib/jerakia/cache/file.rb', line 19
def add(index,data)
@@bucket[index] ||= {}
@@bucket[index][:state] = state(index)
super
end
|
#state(filename) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/jerakia/cache/file.rb', line 11
def state(filename)
if ::File.exists?(filename)
::File.stat(filename).mtime
else
nil
end
end
|
#valid?(index) ⇒ Boolean
25
26
27
28
29
30
31
|
# File 'lib/jerakia/cache/file.rb', line 25
def valid?(index)
if in_bucket?(index)
@@bucket[index][:state] == state(index)
else
false
end
end
|