jmettraux / rufus-lru
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (1)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG.txt | Sat Jan 23 23:50:10 -0800 2010 | |
| |
LICENSE.txt | Sat Jan 23 23:42:31 -0800 2010 | |
| |
README.rdoc | Sat Jan 23 23:50:10 -0800 2010 | |
| |
Rakefile | ||
| |
doc/ | Thu Mar 12 16:33:44 -0700 2009 | |
| |
lib/ | Sat Jan 23 23:50:10 -0800 2010 | |
| |
rufus-lru.gemspec | Sat Jan 23 23:52:41 -0800 2010 | |
| |
test/ | Sat Jan 23 23:42:31 -0800 2010 |
README.rdoc
rufus-lru
LruHash class, a Hash with a max size, controlled by a LRU mechanism
getting it
gem install rufus-lru
or at
rubyforge.org/frs/?group_id=4812
usage
It’s a regular hash, but you have to set a maxsize at instantiation.
Once the maxsize is reached, the hash will discard the element that was the least recently used (hence LRU).
require 'rubygems'
require 'rufus/lru'
h = LruHash.new 3
5.times { |i| h[i] = "a" * i }
puts h.inspect # >> {2=>"aa", 3=>"aaa", 4=>"aaaa"}
h[:newer] = "b"
puts h.inspect # >> {:newer=>"b", 3=>"aaa", 4=>"aaaa"}
dependencies
None.
mailing list
On the rufus-ruby list :
http://groups.google.com/group/rufus-ruby
issue tracker
github.com/jmettraux/rufus-lru/issues
irc
irc.freenode.net #ruote
source
github.com/jmettraux/rufus-lru
git clone git://github.com/jmettraux/rufus-lru.git
author
John Mettraux, jmettraux@gmail.com jmettraux.wordpress.com
the rest of Rufus
license
MIT

