Class: SolidCache::MaglevHash::Preferences
- Inherits:
-
Object
- Object
- SolidCache::MaglevHash::Preferences
- Defined in:
- lib/solid_cache/maglev_hash.rb
Instance Method Summary collapse
-
#initialize(offset, skip) ⇒ Preferences
constructor
A new instance of Preferences.
- #preferred_free_slot(lookup) ⇒ Object
Constructor Details
#initialize(offset, skip) ⇒ Preferences
Returns a new instance of Preferences.
59 60 61 62 |
# File 'lib/solid_cache/maglev_hash.rb', line 59 def initialize(offset, skip) @preferred_slots = TABLE_SIZE.times.map { |i| (offset + i * skip) % TABLE_SIZE } @rank = 0 end |
Instance Method Details
#preferred_free_slot(lookup) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/solid_cache/maglev_hash.rb', line 64 def preferred_free_slot(lookup) loop do slot = next_slot return slot if lookup[slot].nil? end end |