Class: ShuntCache::Status

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/shunt_cache/status.rb

Constant Summary collapse

SHUNTED =
"shunted"
UNSHUNTED =
"ok"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



11
12
13
# File 'lib/shunt_cache/status.rb', line 11

def cache
  @cache
end

#keyObject

Returns the value of attribute key.



11
12
13
# File 'lib/shunt_cache/status.rb', line 11

def key
  @key
end

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/shunt_cache/status.rb', line 11

def logger
  @logger
end

Class Method Details

.configure {|instance| ... } ⇒ Object

Yields:

  • (instance)


16
17
18
# File 'lib/shunt_cache/status.rb', line 16

def self.configure
  yield instance
end

Instance Method Details

#clear!Object

reset to default



31
32
33
# File 'lib/shunt_cache/status.rb', line 31

def clear!
  cache.delete(key)
end

#shunt!Object



35
36
37
38
# File 'lib/shunt_cache/status.rb', line 35

def shunt!
  log(:info, "Shunting site with key: #{key}")
  cache.write(key, SHUNTED)
end

#shunted?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/shunt_cache/status.rb', line 26

def shunted?
  status == SHUNTED
end

#statusObject



20
21
22
23
24
# File 'lib/shunt_cache/status.rb', line 20

def status
  cache.fetch(key) do
    UNSHUNTED
  end
end

#unshunt!Object



40
41
42
43
# File 'lib/shunt_cache/status.rb', line 40

def unshunt!
  log(:info, "Unshunting site with key: #{key}")
  cache.write(key, UNSHUNTED)
end