{"id":29271606,"url":"https://github.com/bukalapak/redis-cluster","last_synced_at":"2025-07-05T00:02:05.586Z","repository":{"id":21292957,"uuid":"84814803","full_name":"bukalapak/redis-cluster","owner":"bukalapak","description":"Redis Cluster client for Ruby","archived":false,"fork":false,"pushed_at":"2020-07-27T22:39:41.000Z","size":189,"stargazers_count":9,"open_issues_count":2,"forks_count":5,"subscribers_count":321,"default_branch":"master","last_synced_at":"2025-06-01T14:31:28.165Z","etag":null,"topics":["redis-client","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bukalapak.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-13T10:40:10.000Z","updated_at":"2021-08-13T08:02:50.000Z","dependencies_parsed_at":"2022-09-13T17:51:44.418Z","dependency_job_id":null,"html_url":"https://github.com/bukalapak/redis-cluster","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bukalapak/redis-cluster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukalapak%2Fredis-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukalapak%2Fredis-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukalapak%2Fredis-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukalapak%2Fredis-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bukalapak","download_url":"https://codeload.github.com/bukalapak/redis-cluster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukalapak%2Fredis-cluster/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262990644,"owners_count":23396030,"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":["redis-client","ruby"],"created_at":"2025-07-05T00:01:04.821Z","updated_at":"2025-07-05T00:02:05.580Z","avatar_url":"https://github.com/bukalapak.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redis-cluster\n[![CircleCI](https://circleci.com/gh/bukalapak/redis-cluster.svg?style=shield\u0026circle-token=5ebe750ce74100b7bc18768395ec3e4ebd9f1a43)](https://circleci.com/gh/bukalapak/redis-cluster)\n[![Coverage](https://codecov.io/gh/bukalapak/redis-cluster/branch/master/graph/badge.svg?token=cPZvgDYAft)](https://codecov.io/gh/bukalapak/redis-cluster)\n\n## Description\n\nredis-cluster is redis cluster client for ruby that support pipelining.\n\n## Owner\n\nSRE Bukalapak\n\n## Contact\n\n[Contributors](https://github.com/bukalapak/redis-cluster/graphs/contributors)\n\n## Onboarding and Development Guide\n\n### Getting started\n\n1. Install redis-cluster\n\n   ````ruby\n   gem install 'redis-cluster'\n   ````\n\n2. Start `irb`. This command will start a redis-cluster client from seed servers.\n\n   ````ruby\n   seed = ['127.0.0.1:7001', '127.0.0.1:7002']\n   redis = RedisCluster.new(\n                             seed,\n                             redis_opts: { timeout: 5, connect_timeout: 1 },\n                             cluster_opts: { force_cluster: false, read_mode: :master_slave, silent: true, logger: Logger.new }\n                           )\n   redis.middlewares.register(:commit) do |*args, \u0026block|\n     puts \"this is RedisCluster middlewares\"\n     block.call\n   end\n   ````\n\n### Development Guide\n\n1. You need [rvm](https://rvm.io) and [bundler](http://bundler.io/) to test.\n   See [here](https://rvm.io/rvm/install) to install `rvm`.\n   And run these commands to install `bundler` and other dependencies\n\n   ````sh\n   gem install bundler\n   bundle install\n   ````\n\n2. You also need redis binary.\n   See [here](https://redis.io/download) to install `redis`\n\n3. Fork this repo\n\n4. Make your change and it's test.\n\n   ````sh\n   vim lib/**.rb\n   vim spec/**_spec.rb\n   ````\n\n5. Optionally, run the test in your local\n\n   ````sh\n   rake # run all test and lint\n   ````\n\n6. Commit and push your change to upstream\n\n   ````sh\n   git commit -m \"message\"\n   git push # add \"--set-upstream branch_name\" after \"git push\" if you haven't set the upstream\n   ````\n\n7. Open pull request in `Github`\n\n8. If test in CI is success, ask someone to review your code.\n\n9. If review is passed, your pull request can be merged.\n\n### Configuration\n\n#### redis_opts\n\nOption for Redis::Client instance. Set timeout, ssl, etc here.\n\n#### cluster_opts\n\nOption for RedisCluster.\n- `force_cluster`: if true, RedisCluster will only work on clustered Redis or otherwise can also work on standalone Redis. The default value is `false`.\n- `read_mode`: for read command, RedisClient can try to read from slave if specified. Supported option is `:master`(default), `:slave`, and `:master_slave`.\n- `silent`: whether or not RedisCluster will raise error.\n- `logger`: if specified. RedisCluster will log all of RedisCluster errors here.\n- `reset_interval`: reset threshold in second. A reset can only happen once per reset_interval.\n- `circuit_threshold`: Threshold how many error that client will considered an unhealthy.\n- `circuit_interval`: How long failed count will be remembered in second.\n\n#### Middlewares\n\nMiddlewares are hooks that RedisCluster provide to observe RedisCluster events. To register a middlewares, provide callable object (object that respond to call)\nor give block in register method. Middlewares must give block result as return value.\n````ruby\n# Using callable\nclass Callable\n  def call\n    start = Time.now\n    yield\n  rescue StandardError =\u003e e\n    raise e\n  ensure\n    Metrics.publish(elapsed_time: Time.now - start)\n  end\nend\nredis.middlewares.register(:commit, Callable.new)\n\n# Using proc\nredis.middlewares.register(:commit) do |*args, \u0026block|\n  begin\n    res = block.call\n  rescue StandardError =\u003e e\n    Log.warn('failed')\n    raise e\n  end\n  Log.info('success')\n  res\nend\n````\n\nCurrently there are 3 events that RedisCluster publish.\n- `:commit`\n  RedisCluster will fire `:commit` events when RedisCluster::Client call redis server. It give `RedisCluster::Client` as arguments.\n  ````ruby\n  redis.middlewares.register(:commit) do |client, \u0026block|\n    puts 'this is :commit events'\n    puts \"client url: #{client.url}\"\n    puts \"first command: #{client.queue.first.first}\"\n    puts \"last command: #{client.queue.last.first}\"\n    block.call\n  end\n  ````\n- `:call`\n  This events is fired when command is issued in RedisCluster client before any load balancing is done. It give `RedisCluster` and `RedisCluster#call` arguments as arguments\n  ````ruby\n  redis.middlewares.register(:call) do |client, keys, command, opts = {}, \u0026block|\n    puts \"keys to load balance: #{keys}\"\n    puts \"redis command: #{command.first}\"\n    puts \"in pipelined?: #{client.pipelined?}\"\n    block.call\n  end\n  redis.get('something')\n  # Output:\n  #   keys to load balance: something\n  #   redis command: get\n  ````\n- `:pipelined`\n  This events is fired when pipelined method is called from redis client. It does give `RedisCluster` as arguments\n  ````ruby\n  redis.middlewares.register(:pipelined) do |client, \u0026block|\n    puts 'pipelined is called'\n    block.call\n  end\n  ````\n\n### Limitation\n\nAll multi keys operation, cluster command, multi-exec, and some commands are not supported.\n\n### Pipeline\n\nCan be used with same interface as standalone redis client. See [redis pipeline](https://github.com/redis/redis-rb#pipelining)\n\n## FAQ\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbukalapak%2Fredis-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbukalapak%2Fredis-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbukalapak%2Fredis-cluster/lists"}