No commit activity in last 3 years
No release in over 3 years
Kyoto Cabinet provided DBM interface to efficient key value stores both in-memory and on-disk. This gem wraps Kyoto Cabinet's C API using FFI (foregin function interface) to support MRI, JRuby, and Rubinius.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.4
~> 10.4

Runtime

~> 1.9
 Project Readme

Gem Version Build Status

kyotocabinet-ffi

A FFI wrapper to the Kyoto Cabinet's C interface.

Currently it provides the PolymorphicDb with MemoryHash and FileHash subclasses.

requirements

  • Works on MRI (>= 1.9.2), JRuby (1.9 mode), and Rubinius.
  • No runtime dependencies (except ffi gem on MRI).

design

  • Supports polymorphic database with type-specific database classes for readability.
  • Database classes can be treated like a ruby Hash.
  • Common database calls (e.g. open, get, etc.) are provided in KyotoCabinet::Db.
  • Methods ending with ! can raise exceptions.
  • Implemented using FFI to support MRI, JRuby, and Rubinius.

usage

require 'kyotocabinet'

# polymorphic database (e.g. determined by file_path)
db = KyotoCabinet::Db::PolymorphicDb.new(KyotoCabinet::MEMORY_CACHE_TREE, :reader, :writer, :create)

# in-memory hash
db = KyotoCabinet::Db::MemoryHash.new(:reader, :writer, :create)

# on-disk hash
db = KyotoCabinet::Db::FileHash.new("db", :reader, :writer, :create)

begin
  # set key/value record; create is needed
  db['KyotoCabinet'] = 'FFI'
  
  # get value for key
  db['KyotoCabinet']
  # => FFI

  # record count
  db.size
  # => 1

  # clear all records
  db.clear
ensure
  # close database; raise SystemCallError on failure
  db.close! if db
end

license

MIT