Skip to content

mynameisrufus/file_db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileDb

FileDB is a filesystem DB that supports synchronous and asynchronous operations, API inspired by https://github.com/coreos/etcd and not recommended for production.

Installation

Add this line to your application's Gemfile:

gem 'file_db'

And then execute:

$ bundle

Or install it yourself as:

$ gem install file_db

Usage

By default all operations are asynchronous, for synchronous operations use the option wait: true, only three operations are supported get set and del.

Reads and writes

Asynchronous write, synchronous read:

FileDB.set(key: 'foo1', value: 'bar')
FileDb.get(key: 'foo1', wait: true)

This will raise FileDB::NotFound error because of the 100ms update lag:

FileDB.set(key: 'foo1', value: 'bar')
FileDb.get(key: 'foo1')

Namespaces

You will need to provide the namespace argument to subsequent calls to get, set and del for this node:

FileDB.set(key: 'foo1', value: 'bar', namespace: 'fubar')

Compare and swap

This following will raise a FileDB::CompareAndSwap error:

state = FileDB.set(key: 'foo1', value: 'bar', wait: true)
FileDB.set(key: 'foo1', value: 'bar', wait: true)
FileDB.set(key: 'foo1', value: 'bar', wait: true, prev_node: state.node)

Compare and delete

This following will raise a FileDB::CompareAndDelete error:

state = FileDB.set(key: 'foo1', value: 'bar', wait: true)
FileDB.set(key: 'foo1', value: 'bar', wait: true)
FileDB.del(key: 'foo1', wait: true, prev_node: state.node)

Contributing

  1. Fork it ( https://github.com/[my-github-username]/file_db/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Ruby file database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages