-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon Whitaker
committed
Sep 1, 2012
1 parent
4fd7b4b
commit 50f4647
Showing
2 changed files
with
39 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FileCache is a file-based caching library for Ruby. It's | ||
available for download from [RubyForge][rubyforge-filecache] | ||
|
||
# Note about the current code | ||
|
||
I haven't touched this code since I wrote it in 2008! I don't | ||
use Ruby much any more. I'm putting it on Github to make it easy | ||
for people to find, tweak and extend it. Please feel free to | ||
drag it into the 21st century and send me pull requests. | ||
|
||
# Installation | ||
|
||
gem install -r filecache | ||
|
||
(On a Unix-like system you'll probably want to run that with sudo.) | ||
|
||
# Synopsis | ||
|
||
```ruby | ||
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 | ||
``` | ||
|
||
[rubyforge-filecache]: http://rubyforge.org/projects/filecache/ |