{"id":13879482,"url":"https://github.com/redis/hiredis-rb","last_synced_at":"2025-05-15T02:09:32.070Z","repository":{"id":560238,"uuid":"927591","full_name":"redis/hiredis-rb","owner":"redis","description":"Ruby wrapper for hiredis","archived":false,"fork":false,"pushed_at":"2024-07-01T10:04:36.000Z","size":222,"stargazers_count":320,"open_issues_count":20,"forks_count":88,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-27T04:33:24.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-09-21T12:42:08.000Z","updated_at":"2025-04-24T16:02:28.000Z","dependencies_parsed_at":"2024-11-05T18:36:00.343Z","dependency_job_id":"f3f1c696-1e01-45a6-bca5-0eabb7705fb1","html_url":"https://github.com/redis/hiredis-rb","commit_stats":{"total_commits":246,"total_committers":22,"mean_commits":"11.181818181818182","dds":0.1869918699186992,"last_synced_commit":"eb27295facd5473a54585e06a043bebf5c80bb5b"},"previous_names":["pietern/hiredis-rb"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis%2Fhiredis-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis%2Fhiredis-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis%2Fhiredis-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis%2Fhiredis-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redis","download_url":"https://codeload.github.com/redis/hiredis-rb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251254259,"owners_count":21559791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:02:22.414Z","updated_at":"2025-05-15T02:09:32.051Z","avatar_url":"https://github.com/redis.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# hiredis-rb\n\n[![Build Status](https://github.com/redis/hiredis-rb/workflows/Test/badge.svg)](https://github.com/redis/hiredis-rb/actions)\n\nRuby extension that wraps [hiredis](http://github.com/redis/hiredis). Both\nthe synchronous connection API and a separate protocol reader are supported.\nIt is primarily intended to speed up parsing multi bulk replies.\n\n## Install\n\nInstall with Rubygems:\n\n    gem install hiredis\n\n## Usage\n\nHiredis can be used as standalone library, or be used together with redis-rb.\nThe latter adds in support for hiredis in 2.2.\n\n### redis-rb\n\nTo use hiredis from redis-rb, it needs to be available in Ruby's load path.\nUsing Bundler, this comes down to adding the following lines:\n\n``` ruby\ngem \"hiredis\", \"~\u003e 0.6.0\"\ngem \"redis\", \"\u003e= 3.2.0\"\n```\n\nTo use hiredis with redis-rb, you need to require `redis/connection/hiredis`\nbefore creating a new connection. This makes sure that hiredis will be used\ninstead of the pure Ruby connection code and protocol parser. Doing so in the\nGemfile is done by adding a `:require` option to the line adding the redis-rb\ndependency:\n\n``` ruby\ngem \"redis\", \"\u003e= 3.2.0\", :require =\u003e [\"redis\", \"redis/connection/hiredis\"]\n```\n\nYou can use Redis normally, as you would with the pure Ruby version.\n\n### Standalone: Connection\n\nA connection to Redis can be opened by creating an instance of\n`Hiredis::Connection` and calling `#connect`:\n\n``` ruby\nconn = Hiredis::Connection.new\nconn.connect(\"127.0.0.1\", 6379)\n```\n\nCommands can be written to Redis by calling `#write` with an array of\narguments. You can call write more than once, resulting in a pipeline of\ncommands.\n\n``` ruby\nconn.write [\"SET\", \"speed\", \"awesome\"]\nconn.write [\"GET\", \"speed\"]\n```\n\nAfter commands are written, use `#read` to receive the subsequent replies.\nMake sure **not** to call `#read` more than you have replies to read, or\nthe connection will block indefinitely. You _can_ use this feature\nto implement a subscriber (for Redis Pub/Sub).\n\n``` ruby\n\u003e\u003e conn.read\n=\u003e \"OK\"\n\n\u003e\u003e conn.read\n=\u003e \"awesome\"\n```\n\nWhen the connection was closed by the server, an error of the type\n`Hiredis::Connection::EOFError` will be raised. For all I/O related errors,\nthe Ruby built-in `Errno::XYZ` errors will be raised. All other errors\n(such as a protocol error) result in a `RuntimeError`.\n\nYou can skip loading everything and just load `Hiredis::Connection` by\nrequiring `hiredis/connection`.\n\n### Standalone: Reply parser\n\nOnly using hiredis for the reply parser can be very useful in scenarios\nwhere the I/O is already handled by another component (such as EventMachine).\n\nYou can skip loading everything and just load `Hiredis::Reader` by requiring\n`hiredis/reader`.\n\nUse `#feed` on an instance of `Hiredis::Reader` to feed the stream parser with\nnew data. Use `#read` to get the parsed replies one by one:\n\n``` ruby\n\u003e\u003e reader = Hiredis::Reader.new\n\u003e\u003e reader.feed(\"*2\\r\\n$7\\r\\nawesome\\r\\n$5\\r\\narray\\r\\n\")\n\u003e\u003e reader.gets\n=\u003e [\"awesome\", \"array\"]\n```\n\n## Benchmarks\n\nThese numbers were generated by running `benchmark/throughput.rb` against\n`ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]`. The\nbenchmark compares redis-rb with the Ruby connection and protocol code against\nredis-rb with hiredis to handle I/O and reply parsing.\n\nFor simple line or bulk replies, the throughput improvement is insignificant,\nwhile the larger multi bulk responses will have a noticeable higher throughput.\n\n                                                            user     system      total        real\n    redis-rb:  1x SET pipeline, 10000 times             0.260000   0.140000   0.400000 (  0.726216)\n     hiredis:  1x SET pipeline, 10000 times             0.170000   0.130000   0.300000 (  0.602332)\n    redis-rb: 10x SET pipeline, 10000 times             1.550000   0.660000   2.210000 (  2.231505)\n     hiredis: 10x SET pipeline, 10000 times             0.400000   0.140000   0.540000 (  0.995266)\n\n    redis-rb:  1x GET pipeline, 10000 times             0.270000   0.150000   0.420000 (  0.730322)\n     hiredis:  1x GET pipeline, 10000 times             0.170000   0.130000   0.300000 (  0.604060)\n    redis-rb: 10x GET pipeline, 10000 times             1.480000   0.640000   2.120000 (  2.122215)\n     hiredis: 10x GET pipeline, 10000 times             0.380000   0.130000   0.510000 (  0.925731)\n\n    redis-rb:  1x LPUSH pipeline, 10000 times           0.260000   0.150000   0.410000 (  0.725292)\n     hiredis:  1x LPUSH pipeline, 10000 times           0.160000   0.130000   0.290000 (  0.592466)\n    redis-rb: 10x LPUSH pipeline, 10000 times           1.540000   0.660000   2.200000 (  2.202709)\n     hiredis: 10x LPUSH pipeline, 10000 times           0.360000   0.130000   0.490000 (  0.940361)\n\n    redis-rb:  1x LRANGE(100) pipeline, 1000 times      0.240000   0.020000   0.260000 (  0.307504)\n     hiredis:  1x LRANGE(100) pipeline, 1000 times      0.050000   0.020000   0.070000 (  0.100293)\n\n    redis-rb:  1x LRANGE(1000) pipeline, 1000 times     2.100000   0.030000   2.130000 (  2.353551)\n     hiredis:  1x LRANGE(1000) pipeline, 1000 times     0.320000   0.030000   0.350000 (  0.472789)\n\n## License\n\nThis code is released under the BSD license, after the license of hiredis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis%2Fhiredis-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredis%2Fhiredis-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis%2Fhiredis-rb/lists"}