Class: Cache

Inherits:
Object
  • Object
show all
Defined in:
bin/httphere

Overview

Instance Method Summary collapse

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

#bytesObject



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

Returns:

  • (Boolean)


753
754
755
# File 'bin/httphere', line 753

def has_key?(key)
  @cache.has_key?(key)
end

#max_sizeObject



744
745
746
# File 'bin/httphere', line 744

def max_size
  @config[:max_size]
end