Class: HTTP::Headers::Normalizer::Cache
- Inherits:
-
Object
- Object
- HTTP::Headers::Normalizer::Cache
- Defined in:
- lib/http/headers/normalizer.rb
Overview
Normalized header names cache
Constant Summary collapse
- MAX_SIZE =
200
Instance Method Summary collapse
- #get(key) ⇒ Object (also: #[])
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #set(key, value) ⇒ Object (also: #[]=)
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
20 21 22 |
# File 'lib/http/headers/normalizer.rb', line 20 def initialize @store = {} end |
Instance Method Details
#get(key) ⇒ Object Also known as: []
24 25 26 |
# File 'lib/http/headers/normalizer.rb', line 24 def get(key) @store[key] end |
#set(key, value) ⇒ Object Also known as: []=
29 30 31 32 33 34 |
# File 'lib/http/headers/normalizer.rb', line 29 def set(key, value) # Maintain cache size @store.delete(@store.each_key.first) while MAX_SIZE <= @store.size @store[key] = value end |