Stores entity bodies on disk at the specified path.
# File lib/rack/cache/entitystore.rb, line 95 95: def exist?(key) 96: File.exist?(body_path(key)) 97: end
Open the entity body and return an IO object. The IO object’s each method is overridden to read 8K chunks instead of lines.
# File lib/rack/cache/entitystore.rb, line 116 116: def open(key) 117: Body.open(body_path(key), 'rb') 118: rescue Errno::ENOENT 119: nil 120: end
# File lib/rack/cache/entitystore.rb, line 140 140: def purge(key) 141: File.unlink body_path(key) 142: nil 143: rescue Errno::ENOENT 144: nil 145: end
# File lib/rack/cache/entitystore.rb, line 99 99: def read(key) 100: File.open(body_path(key), 'rb') { |f| f.read } 101: rescue Errno::ENOENT 102: nil 103: end
# File lib/rack/cache/entitystore.rb, line 122 122: def write(body, ttl=nil) 123: filename = ['buf', $$, Thread.current.object_id].join('-') 124: temp_file = storage_path(filename) 125: key, size = 126: File.open(temp_file, 'wb') { |dest| 127: slurp(body) { |part| dest.write(part) } 128: } 129: 130: path = body_path(key) 131: if File.exist?(path) 132: File.unlink temp_file 133: else 134: FileUtils.mkdir_p File.dirname(path), :mode => 0755 135: FileUtils.mv temp_file, path 136: end 137: [key, size] 138: end
# File lib/rack/cache/entitystore.rb, line 158 158: def body_path(key) 159: storage_path spread(key) 160: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.