https://github.com/redis/hiredis-rb
Ruby wrapper for hiredis
https://github.com/redis/hiredis-rb
Keywords from Contributors
activerecord mvc activejob rack marshaller rubygems crash-reporting background-jobs json-parser jobs
Last synced: about 12 hours ago
JSON representation
Repository metadata
Ruby wrapper for hiredis
- Host: GitHub
- URL: https://github.com/redis/hiredis-rb
- Owner: redis
- License: bsd-3-clause
- Created: 2010-09-21T12:42:08.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2024-07-01T10:04:36.000Z (over 1 year ago)
- Last Synced: 2025-12-05T11:18:30.624Z (7 days ago)
- Language: Ruby
- Homepage:
- Size: 217 KB
- Stars: 321
- Watchers: 16
- Forks: 86
- Open Issues: 20
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: COPYING
README.md
hiredis-rb
Ruby extension that wraps hiredis. Both
the synchronous connection API and a separate protocol reader are supported.
It is primarily intended to speed up parsing multi bulk replies.
Install
Install with Rubygems:
gem install hiredis
Usage
Hiredis can be used as standalone library, or be used together with redis-rb.
The latter adds in support for hiredis in 2.2.
redis-rb
To use hiredis from redis-rb, it needs to be available in Ruby's load path.
Using Bundler, this comes down to adding the following lines:
gem "hiredis", "~> 0.6.0"
gem "redis", ">= 3.2.0"
To use hiredis with redis-rb, you need to require redis/connection/hiredis
before creating a new connection. This makes sure that hiredis will be used
instead of the pure Ruby connection code and protocol parser. Doing so in the
Gemfile is done by adding a :require option to the line adding the redis-rb
dependency:
gem "redis", ">= 3.2.0", :require => ["redis", "redis/connection/hiredis"]
You can use Redis normally, as you would with the pure Ruby version.
Standalone: Connection
A connection to Redis can be opened by creating an instance of
Hiredis::Connection and calling #connect:
conn = Hiredis::Connection.new
conn.connect("127.0.0.1", 6379)
Commands can be written to Redis by calling #write with an array of
arguments. You can call write more than once, resulting in a pipeline of
commands.
conn.write ["SET", "speed", "awesome"]
conn.write ["GET", "speed"]
After commands are written, use #read to receive the subsequent replies.
Make sure not to call #read more than you have replies to read, or
the connection will block indefinitely. You can use this feature
to implement a subscriber (for Redis Pub/Sub).
>> conn.read
=> "OK"
>> conn.read
=> "awesome"
When the connection was closed by the server, an error of the type
Hiredis::Connection::EOFError will be raised. For all I/O related errors,
the Ruby built-in Errno::XYZ errors will be raised. All other errors
(such as a protocol error) result in a RuntimeError.
You can skip loading everything and just load Hiredis::Connection by
requiring hiredis/connection.
Standalone: Reply parser
Only using hiredis for the reply parser can be very useful in scenarios
where the I/O is already handled by another component (such as EventMachine).
You can skip loading everything and just load Hiredis::Reader by requiring
hiredis/reader.
Use #feed on an instance of Hiredis::Reader to feed the stream parser with
new data. Use #read to get the parsed replies one by one:
>> reader = Hiredis::Reader.new
>> reader.feed("*2\r\n$7\r\nawesome\r\n$5\r\narray\r\n")
>> reader.gets
=> ["awesome", "array"]
Benchmarks
These numbers were generated by running benchmark/throughput.rb against
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]. The
benchmark compares redis-rb with the Ruby connection and protocol code against
redis-rb with hiredis to handle I/O and reply parsing.
For simple line or bulk replies, the throughput improvement is insignificant,
while the larger multi bulk responses will have a noticeable higher throughput.
user system total real
redis-rb: 1x SET pipeline, 10000 times 0.260000 0.140000 0.400000 ( 0.726216)
hiredis: 1x SET pipeline, 10000 times 0.170000 0.130000 0.300000 ( 0.602332)
redis-rb: 10x SET pipeline, 10000 times 1.550000 0.660000 2.210000 ( 2.231505)
hiredis: 10x SET pipeline, 10000 times 0.400000 0.140000 0.540000 ( 0.995266)
redis-rb: 1x GET pipeline, 10000 times 0.270000 0.150000 0.420000 ( 0.730322)
hiredis: 1x GET pipeline, 10000 times 0.170000 0.130000 0.300000 ( 0.604060)
redis-rb: 10x GET pipeline, 10000 times 1.480000 0.640000 2.120000 ( 2.122215)
hiredis: 10x GET pipeline, 10000 times 0.380000 0.130000 0.510000 ( 0.925731)
redis-rb: 1x LPUSH pipeline, 10000 times 0.260000 0.150000 0.410000 ( 0.725292)
hiredis: 1x LPUSH pipeline, 10000 times 0.160000 0.130000 0.290000 ( 0.592466)
redis-rb: 10x LPUSH pipeline, 10000 times 1.540000 0.660000 2.200000 ( 2.202709)
hiredis: 10x LPUSH pipeline, 10000 times 0.360000 0.130000 0.490000 ( 0.940361)
redis-rb: 1x LRANGE(100) pipeline, 1000 times 0.240000 0.020000 0.260000 ( 0.307504)
hiredis: 1x LRANGE(100) pipeline, 1000 times 0.050000 0.020000 0.070000 ( 0.100293)
redis-rb: 1x LRANGE(1000) pipeline, 1000 times 2.100000 0.030000 2.130000 ( 2.353551)
hiredis: 1x LRANGE(1000) pipeline, 1000 times 0.320000 0.030000 0.350000 ( 0.472789)
License
This code is released under the BSD license, after the license of hiredis.
Owner metadata
- Name: Redis
- Login: redis
- Email: redis@redis.io
- Kind: organization
- Description:
- Website: https://redis.io
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/1529926?v=4
- Repositories: 63
- Last ynced at: 2025-10-30T00:35:00.620Z
- Profile URL: https://github.com/redis
GitHub Events
Total
- Issues event: 1
- Watch event: 1
- Issue comment event: 6
- Fork event: 1
Last Year
- Issues event: 1
- Watch event: 1
- Issue comment event: 6
- Fork event: 1
Committers metadata
Last synced: 7 days ago
Total Commits: 246
Total Committers: 22
Avg Commits per committer: 11.182
Development Distribution Score (DDS): 0.187
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Pieter Noordhuis | p****s@g****m | 200 |
| Jan-Erik Rediger | j****k@f****e | 14 |
| Maxime Bedard | m****d@s****m | 3 |
| Michel Martens | m****l@s****m | 3 |
| Olle Jonsson | o****n@g****m | 3 |
| Stan Hu | s****u@g****m | 3 |
| Chayim I. Kirshen | c@k****m | 2 |
| Mathieu Jobin | m****n | 2 |
| Rafael Mendonça França | r****a@g****m | 2 |
| Rafał Michalski | r****5@g****m | 2 |
| Chulki Lee | c****e@g****m | 1 |
| Dirkjan Bussink | d****k@g****m | 1 |
| Martyn Loughran | me@m****m | 1 |
| Omer Katz | o****w@g****m | 1 |
| Pavel Valena | p****a@r****m | 1 |
| Peter Ohler | p****r@o****m | 1 |
| Sean Griffin | s****n@s****m | 1 |
| artygus | h****o@e****t | 1 |
| Nicolas Leger | n****r@n****m | 1 |
| Kelley Reynolds | k****y@i****t | 1 |
| Gaurish Sharma | g****h@p****m | 1 |
| y-yagi | y****a@g****m | 1 |
Committer domains:
- punchh.com: 1
- insidesystems.net: 1
- nleger.com: 1
- engineeriam.net: 1
- seantheprogrammer.com: 1
- ohler.com: 1
- redhat.com: 1
- mloughran.com: 1
- kirshen.com: 1
- soveran.com: 1
- shopify.com: 1
- fnordig.de: 1
Issue and Pull Request metadata
Last synced: 3 months ago
Total issues: 48
Total pull requests: 47
Average time to close issues: 4 months
Average time to close pull requests: 5 months
Total issue authors: 46
Total pull request authors: 36
Average comments per issue: 3.5
Average comments per pull request: 2.49
Merged pull request: 22
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- youngwolf-project (2)
- pvalena (2)
- mroth (1)
- gyfis (1)
- findchris (1)
- mrchucho (1)
- amcvega (1)
- Apteryks (1)
- alexfarrill (1)
- printercu (1)
- voxik (1)
- sostenes89 (1)
- EppO (1)
- codeblooded (1)
- eregon (1)
Top Pull Request Authors
- stanhu (5)
- olleolleolle (3)
- kreynolds (2)
- chayim (2)
- badboy (2)
- seosgithub (2)
- mtuleika-appcast (2)
- ohler55 (1)
- nviennot (1)
- chulkilee (1)
- dplummer (1)
- y-yagi (1)
- thedrow (1)
- machty (1)
- gaurish (1)
Top Issue Labels
- wait-for-feedback (2)
- more-work-needed (1)
Top Pull Request Labels
- maintenance (1)
Package metadata
- Total packages: 5
-
Total downloads:
- rubygems: 160,272,216 total
- Total docker downloads: 247,561,822
- Total dependent packages: 136 (may contain duplicates)
- Total dependent repositories: 7,651 (may contain duplicates)
- Total versions: 80
- Total maintainers: 11
gem.coop: hiredis
Ruby wrapper for hiredis (protocol serialization/deserialization and blocking I/O)
- Homepage: http://github.com/redis/hiredis-rb
- Documentation: http://www.rubydoc.info/gems/hiredis/
- Licenses: BSD-3-Clause
- Latest release: 0.6.3 (published about 7 years ago)
- Last Synced: 2025-12-10T16:03:00.615Z (1 day ago)
- Versions: 32
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 80,141,215 Total
- Docker Downloads: 123,780,911
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.119%
- Downloads: 0.356%
- Maintainers (10)
rubygems.org: hiredis
Ruby wrapper for hiredis (protocol serialization/deserialization and blocking I/O)
- Homepage: http://github.com/redis/hiredis-rb
- Documentation: http://www.rubydoc.info/gems/hiredis/
- Licenses: BSD-3-Clause
- Latest release: 0.6.3 (published about 7 years ago)
- Last Synced: 2025-12-10T05:00:37.530Z (2 days ago)
- Versions: 32
- Dependent Packages: 136
- Dependent Repositories: 7,651
- Downloads: 80,127,173 Total
- Docker Downloads: 123,780,911
-
Rankings:
- Dependent packages count: 0.254%
- Downloads: 0.291%
- Dependent repos count: 0.369%
- Docker downloads count: 0.609%
- Average: 1.246%
- Forks count: 2.788%
- Stargazers count: 3.167%
- Maintainers (10)
proxy.golang.org: github.com/redis/hiredis-rb
- Homepage:
- Documentation: https://pkg.go.dev/github.com/redis/hiredis-rb#section-documentation
- Licenses: bsd-3-clause
- Latest release: v0.6.3 (published about 7 years ago)
- Last Synced: 2025-12-09T19:03:17.954Z (3 days ago)
- Versions: 14
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 6.456%
- Average: 6.674%
- Dependent repos count: 6.892%
gem.coop: hiredis-futureproof
Ruby wrapper for hiredis (protocol serialization/deserialization and blocking I/O)
- Homepage: http://github.com/redis/hiredis-rb
- Documentation: http://www.rubydoc.info/gems/hiredis-futureproof/
- Licenses: BSD-3-Clause
- Latest release: 0.6.3 (published almost 4 years ago)
- Last Synced: 2025-12-09T19:03:14.768Z (3 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 1,914 Total
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 31.604%
- Downloads: 94.813%
- Maintainers (1)
rubygems.org: hiredis-futureproof
Ruby wrapper for hiredis (protocol serialization/deserialization and blocking I/O)
- Homepage: http://github.com/redis/hiredis-rb
- Documentation: http://www.rubydoc.info/gems/hiredis-futureproof/
- Licenses: BSD-3-Clause
- Latest release: 0.6.3 (published almost 4 years ago)
- Last Synced: 2025-12-09T19:03:14.756Z (3 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 1,914 Total
-
Rankings:
- Forks count: 2.501%
- Stargazers count: 2.936%
- Dependent packages count: 15.706%
- Average: 33.096%
- Dependent repos count: 46.782%
- Downloads: 97.554%
- Maintainers (1)
Dependencies
- minitest ~> 5.5.1 development
- rake >= 0 development
- rake-compiler ~> 0.7.1 development
- release-drafter/release-drafter v5 composite
- actions/checkout v2 composite
- ruby/setup-ruby v1 composite
- redis * docker
Score: 28.749315828395485