Sha256: bf12d6c9412e006764d3e992f299a6d2a514275d4673f7f9e2fc975d0633ea61

Contents?: true

Size: 906 Bytes

Versions: 1

Compression:

Stored size: 906 Bytes

Contents

= 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"}


== mailing list

On the OpenWFEru-user for now : 

    http://groups.google.com/group/openwferu-users


== source

    http://rufus.rubyforge.org/svn/trunk/lru

    svn checkout http://rufus.rubyforge.org/svn/trunk/lru


== author

John Mettraux, jmettraux@gmail.com


== license

MIT

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rufus-lru-1.0 README.txt