Class: Arachni::Support::Cache::RandomReplacement
- Defined in:
- lib/arachni/support/cache/random_replacement.rb
Overview
Random Replacement cache implementation.
Discards entries at random in order to make room for new ones.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize ⇒ RandomReplacement
constructor
A new instance of RandomReplacement.
- #store(k, v) ⇒ Object
Methods inherited from Base
#==, #[], #[]=, #any?, #capped?, #delete, #dup, #empty?, #fetch_or_store, #hash, #include?, #size, #uncap, #uncapped?
Constructor Details
#initialize ⇒ RandomReplacement
Returns a new instance of RandomReplacement.
20 21 22 23 |
# File 'lib/arachni/support/cache/random_replacement.rb', line 20 def initialize( * ) super @keys = [] end |
Instance Method Details
#clear ⇒ Object
34 35 36 37 |
# File 'lib/arachni/support/cache/random_replacement.rb', line 34 def clear super @keys.clear end |
#store(k, v) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/arachni/support/cache/random_replacement.rb', line 26 def store( k, v ) already_in = include?( k ) super( k, v ) ensure @keys << k if !already_in end |