An open API service indexing awesome lists of open source software.

https://github.com/mudge/helloredis

An incomplete Ruby FFI interface to hiredis for educational purposes.
https://github.com/mudge/helloredis

Last synced: 2 months ago
JSON representation

An incomplete Ruby FFI interface to hiredis for educational purposes.

Awesome Lists containing this project

README

          

This is an incomplete, experimental Ruby FFI interface to [Hiredis][0].

It exists mainly as a tool to teach me about [Ruby's FFI interface][1] and, as such,
the location of the `libhiredis` library is hard-coded into `hiredis.rb` as being
`/usr/local/lib`. If you want to tinker with this yourself, make sure to amend that
path as necessary.

Prerequisites
=============

* [Hiredis][0] 0.9.2 installed to `/usr/local/lib`.

Usage
=====

# With the project's lib directory on your load path...
require "helloredis"

redis = Helloredis.new # defaults to connecting to 127.0.0.1:6379
redis.set("foo", "bar")
# => "OK"
redis.get("foo")
# => "bar"
redis.lpush("mylist", "arnold")
# => 1
redis.lpush("mylist", "bob")
# => 2
redis.sort("mylist", :alpha => true, :order => :desc, :count => 1, :offset => 0)
# => ["bob"]

See `spec/helloredis_spec.rb` for more usage information.

[0]: https://github.com/antirez/hiredis
[1]: https://github.com/ffi/ffi