FileCache
FileCache is a file-based caching library for Ruby. It’s available for download from RubyForge
Installation
gem install -r filecache
(On a Unix-like system you’ll probably want to run that with sudo.)
Synopsis
require 'rubygems'
require 'filecache'
cache = FileCache.new
cache.set(:key, "value")
puts cache.get(:key) # "value"
cache.delete(:key)
puts cache.get(:key) # nil
# create a new cache called "my-cache", rooted in /home/simon/caches
# with an expiry time of 30 seconds, and a file hierarchy three
# directories deep
cache = FileCache.new("my-cache", "/home/simon/caches", 30, 3)
cache.put("joe", "bloggs")
puts(cache.get("joe")) # "bloggs"
sleep 30
puts(cache.get("joe")) # nil
Copyright
Copyright 2008 Simon Whitaker <[email protected]>
See COPYING for license.