Class: OpenURI::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/openuri/common.rb,
lib/openuri/memcached.rb,
lib/openuri/rails-cache.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.expiryObject

How long your caches will be kept for (in seconds)



81
82
83
# File 'lib/openuri/common.rb', line 81

def expiry
  @expiry ||= 60 * 10
end

.hostObject



85
86
87
# File 'lib/openuri/common.rb', line 85

def host
  @host ||= "127.0.0.1:11211"
end

Class Method Details

.disable!Object

Disable caching - all queries will be run directly using the standard OpenURI ‘open` method.



64
65
66
# File 'lib/openuri/common.rb', line 64

def disable!
  @cache_enabled = false
end

.disabled?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/openuri/common.rb', line 68

def disabled?
  !@cache_enabled
end

.enable!Object

Enable caching



58
59
60
# File 'lib/openuri/common.rb', line 58

def enable!
  raise NotImplementedError
end

.enabled?Boolean

Is the cache enabled?

Returns:

  • (Boolean)


53
54
55
# File 'lib/openuri/common.rb', line 53

def enabled?
  @cache_enabled
end

.get(key) ⇒ Object

Raises:

  • (NotImplementedError)


72
73
74
# File 'lib/openuri/common.rb', line 72

def get(key)
  raise NotImplementedError
end

.set(key, value) ⇒ Object

Raises:

  • (NotImplementedError)


76
77
78
# File 'lib/openuri/common.rb', line 76

def set(key, value)
  raise NotImplementedError
end