Skip to content

Commit

Permalink
Fix comments in cluster-tutorial and cluster-spec, valkey-io#140 and v…
Browse files Browse the repository at this point in the history
…alkey-io#141

* Remove junk line numbers in code examples and incorrect output in the valkey-cli prompt in examples in in cluster-tutorial.
* Remove reference to Redis OSS 3 and revert an occurrence of "adapterd to Redis coding style", since that's what this old code was.

Signed-off-by: Viktor Söderqvist <[email protected]>
  • Loading branch information
zuiderkwast committed Jun 19, 2024
1 parent b4afbed commit d2583b8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 45 deletions.
4 changes: 1 addition & 3 deletions topics/cluster-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Valkey Cluster is a distributed implementation of Valkey with the following goal
* Acceptable degree of write safety: the system tries (in a best-effort way) to retain all the writes originating from clients connected with the majority of the master nodes. Usually there are small windows where acknowledged writes can be lost. Windows to lose acknowledged writes are larger when clients are in a minority partition.
* Availability: Valkey Cluster is able to survive partitions where the majority of the master nodes are reachable and there is at least one reachable replica for every master node that is no longer reachable. Moreover using *replicas migration*, masters no longer replicated by any replica will receive one from a master which is covered by multiple replicas.

What is described in this document is implemented in Redis OSS 3.0 or greater.

### Implemented subset

Valkey Cluster implements all the single key commands available in the
Expand Down Expand Up @@ -1208,7 +1206,7 @@ The cluster makes sure the published shard messages are forwarded to all nodes i

/*
* Copyright 2001-2010 Georges Menie (www.menie.org)
* Copyright 2010 Salvatore Sanfilippo (adapted to Valkey coding style)
* Copyright 2010 Salvatore Sanfilippo (adapted to Redis coding style)
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down
84 changes: 42 additions & 42 deletions topics/cluster-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,16 @@ You can also test your Valkey Cluster using the `valkey-cli` command line utilit

```
$ valkey-cli -c -p 7000
valkey 127.0.0.1:7000> set foo bar
127.0.0.1:7000> set foo bar
-> Redirected to slot [12182] located at 127.0.0.1:7002
OK
valkey 127.0.0.1:7002> set hello world
127.0.0.1:7002> set hello world
-> Redirected to slot [866] located at 127.0.0.1:7000
OK
valkey 127.0.0.1:7000> get foo
127.0.0.1:7000> get foo
-> Redirected to slot [12182] located at 127.0.0.1:7002
"bar"
valkey 127.0.0.1:7002> get hello
127.0.0.1:7002> get hello
-> Redirected to slot [866] located at 127.0.0.1:7000
"world"
```
Expand Down Expand Up @@ -370,44 +370,44 @@ The first is the following, and is the
[`example.rb`](https://github.com/antirez/redis-rb-cluster/blob/master/example.rb)
file inside the redis-rb-cluster distribution:

```
1 require './cluster'
2
3 if ARGV.length != 2
4 startup_nodes = [
5 {:host => "127.0.0.1", :port => 7000},
6 {:host => "127.0.0.1", :port => 7001}
7 ]
8 else
9 startup_nodes = [
10 {:host => ARGV[0], :port => ARGV[1].to_i}
11 ]
12 end
13
14 rc = RedisCluster.new(startup_nodes,32,:timeout => 0.1)
15
16 last = false
17
18 while not last
19 begin
20 last = rc.get("__last__")
21 last = 0 if !last
22 rescue => e
23 puts "error #{e.to_s}"
24 sleep 1
25 end
26 end
27
28 ((last.to_i+1)..1000000000).each{|x|
29 begin
30 rc.set("foo#{x}",x)
31 puts rc.get("foo#{x}")
32 rc.set("__last__",x)
33 rescue => e
34 puts "error #{e.to_s}"
35 end
36 sleep 0.1
37 }
```ruby
require './cluster'

if ARGV.length != 2
startup_nodes = [
{:host => "127.0.0.1", :port => 7000},
{:host => "127.0.0.1", :port => 7001}
]
else
startup_nodes = [
{:host => ARGV[0], :port => ARGV[1].to_i}
]
end

rc = RedisCluster.new(startup_nodes,32,:timeout => 0.1)

last = false

while not last
begin
last = rc.get("__last__")
last = 0 if !last
rescue => e
puts "error #{e.to_s}"
sleep 1
end
end

((last.to_i+1)..1000000000).each{|x|
begin
rc.set("foo#{x}",x)
puts rc.get("foo#{x}")
rc.set("__last__",x)
rescue => e
puts "error #{e.to_s}"
end
sleep 0.1
}
```

The application does a very simple thing, it sets keys in the form `foo<number>` to `number`, one after the other. So if you run the program the result is the
Expand Down

0 comments on commit d2583b8

Please sign in to comment.