{"id":26816081,"url":"https://github.com/oshboul/lets_shard","last_synced_at":"2025-04-23T20:30:04.727Z","repository":{"id":56881021,"uuid":"252032129","full_name":"oshboul/lets_shard","owner":"oshboul","description":"An easy way to shard anything!","archived":false,"fork":false,"pushed_at":"2020-04-04T18:44:10.000Z","size":9,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T14:38:17.386Z","etag":null,"topics":["distribution","redis","redis-client","redis-cluster","redis-server","ruby","shard","sharding","shards"],"latest_commit_sha":null,"homepage":null,"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/oshboul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-01T00:35:33.000Z","updated_at":"2024-11-19T18:22:00.000Z","dependencies_parsed_at":"2022-08-20T13:00:38.309Z","dependency_job_id":null,"html_url":"https://github.com/oshboul/lets_shard","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oshboul%2Flets_shard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oshboul%2Flets_shard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oshboul%2Flets_shard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oshboul%2Flets_shard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oshboul","download_url":"https://codeload.github.com/oshboul/lets_shard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250509169,"owners_count":21442365,"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":["distribution","redis","redis-client","redis-cluster","redis-server","ruby","shard","sharding","shards"],"created_at":"2025-03-30T03:17:45.183Z","updated_at":"2025-04-23T20:30:04.666Z","avatar_url":"https://github.com/oshboul.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LetsShard\n\nLetsShard is an easy way to shard and distribute load/use on any set of objects!\nOne of the best uses is to shard [Redis](https://redis.io/)\n\nSo simply run your instances and let **LetsShard** shard your usage on them!\n\n**LetsShard** distributes and shards things in a way somehow similar to [Redis Cluster](https://redis.io/topics/cluster-tutorial)\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lets_shard'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install lets_shard\n\n## Usage\n\n```ruby\nrequire 'lets_shard'\n\nobjects = (0..10).map { |_| AnyObject.new } # AnyObject is an arbitrary class and not included in the gem.\n\nmy_shards = LetsShard.new(objects)\n\n# To see all objects including the intervals they cover\nmy_shards.shards\n\n# To get the object that covers \"blah\"\nmy_object = my_shards.get_object(\"blah\")\nmy_object.foo\n\n# To get the shard (including the intervals and the object it self) that covers \"blah\"\nmy_shard = my_shards.get_shard(\"blah\")\n\n# To see slots/intervals that \"my_shard\" covers\nmy_shard.start_slot\nmy_shard.end_slot\n\n# To use the object of this interval\nmy_shard.object.foo\n```\n\n### An example with redis\n\n```ruby\nrequire 'lets_shard'\nrequire 'redis'\n\nredis1 = Redis.new(host: \"10.0.0.1\", port: 6379)\nredis2 = Redis.new(host: \"10.0.0.2\", port: 6379)\n\nredis_shards = LetsShard.new([redis1, redis2])\n\nredis_shards.get_object('key').set('key', 'value')\nredis_shards.get_object('key').get('key')\n\n# redis_shards.get_object('key').any_redis_command\n```\n\n### LetsShard let you distribute objects usage better!\n\nIf you are using 3 redis instances in 3 servers, but one of these servers has more\npowerful specifications than the others and you want to utilize its power.\n\n**LetsShard** can solve it for you, easily!\n\n```ruby\nrequire 'lets_shard'\nrequire 'redis'\n\nredis1 = Redis.new(host: \"10.0.0.1\", port: 6379) # The most powerful server\nredis2 = Redis.new(host: \"10.0.0.2\", port: 6379)\nredis3 = Redis.new(host: \"10.0.0.3\", port: 6379)\n\nredises = [redis1, redis2, redis3]\nweights = [2, 1, 1] # By default, the weight of each object is 1\n\nredis_shards = LetsShard.new(redises, weights: weights)\n\n# So now LetsShard will give redis1 more slots to utilize it more!\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/oshboul/lets_shard. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lets_shard/blob/master/CODE_OF_CONDUCT.md).\n\n\n## Code of Conduct\n\nEveryone interacting in the LetsShard project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lets_shard/blob/master/CODE_OF_CONDUCT.md).\n\n\n## License\n\nLetsShard is released under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foshboul%2Flets_shard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foshboul%2Flets_shard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foshboul%2Flets_shard/lists"}