Class: MemCache

Inherits:
Object
  • Object
show all
Defined in:
lib/cachy/memcache_timeout_protection.rb

Overview

class should exist at this point

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.read_error_callbackObject

Returns the value of attribute read_error_callback.



15
16
17
# File 'lib/cachy/memcache_timeout_protection.rb', line 15

def read_error_callback
  @read_error_callback
end

Instance Attribute Details

#read_error_occurredObject

Returns the value of attribute read_error_occurred.



17
18
19
# File 'lib/cachy/memcache_timeout_protection.rb', line 17

def read_error_occurred
  @read_error_occurred
end

Instance Method Details

#cache_get_with_timeout_protection(*args) ⇒ Object Also known as: cache_get



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cachy/memcache_timeout_protection.rb', line 19

def cache_get_with_timeout_protection(*args)
  begin
    @read_error_occurred = false
    cache_get_without_timeout_protection(*args)
  rescue Exception => error
    @read_error_occurred = true
    if error.to_s == 'IO timeout' and self.class.read_error_callback
      self.class.read_error_callback.call error
    else
      raise error
    end
  end
end