Class: Moneta::Adapters::TDB

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

Overview

TDB backend

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) ⇒ TDB

Returns a new instance of TDB

Options Hash (options):

  • :file (String)

    Database file

  • :backend (::TDB)

    Use existing backend instance


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

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

Instance Method Details

#closeObject

Explicitly close the store


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

def close
  @backend.close
  nil
end