Class: Moneta::Adapters::DBM

Inherits:
Memory
  • Object
show all
Defined in:
lib/moneta/adapters/dbm.rb

Overview

DBM backend (Berkeley DB)

Instance Attribute Summary

Attributes included from HashAdapter

#backend

Instance Method Summary collapse

Methods inherited from Memory

#each_key

Methods included from CreateSupport

#create, included

Methods included from IncrementSupport

included, #increment

Methods included from HashAdapter

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

Methods included from Defaults

#[], #[]=, #create, #decrement, #each_key, #features, #fetch, #fetch_values, included, #increment, #key?, #merge!, #slice, #supports?, #values_at

Methods included from OptionSupport

#expires, #prefix, #raw, #with

Constructor Details

#initialize(options = {}) ⇒ DBM

Returns a new instance of DBM

Options Hash (options):

  • :file (String)

    Database file

  • :backend (::DBM)

    Use existing backend instance


11
12
13
14
15
16
17
# File 'lib/moneta/adapters/dbm.rb', line 11

def initialize(options = {})
  @backend = options[:backend] ||
    begin
      raise ArgumentError, 'Option :file is required' unless options[:file]
      ::DBM.new(options[:file])
    end
end

Instance Method Details

#closeObject

Explicitly close the store


20
21
22
23
# File 'lib/moneta/adapters/dbm.rb', line 20

def close
  @backend.close
  nil
end