- Notifications
You must be signed in to change notification settings - Fork10
Ruby wrapper for Spotify's Sparkey
License
NotificationsYou must be signed in to change notification settings
emnl/gnista
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Gnista is a wrapper for the database/hashstoreSparkey written for Ruby. Gnista packs all the native features of Sparkey into a shiny red package, easy to use.
You will need Sparkey, obviously. It's really easy to install. Head over tohttp://github.com/spotify/sparkey and install it, I'll wait..
Now, add this line to your application's Gemfile:
gem 'gnista'
And then execute:
$ bundle
Or install it yourself as:
$ gem install gnista
You can read about Sparkeyhere.
require'gnista'logwriter=Gnista::Logwriter.new"mylog.log"# no compressionlogwriter=Gnista::Logwriter.new"mylog.log",4000# 4k compression block sizelogwriter=Gnista::Logwriter.new"mylog.log",:append# append to existing loglogwriter.logpath# => "mylog.log"logwriter.put"key","value"# put entrylogwriter["key"]="value"logwriter.del"key"# delete entrylogwriter.flushlogwriter.write_batchdologwriter["key1"]="value1"logwriter["key2"]="value2"endlogreader=Gnista::Logreader.new"mylog.log"logreader.logpath# => "mylog.log"logreader.each{|key,value,type|putskey,value,type}# => "key", "value"/nil, :put/:deletelogreader.maxkeylen# largest key lengthlogreader.maxkeylen# largest value lengthGnista::Hash.write"mylog.hash","mylog.log"# no preferred hash sizeGnista::Hash.write"mylog.hash","mylog.log",4# 32 bit murmurhash3_x86_32Gnista::Hash.write"mylog.hash","mylog.log",8# lower 64-bit part of murmurhash3_x64_128hash=Gnista::Hash.new"mylog.hash","mylog.log"logwriter.hashpath# => "mylog.hash"logwriter.logpath# => "mylog.log"hash.each{|key,value|putskey,value}hash.get"key"# => "value" or nilhash["key"]hash.maxkeylenhash.maxkeylenhash.lengthhash.collisionshash.empty?hash.include?"key"hash.keys# => ["key1", "key2"]hash.values# => ["value1", "value2"]# Don't forget to close!logwriter.closelogreader.closehash.closelogwriter.open? ||logreader.open? ||hash.open?# => false
BothLogreader
andHash
mixinEnumerable.
Step-by-step:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Write some code
- Build and test
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Use the following commands to build the native extensions and test:
$ rake make$ rake test
About
Ruby wrapper for Spotify's Sparkey
Resources
License
Stars
Watchers
Forks
Packages0
No packages published