Class: MiniMime::Db::Cache
- Inherits:
-
Object
- Object
- MiniMime::Db::Cache
- Defined in:
- lib/mini_mime.rb
Instance Method Summary collapse
- #[]=(key, val) ⇒ Object
- #fetch(key, &blk) ⇒ Object
-
#initialize(size) ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize(size) ⇒ Cache
Returns a new instance of Cache.
72 73 74 75 |
# File 'lib/mini_mime.rb', line 72 def initialize(size) @size = size @hash = {} end |
Instance Method Details
#[]=(key, val) ⇒ Object
77 78 79 80 81 |
# File 'lib/mini_mime.rb', line 77 def []=(key, val) rval = @hash[key] = val @hash.shift if @hash.length > @size rval end |
#fetch(key, &blk) ⇒ Object
83 84 85 |
# File 'lib/mini_mime.rb', line 83 def fetch(key, &blk) @hash.fetch(key, &blk) end |