ssdb-rb
A Ruby client library for SSDB, heaviliy inspired by the great redis-rb library. Requires SSDB version 1.4.2 or higher.
Installation
Install via rubygems:
gem install ssdb
Use it with bundler, by adding the following line to your Gemfile:
gem "ssdb"
For more information please visit http://gembundler.com/.
Basic usage
Connect to SSDB, assuming it is listening on localhost
, port 8888.
require "ssdb"
ssdb = SSDB.new
To connect to a custom server, please provide a custom :url
option:
ssdb = SSDB.new url: "ssdb://1.2.3.4:8889"
To execute commands:
ssdb.set("mykey", "hello world")
# => true
ssdb.get("mykey")
# => "hello world"
Full documentation of all commands is available on rdoc.info.
Batching/pipelining
Multiple commands can be executed as a batch operations. Instead of sending commands one-by-one the client is able to send a batch of commands and retrieve all responses as a single socket message exchange cycle.
Example:
ssdb.batch do
ssdb.set "foo", "5"
ssdb.get "foo"
ssdb.incr "foo"
end
# => [true, "5", 6]
Futures
Results of individual batch operations are stored as futures. Future values
can be retrieved via the #value
method once the batch execution is complete.
ssdb.batch do
v = ssdb.set "foo", "bar"
w = ssdb.incr "baz"
end
v.value
# => true
w.value
# => 1
TODO
- Implement HASH operations
- Complete EVAL(SHA) support
Licence (MIT)
Copyright (c) 2013 Black Square Media Ltd
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.