Hash Cabinet - File based key-object store

Gem Version Build Status Maintainability


Hash Cabinet is a file-based, key-object store with hash-like access.

Highlights

  • Tiny library, based on Ruby's built in SDBM.
  • Stores simple values or complex objects through transparent YAML serialization.
  • Easy hash-like access: cabinet['key'] = 'value'.
  • Mirrors most of the native SDBM methods.

Installation

$ gem install hash_cabinet

Usage

require 'hash_cabinet'

cabinet = HashCabinet.new 'dbfile'

# Store values
cabinet['some-key'] = 'some-value'
cabinet['another-key'] = { color: 'yellow' }

# Retrieve values
p cabinet['another-key']
#=> {:color=>"yellow"}

# Show all values
p cabinet.to_h
#=> {"some-key"=>"some=value", "another-key"=>{:color=>"yellow"}}

Documentation