Stores entity bodies on disk at the specified path.
# File lib/rack/cache/entitystore.rb, line 95 def exist?(key) File.exist?(body_path(key)) 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 def open(key) Body.open(body_path(key), 'rb') rescue Errno::ENOENT nil end
# File lib/rack/cache/entitystore.rb, line 140 def purge(key) File.unlink body_path(key) nil rescue Errno::ENOENT nil end
# File lib/rack/cache/entitystore.rb, line 99 def read(key) File.open(body_path(key), 'rb') { |f| f.read } rescue Errno::ENOENT nil end
# File lib/rack/cache/entitystore.rb, line 122 def write(body, ttl=nil) filename = ['buf', $$, Thread.current.object_id].join('-') temp_file = storage_path(filename) key, size = File.open(temp_file, 'wb') { |dest| slurp(body) { |part| dest.write(part) } } path = body_path(key) if File.exist?(path) File.unlink temp_file else FileUtils.mkdir_p File.dirname(path), :mode => 0755 FileUtils.mv temp_file, path end [key, size] end
Generated with the Darkfish Rdoc Generator 2.