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.
57 58 59 60 |
# File 'lib/solid_cache/maglev_hash.rb', line 57 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
62 63 64 65 66 67 |
# File 'lib/solid_cache/maglev_hash.rb', line 62 def preferred_free_slot(lookup) loop do slot = next_slot return slot if lookup[slot].nil? end end |