Class: Moneta::Wrapper

Inherits:
Proxy
  • Object
show all
Defined in:
lib/moneta/wrapper.rb

Overview

Wraps the calls to the adapter

Direct Known Subclasses

Lock, Logger, OptionMerger, Pool, Shared

Instance Attribute Summary

Attributes inherited from Proxy

#adapter

Instance Method Summary collapse

Methods inherited from Proxy

features_mask, #initialize, not_supports

Methods included from Defaults

#[], #[]=, #decrement, #fetch, included, #supports?

Methods included from OptionSupport

#expires, #prefix, #raw, #with

Constructor Details

This class inherits a constructor from Moneta::Proxy

Instance Method Details

#clear(options = {}) ⇒ void

This method returns an undefined value.

Clear all keys in this store

Parameters:

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

36
37
38
# File 'lib/moneta/wrapper.rb', line 36

def clear(options = {})
  wrap(:clear, options) { super }
end

#closeObject

Explicitly close the store

Returns:

  • nil


41
42
43
# File 'lib/moneta/wrapper.rb', line 41

def close
  wrap(:close) { super }
end

#create(key, value, options = {}) ⇒ Boolean

Note:

Not every Moneta store implements this method, a NotImplementedError is raised if it is not supported.

Atomically sets a key to value if it's not set.

Parameters:

  • key (Object)
  • value (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :expires (Integer)

    Update expiration time (See Expires)

  • :raw (Boolean)

    Raw access without value transformation (See Transformer)

  • :prefix (String)

    Prefix key (See Transformer)

Returns:

  • (Boolean)

    key was set


31
32
33
# File 'lib/moneta/wrapper.rb', line 31

def create(key, value, options = {})
  wrap(:create, key, value, options) { super }
end

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

Delete the key from the store and return the current value

Parameters:

  • key (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :raw (Boolean)

    Raw access without value transformation (See Transformer)

  • :prefix (String)

    Prefix key (See Transformer)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • (Object)

    current value


21
22
23
# File 'lib/moneta/wrapper.rb', line 21

def delete(key, options = {})
  wrap(:delete, key, options) { super }
end

#each_keyEnumerator

Note:

Not every Moneta store implements this method, a NotImplementedError is raised if it is not supported.

Calls block once for each key in store, passing the key as a parameter. If no block is given, an enumerator is returned instead.

Returns:

  • (Enumerator)

    An all-the-keys enumerator


51
52
53
# File 'lib/moneta/wrapper.rb', line 51

def each_key
  wrap(:each_key) { super }
end

#featuresObject


46
47
48
# File 'lib/moneta/wrapper.rb', line 46

def features
  wrap(:features) { super }
end

#fetch_values(*keys, **options, &defaults) ⇒ Object


59
60
61
# File 'lib/moneta/wrapper.rb', line 59

def fetch_values(*keys, **options, &defaults)
  wrap(:fetch_values, keys, options, defaults) { super }
end

#increment(key, amount = 1, options = {}) ⇒ Object

Note:

Not every Moneta store implements this method, a NotImplementedError is raised if it is not supported.

Atomically increment integer value with key

This method also accepts negative amounts.

Parameters:

  • key (Object)
  • amount (Integer) (defaults to: 1)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :prefix (String)

    Prefix key (See Transformer)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • (Object)

    value from store


26
27
28
# File 'lib/moneta/wrapper.rb', line 26

def increment(key, amount = 1, options = {})
  wrap(:increment, key, amount, options) { super }
end

#key?(key, options = {}) ⇒ Boolean

Exists the value with key

Parameters:

  • key (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :expires (Integer)

    Update expiration time (See Expires)

  • :prefix (String)

    Prefix key (See Transformer)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • (Boolean)

6
7
8
# File 'lib/moneta/wrapper.rb', line 6

def key?(key, options = {})
  wrap(:key?, key, options) { super }
end

#load(key, options = {}) ⇒ Object

Fetch value with key. Return nil if the key doesn't exist

Parameters:

  • key (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :expires (Integer)

    Update expiration time (See Expires)

  • :raw (Boolean)

    Raw access without value transformation (See Transformer)

  • :prefix (String)

    Prefix key (See Transformer)

  • :sync (Boolean)

    Synchronized load (Cache reloads from adapter, Adapters::Daybreak syncs with file)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • (Object)

    value


11
12
13
# File 'lib/moneta/wrapper.rb', line 11

def load(key, options = {})
  wrap(:load, key, options) { super }
end

#merge!(pairs, options = {}) ⇒ Object


67
68
69
# File 'lib/moneta/wrapper.rb', line 67

def merge!(pairs, options = {})
  wrap(:merge!, pairs, options) { super }
end

#slice(*keys, **options) ⇒ Object


63
64
65
# File 'lib/moneta/wrapper.rb', line 63

def slice(*keys, **options)
  wrap(:slice, keys, options) { super }
end

#store(key, value, options = {}) ⇒ Object

Store value with key

Parameters:

  • key (Object)
  • value (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :expires (Integer)

    Set expiration time (See Expires)

  • :raw (Boolean)

    Raw access without value transformation (See Transformer)

  • :prefix (String)

    Prefix key (See Transformer)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • value


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

def store(key, value, options = {})
  wrap(:store, key, value, options) { super }
end

#values_at(*keys, **options) ⇒ Object


55
56
57
# File 'lib/moneta/wrapper.rb', line 55

def values_at(*keys, **options)
  wrap(:values_at, keys, options) { super }
end