Class: Jerakia::Cache::File

Inherits:
Jerakia::Cache show all
Defined in:
lib/jerakia/cache/file.rb

Instance Method Summary collapse

Methods inherited from Jerakia::Cache

#bucket, #get, #in_bucket?

Constructor Details

#initializeFile

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

Returns:

  • (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