Class: CacheLib::UtilHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/cache_lib/util_hash.rb

Instance Method Summary collapse

Instance Method Details

#head_keyObject



3
4
5
# File 'lib/cache_lib/util_hash.rb', line 3

def head_key
  keys.last
end

#pop_tailObject



20
21
22
# File 'lib/cache_lib/util_hash.rb', line 20

def pop_tail
  delete(first[0])
end

#refresh(key) ⇒ Object



24
25
26
27
# File 'lib/cache_lib/util_hash.rb', line 24

def refresh(key)
  value = delete(key)
  self[key] = value
end

#set_head(key, value) ⇒ Object



11
12
13
14
# File 'lib/cache_lib/util_hash.rb', line 11

def set_head(key, value)
  delete(key)
  self[key] = value
end

#set_tail(key, value) ⇒ Object



16
17
18
# File 'lib/cache_lib/util_hash.rb', line 16

def set_tail(key, value)
  replace(Hash[key, value].merge(self))
end

#tailObject



7
8
9
# File 'lib/cache_lib/util_hash.rb', line 7

def tail
  first
end