Class: Merb::Cache::AbstractStore Abstract

Inherits:
Object
  • Object
show all
Defined in:
merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb

Overview

This class is abstract.

Subclass and override all methods.

Direct Known Subclasses

AbstractStrategyStore, FileStore, MemcachedStore

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ AbstractStore

Returns a new instance of AbstractStore



4
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 4

def initialize(config = {}); end

Instance Method Details

#delete(key, parameters = {}) ⇒ Object

Deletes the entry for the key & parameter from the store.

Parameters:

  • key (#to_s)

    the key used to identify an entry

  • parameters (Hash) (defaults to: {})

    optional parameters used to identify an entry

Raises:

  • (Boolean)

    true if the an entry matching the key and parameters is successfully deleted, false otherwise

  • (NotImplementedError)

    API method has not been implemented



79
80
81
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 79

def delete(key, parameters = {})
  raise NotImplementedError
end

#delete_allBoolean

deletes all entries for the key & parameters for the store.

Returns:

  • (Boolean)

    true if all entries in the store are erased, false otherwise

Raises:

  • (NotImplementedError)

    API method has not been implemented



87
88
89
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 87

def delete_all
  raise NotImplementedError
end

#delete_all!Boolean

Dangerous version of delete_all. Used by strategy stores, which may delete entries not associated with the strategy store making the call.

Returns:

  • (Boolean)

    true if all entries in the store are erased, false otherwise

Raises:

  • (NotImplementedError)

    API method has not been implemented



97
98
99
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 97

def delete_all!
  delete_all
end

#exists?(key, parameters = {}) ⇒ Boolean

Returns true/false/nil based on if data identified by the key & parameters is persisted in the store.

Parameters:

  • key (#to_s)

    the key used to identify an entry

  • parameters (Hash) (defaults to: {})

    optional parameters used to identify an entry

Returns:

  • (Boolean)

    true if the key and parameters match an entry in the store, false otherwise

Raises:

  • (NotImplementedError)

    API method has not been implemented



69
70
71
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 69

def exists?(key, parameters = {})
  raise NotImplementedError
end

#fetch(key, parameters = {}, conditions = {}, &blk) ⇒ Object, NilClass

Tries to read the data from the store. If that fails, it calls the block parameter and persists the result.

Parameters:

  • key (#to_s)

    the key used to identify an entry

  • parameters (Hash) (defaults to: {})

    optional parameters used to identify an entry

  • conditions (Hash) (defaults to: {})

    optional conditions that place constraints or detail instructions for storing an entry

Returns:

  • (Object, NilClass)

    the match entry or the result of the block call, or nil if the entry is not successfully written

Raises:

  • (NotImplementedError)

    API method has not been implemented



58
59
60
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 58

def fetch(key, parameters = {}, conditions = {}, &blk)
  raise NotImplementedError
end

#read(key, parameters = {}) ⇒ Object, NilClass

Gets the data from the store identified by the key & parameters.

Parameters:

  • key (#to_s)

    the key used to identify an entry

  • parameters (Hash) (defaults to: {})

    optional parameters used to identify an entry

Returns:

  • (Object, NilClass)

    the match entry, or nil if no entry exists matching the key and parameters

Raises:

  • (NotImplementedError)

    API method has not been implemented



24
25
26
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 24

def read(key, parameters = {})
  raise NotImplementedError
end

#writable?(key, parameters = {}, conditions = {}) ⇒ TrueClass

Determines if the store is able to persist data identified by the key & parameters with the given conditions.

Parameters:

  • key (#to_s)

    the key used to identify an entry

  • parameters (Hash) (defaults to: {})

    optional parameters used to identify an entry

  • conditions (Hash) (defaults to: {})

    optional conditions that place constraints or detail instructions for storing an entry

Returns:

  • (TrueClass)

    the ability of the store to write an entry based on the key, parameters, and conditions

Raises:

  • (NotImplementedError)

    API method has not been implemented



14
15
16
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 14

def writable?(key, parameters = {}, conditions = {})
  raise NotImplementedError
end

#write(key, data = nil, parameters = {}, conditions = {}) ⇒ TrueClass, NilClass

Persists the data so that it can be retrieved by the key & parameters.

Parameters:

  • key (#to_s)

    the key used to identify an entry

  • data (defaults to: nil)

    the object to persist as an entry

  • parameters (Hash) (defaults to: {})

    optional parameters used to identify an entry

  • conditions (Hash) (defaults to: {})

    optional conditions that place constraints or detail instructions for storing an entry

Returns:

  • (TrueClass, NilClass)

    true if the entry was successfully written, otherwise nil

Raises:

  • (NotImplementedError)

    API method has not been implemented



36
37
38
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 36

def write(key, data = nil, parameters = {}, conditions = {})
  raise NotImplementedError
end

#write_all(key, data = nil, parameters = {}, conditions = {}) ⇒ TrueClass, NilClass

Returns true if the entry was successfully written, otherwise nil

Parameters:

  • key (#to_s)

    the key used to identify an entry

  • data (defaults to: nil)

    the object to persist as an entry

  • parameters (Hash) (defaults to: {})

    optional parameters used to identify an entry

  • conditions (Hash) (defaults to: {})

    optional conditions that place constraints or detail instructions for storing an entry

Returns:

  • (TrueClass, NilClass)

    true if the entry was successfully written, otherwise nil

Raises:

  • (NotImplementedError)

    API method has not been implemented



46
47
48
# File 'merb-cache/lib/merb-cache/stores/fundamental/abstract_store.rb', line 46

def write_all(key, data = nil, parameters = {}, conditions = {})
  write(key, data, parameters, conditions)
end