Class: Arachni::Cache::LeastRecentlyUsed
- Defined in:
- lib/arachni/cache/least_recently_used.rb
Overview
Least Recently Used cache implementation.
Generally the most desired mode under normal circumstances, although it does not satisfy low-latency requirements due to the overhead of maintaining entry ages.
Discards the least recently used entries in order to make room for new ones.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #[](k) ⇒ Object
- #clear ⇒ Object
- #delete(k) ⇒ Object
-
#initialize ⇒ LeastRecentlyUsed
constructor
A new instance of LeastRecentlyUsed.
- #store(k, v) ⇒ Object
Methods inherited from Base
#[]=, #any?, #capped?, #empty?, #fetch_or_store, #include?, #size, #uncap, #uncapped?
Constructor Details
#initialize ⇒ LeastRecentlyUsed
Returns a new instance of LeastRecentlyUsed.
30 31 32 33 |
# File 'lib/arachni/cache/least_recently_used.rb', line 30 def initialize( * ) super @lru = [] end |
Instance Method Details
#[](k) ⇒ Object
43 44 45 46 47 |
# File 'lib/arachni/cache/least_recently_used.rb', line 43 def []( k ) super( k ) ensure renew( k ) end |
#clear ⇒ Object
57 58 59 60 61 |
# File 'lib/arachni/cache/least_recently_used.rb', line 57 def clear super ensure @lru.clear end |
#delete(k) ⇒ Object
50 51 52 53 54 |
# File 'lib/arachni/cache/least_recently_used.rb', line 50 def delete( k ) super( k ) ensure @lru.delete( k ) end |
#store(k, v) ⇒ Object
36 37 38 39 40 |
# File 'lib/arachni/cache/least_recently_used.rb', line 36 def store( k, v ) super( k, v ) ensure renew( k ) end |