Class: Moneta::Adapters::Memory

Inherits:
Object
  • Object
show all
Includes:
CreateSupport, Defaults, HashAdapter, IncrementSupport
Defined in:
lib/moneta/adapters/memory.rb

Overview

Memory backend using a hash to store the entries

Direct Known Subclasses

Cookie, DBM, Daybreak, GDBM, KyotoCabinet, LevelDB, SDBM, TDB, TokyoCabinet

Instance Attribute Summary

Attributes included from HashAdapter

#backend

Instance Method Summary collapse

Methods included from CreateSupport

#create, included

Methods included from IncrementSupport

included, #increment

Methods included from HashAdapter

#clear, #delete, #each_key, included, #key?, #load, #store

Methods included from Defaults

#[], #[]=, #close, #create, #decrement, #each_key, #features, #fetch, included, #increment, #key?, #supports?

Methods included from OptionSupport

#expires, #prefix, #raw, #with

Constructor Details

#initialize(options = {}) ⇒ Memory

Returns a new instance of Memory

Parameters:

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

    Options hash

Options Hash (options):

  • :backend (Hash)

    Use existing backend instance


13
14
15
# File 'lib/moneta/adapters/memory.rb', line 13

def initialize(options = {})
  @backend = options[:backend] || {}
end

Instance Method Details

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


21
22
23
24
# File 'lib/moneta/adapters/memory.rb', line 21

def fetch_values(*keys, **options, &defaults)
  defaults ||= {} # prevents KeyError
  @backend.fetch_values(*keys, &defaults)
end

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


34
35
36
37
# File 'lib/moneta/adapters/memory.rb', line 34

def merge!(pairs, options={}, &block)
  @backend.merge!(Hash[pairs], &block)
  self
end

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


29
30
31
# File 'lib/moneta/adapters/memory.rb', line 29

def slice(*keys, **options)
  @backend.slice(*keys)
end

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


17
18
19
# File 'lib/moneta/adapters/memory.rb', line 17

def values_at(*keys, **options)
  @backend.values_at(*keys)
end