<commit_before># RedisCluster

RedisCluster for ruby is rewrited from [https://github.com/antirez/redis-rb-cluster](https://github.com/antirez/redis-rb-cluster)

Now is developing, only support single node methods, and not use in any production environments.


## Installation

Add this line to your application's Gemfile:

```ruby
gem 'redis_cluster'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install redis_cluster

## Usage

Doing!

```ruby
hosts = [{host: '127.0.0.1', port: 7000}, {host: '127.0.0.1', port: 7001}]
rs = RedisCluster.new hosts
rs.set "test", 1
rs.get "test"
```

## Benchmark

A simple benchmark at my macbook, start 4 master nodes (and 4 cold slave nodes), running with one ruby process.

```ruby
Benchmark.bm do |x|
  x.report do
    1.upto(100000).each do |i|
      redis.get "test#{i}"
    end
  end
  x.report do
    1.upto(100000).each do |i|
      redis.set "test#{i}", i
    end
  end
  x.report do
    1.upto(100000).each do |i|<commit_msg>read me<commit_after># RedisCluster

RedisCluster for ruby is rewrited from [https://github.com/antirez/redis-rb-cluster](https://github.com/antirez/redis-rb-cluster)

Now is developing, only support single node methods, and not use in any production environments.


## Installation

Add this line to your application's Gemfile:

```ruby
gem 'redis_cluster'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install redis_cluster

## Usage

Doing!

```ruby
hosts = [{host: '127.0.0.1', port: 7000}, {host: '127.0.0.1', port: 7001}]  # don't need all, gem can auto detect all nodes, and process failover if some master nodes down
rs = RedisCluster.new hosts
rs.set "test", 1
rs.get "test"
```

## Benchmark

A simple benchmark at my macbook, start 4 master nodes (and 4 cold slave nodes), running with one ruby process.

```ruby
Benchmark.bm do |x|
  x.report do
    1.upto(100000).each do |i|
      redis.get "test#{i}"
    end
  end
  x.report do
    1.upto(100000).each do |i|
      redis.set "test#{i}", i
    end
  end
  x.report do
    1.upto(100000).each do |i|
{'fraction_non_alphanumeric': 0.1279236276849642, 'fraction_numerical': 0.04200477326968974, 'mean_word_length': 3.4126315789473685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1101022', 'n_tokens_mistral': 826, 'n_tokens_neox': 731, 'n_words': 249}