Class: CacheStoreContract

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

Overview

Defines the contract that CacheStore implementations must adhere to.

Instance Method Summary collapse

Constructor Details

#initialize(namespace = '') ⇒ CacheStoreContract

Returns a new instance of CacheStoreContract.



9
10
# File 'lib/cache_store.rb', line 9

def initialize(namespace = '')
end

Instance Method Details

#exist?(key) ⇒ Boolean

Checks 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)


37
38
# File 'lib/cache_store.rb', line 37

def exist?(key)
end

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

Gets a value from this cache store by its 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
# File 'lib/cache_store.rb', line 25

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

#remove(key) ⇒ Object

Removes a value from this cache store by its unique key.

Parameters:

  • This (String)

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



31
32
# File 'lib/cache_store.rb', line 31

def remove(key)
end

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

Sets a value within this cache store by its 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.



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

def set(key, value, expires_in = 0)
end