Class: Moneta::Adapters::GDBM

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

Overview

GDBM backend

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, #key?, #load, #store

Methods included from Defaults

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

Methods included from OptionSupport

#expires, #prefix, #raw, #with

Constructor Details

#initialize(options = {}) ⇒ GDBM

Returns a new instance of GDBM.

Parameters:

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

Options Hash (options):

  • :file (String)

    Database file

  • :backend (::GDBM)

    Use existing backend instance



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

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

Instance Method Details

#closeObject

Explicitly close the store

Returns:

  • nil



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

def close
  @backend.close
  nil
end