Parent

Methods

Sprockets::Cache::FileStore

A simple file system cache store.

    environment.cache = Sprockets::Cache::FileStore.new("/tmp")

Public Class Methods

new(root) click to toggle source
    # File lib/sprockets/cache/file_store.rb, line 12
12:       def initialize(root)
13:         @root = Pathname.new(root)
14:       end

Public Instance Methods

[](key) click to toggle source

Lookup value in cache

    # File lib/sprockets/cache/file_store.rb, line 17
17:       def [](key)
18:         pathname = @root.join(key)
19:         pathname.exist? ? pathname.open('rb') { |f| Marshal.load(f) } : nil
20:       end
[]=(key, value) click to toggle source

Save value to cache

    # File lib/sprockets/cache/file_store.rb, line 23
23:       def []=(key, value)
24:         # Ensure directory exists
25:         FileUtils.mkdir_p @root.join(key).dirname
26: 
27:         @root.join(key).open('w') { |f| Marshal.dump(value, f)}
28:         value
29:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.