Class: Regentanz::Cache::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/regentanz/cache/base.rb

Direct Known Subclasses

File

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.lint(instance_or_class) ⇒ Object

Checks if instance_or_class complies to cache backend duck type, ie. if it reponds to all mandatory methods



9
10
11
12
13
14
# File 'lib/regentanz/cache/base.rb', line 9

def self.lint(instance_or_class)
  instance = instance_or_class.is_a?(Class) ? instance_or_class.new : instance_or_class
  [:set, :get, :available?, :expire!, :valid?].inject(true) do |memo, method|
    memo && instance.respond_to?(method)
  end
end

.sanitize_key(key) ⇒ Object

Returns a alpha-numeric cache key



17
18
19
# File 'lib/regentanz/cache/base.rb', line 17

def self.sanitize_key(key)
  Digest::SHA1.hexdigest(key.to_s)
end

Instance Method Details

#available?(key) ⇒ Boolean

Checks if cache under key is available.

Returns:

  • (Boolean)


28
# File 'lib/regentanz/cache/base.rb', line 28

def available?(key); end

#expire!(key) ⇒ Object

Deletes cache under key.



31
# File 'lib/regentanz/cache/base.rb', line 31

def expire!(key); end

#get(key) ⇒ Object

Retrieves cached value from key.



25
# File 'lib/regentanz/cache/base.rb', line 25

def get(key); end

#set(key, value) ⇒ Object

Stores cache value as key.



22
# File 'lib/regentanz/cache/base.rb', line 22

def set(key, value); end

#set_retry_state!Object

Persists a timeout state



45
# File 'lib/regentanz/cache/base.rb', line 45

def set_retry_state!; end

#unset_retry_state!Object

Checks if we’ve waited enough. Unsets a possible retry state (and returns true) if so or returns false if not



42
# File 'lib/regentanz/cache/base.rb', line 42

def unset_retry_state!; end

#valid?(key) ⇒ Boolean

Checks if cache under key is still valid.

Returns:

  • (Boolean)


34
# File 'lib/regentanz/cache/base.rb', line 34

def valid?(key); end

#waiting_for_retry?Boolean

Returns whether or not weather retrieval from the API is currently waiting for a timeout to expire

Returns:

  • (Boolean)


38
# File 'lib/regentanz/cache/base.rb', line 38

def waiting_for_retry?; end