Innate::Cache::FileBased

Used by caches that serialize their contents to the filesystem. Right now we do not lock around write access to the file outside of the process, that means that all FileBased caches are not safe for use if you need more than one instance of your application.

Attributes

filename[R]

Public Instance Methods

cache_clear() click to toggle source
    # File lib/innate/cache/file_based.rb, line 21
21:       def cache_clear
22:         FileUtils.mkdir_p(@dir)
23:         FileUtils.rm_f(@filename)
24:         @store = self.class::STORE.new(@filename)
25:       end
cache_delete(*args) click to toggle source
    # File lib/innate/cache/file_based.rb, line 35
35:       def cache_delete(*args)
36:         super{|key| transaction{|store| store.delete(key) } }
37:       end
cache_fetch(*args) click to toggle source
    # File lib/innate/cache/file_based.rb, line 31
31:       def cache_fetch(*args)
32:         super{|key| transaction{|store| store[key] } }
33:       end
cache_setup(*args) click to toggle source
    # File lib/innate/cache/file_based.rb, line 11
11:       def cache_setup(*args)
12:         @prefix = args.compact.join('-')
13: 
14:         @dir = File.join(Dir.tmpdir, self.class::DIR)
15:         FileUtils.mkdir_p(@dir)
16: 
17:         @filename = File.join(@dir, @prefix + self.class::EXT)
18:         @store = self.class::STORE.new(@filename)
19:       end
cache_store(*args) click to toggle source
    # File lib/innate/cache/file_based.rb, line 27
27:       def cache_store(*args)
28:         super{|key, value| transaction{|store| store[key] = value } }
29:       end
transaction(&block) click to toggle source
    # File lib/innate/cache/file_based.rb, line 39
39:       def transaction(&block)
40:         Innate.sync{ @store.transaction(&block) }
41:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.