FileDB is a filesystem DB that supports synchronous and asynchronous operations, API inspired by https://github.com/coreos/etcd and not recommended for production.
Add this line to your application's Gemfile:
gem 'file_db'
And then execute:
$ bundle
Or install it yourself as:
$ gem install file_db
By default all operations are asynchronous, for synchronous operations use the
option wait: true
, only three operations are supported get
set
and del
.
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')
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')
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)
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)
- Fork it ( https://github.com/[my-github-username]/file_db/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request