Class: CacheStoreContract

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

Overview

This class is used to define the contract that CacheStore implementations must adhere to.

Instance Method Summary collapse

Constructor Details

#initialize(namespace = '') ⇒ CacheStoreContract

Returns a new instance of CacheStoreContract.



7
8
9
# File 'lib/cache_store.rb', line 7

def initialize(namespace = '')
  @namespace = namespace
end

Instance Method Details

#exist?(key) ⇒ Boolean

This method is called to check if a value exists within this cache store for a specific key.

Parameters:

  • This (String)

    is the unique key to reference the value to check for within this cache store.

Returns:

  • (Boolean)


39
40
41
# File 'lib/cache_store.rb', line 39

def exist?(key)

end

#get(key, expires_in = 0, &block) ⇒ Object

This method is called to get a value from this cache store by it’s unique key.

Parameters:

  • This (String)

    is the unique key to reference the value to fetch from within this cache store.

  • This (Integer)

    is the number of seconds from the current time that this value should expire. (This is used in conjunction with the block to hydrate the cache key if it is empty.)

  • This (Block)

    block is provided to hydrate this cache store with the value for the request key when it is not found.



25
26
27
# File 'lib/cache_store.rb', line 25

def get(key, expires_in = 0, &block)

end

#remove(key) ⇒ Object

This method is called to remove a value from this cache store by it’s unique key.

Parameters:

  • This (String)

    is the unique key to reference the value to remove from this cache store.



32
33
34
# File 'lib/cache_store.rb', line 32

def remove(key)

end

#set(key, value, expires_in = 0) ⇒ Object

This method is called to set a value within this cache store by it’s key.

Parameters:

  • This (String)

    is the unique key to reference the value being set within this cache store.

  • This (Object)

    is the value to set within this cache store.

  • This (Integer)

    is the number of seconds from the current time that this value should expire.



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

def set(key, value, expires_in = 0)

end