public
Description: LruHash class, a Hash with a max size, controlled by a LRU mechanism (ruby)
Homepage: http://rufus.rubyforge.org/rufus-lru
Clone URL: git://github.com/jmettraux/rufus-lru.git
name age message
file CHANGELOG.txt Mon Mar 31 17:54:35 -0700 2008 first git commit [jmettraux]
file LICENSE.txt Mon Mar 31 17:54:35 -0700 2008 first git commit [jmettraux]
file README.txt Mon Apr 07 17:18:48 -0700 2008 fixed link to source on github.com [jmettraux]
file Rakefile Sun Aug 10 06:54:45 -0700 2008 indent=2 [jmettraux]
directory lib/ Tue Sep 02 23:02:43 -0700 2008 added lib/rufus-lru.rb [jmettraux]
directory test/ Mon Mar 31 17:54:35 -0700 2008 first git commit [jmettraux]
README.txt
= rufus-lru

LruHash class, a Hash with a max size, controlled by a LRU mechanism


== getting it

    sudo gem install rufus-lru

or at

http://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] :

    http://groups.google.com/group/rufus-ruby


== issue tracker

http://rubyforge.org/tracker/?atid=18584&group_id=4812&func=browse


== source

http://github.com/jmettraux/rufus-lru

    git clone git://github.com/jmettraux/rufus-lru.git


== author

John Mettraux, jmettraux@gmail.com 
http://jmettraux.wordpress.com


== the rest of Rufus

http://rufus.rubyforge.org


== license

MIT