Class: Cache
- Inherits:
-
Object
- Object
- Cache
- Defined in:
- bin/httphere
Overview
EventMachineMini.ssl_config = true
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #bytes ⇒ Object
- #delete(key) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(config = {}) ⇒ Cache
constructor
A new instance of Cache.
- #max_size ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Cache
Returns a new instance of Cache.
740 741 742 743 |
# File 'bin/httphere', line 740 def initialize(config={}) @config = config @cache = {} end |
Instance Method Details
#[](key) ⇒ Object
747 748 749 |
# File 'bin/httphere', line 747 def [](key) @cache[key] end |
#[]=(key, value) ⇒ Object
750 751 752 |
# File 'bin/httphere', line 750 def []=(key,value) @cache[key] = value end |
#bytes ⇒ Object
759 760 761 |
# File 'bin/httphere', line 759 def bytes @cache.values.inject(0) {|s,v| s+v[0][:size]} end |
#delete(key) ⇒ Object
756 757 758 |
# File 'bin/httphere', line 756 def delete(key) @cache.delete(key) end |
#has_key?(key) ⇒ Boolean
753 754 755 |
# File 'bin/httphere', line 753 def has_key?(key) @cache.has_key?(key) end |
#max_size ⇒ Object
744 745 746 |
# File 'bin/httphere', line 744 def max_size @config[:max_size] end |