Karma
Karma is a key-value key-counter database, you can find it in a separate repository. This repo contains straightforward Ruby client for Karma.
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add karma
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install karma
Configuration
require 'karma'
Karma.configure do |config|
config.port = 8080
config.host = "localhost"
end
Usage
The client supports all possible functionality, which means that Karma can be fully managed by commands. Each command returns an execution status in the success
attribute and an execution result or an error in the result
attribute. For example:
Karma.drop('comments')
The control commands allow you to maintain the database:
Karma.ping
Karma.create('comments')
Karma.trees
Karma.drop('comments')
Karma.dumps
Karma.dump('comments')
Karma.dump_all
Karma.load('1688496993_comments.tree')
The tree commands allow you to work with specific tree:
Karma.tree('comments').increment(key: 12345)
Karma.tree('comments').decrement(key: 12345)
Karma.tree('comments').sum(key: 12345)
Karma.tree('comments').sum(key: 12345, time_from: 20230601, time_to: 20230629)
Karma.tree('comments').find(key: 12345, time_from: 20230601, time_to: 20230629)
Karma.tree('comments').find(time_from: 20230601, time_to: 20230629)
Karma.tree('comments').delete(key: 12345, time_from: 20230601, time_to: 20230629)
Karma.tree('comments').delete(time_from: 20230601, time_to: 20230629)
Karma.tree('comments').reset(key: 12345)
Karma.tree('comments').reset
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/creadone/karmarb.
License
The gem is available as open source under the terms of the MIT License.