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.
- Host: GitHub
- URL: https://github.com/mudge/helloredis
- Owner: mudge
- Created: 2011-02-19T22:59:38.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2011-02-22T21:49:51.000Z (over 15 years ago)
- Last Synced: 2026-04-19T12:37:55.360Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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