| Class | LruHash |
| In: |
lib/rufus/lru.rb
|
| Parent: | Hash |
A Hash that has a max size. After the maxsize has been reached, the least recently used entries (LRU hence), will be discared to make room for the new entries.
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"}