Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21c3ef9

Browse files
Fix typos/bad Markdown in cluster.markdown
1 parent f2bfd72 commit 21c3ef9

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

cluster.markdown

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Redis introduces cluster support as of version 3.0.0, and to communicate with a
88
To maintain consistency with the RedisArray class, one can create and connect to a cluster either by passing it one or more 'seed' nodes, or by defining these in redis.ini as a 'named' cluster.
99

1010
#### Declaring a cluster with an array of seeds
11-
~~~php
11+
```php
1212
// Create a cluster setting three nodes as seeds
1313
$obj_cluster = new RedisCluster(NULL, Array('host:7000', 'host:7001', 'host:7003'));
1414

@@ -21,24 +21,24 @@ $obj_cluster = new RedisCluster(NULL, Array("host:7000", "host:7001"), 1.5, 1.5,
2121

2222
// Connect with cluster using password.
2323
$obj_cluster = new RedisCluster(NULL, Array("host:7000", "host:7001"), 1.5, 1.5, true, "password");
24-
~~~
24+
```
2525

2626
#### Loading a cluster configuration by name
2727
In order to load a named array, one must first define the seed nodes in redis.ini. The following lines would define the cluster 'mycluster', and be loaded automatically by phpredis.
2828

29-
~~~ini
29+
```ini
3030
# In redis.ini
3131
redis.clusters.seeds = "mycluster[]=localhost:7000&test[]=localhost:7001"
3232
redis.clusters.timeout = "mycluster=5"
3333
redis.clusters.read_timeout = "mycluster=10"
3434
redis.clusters.auth = "mycluster=password"
35-
~~~
35+
```
3636

3737
Then, this cluster can be loaded by doing the following
3838

39-
~~~php
39+
```php
4040
$obj_cluster = new RedisCluster('mycluster');
41-
~~~
41+
```
4242

4343
## Connection process
4444

@@ -60,7 +60,7 @@ Because of this, the RedisCluster class will update its keyspace mapping wheneve
6060
## Automatic slave failover / distribution
6161
By default, RedisCluster will only ever send commands to master nodes, but can be configured differently for readonly commands if requested.
6262

63-
~~~php
63+
```php
6464
// The default option, only send commands to master nodes
6565
$obj_cluster->setOption(RedisCluster::OPT_SLAVE_FAILOVER, RedisCluster::FAILOVER_NONE);
6666

@@ -76,24 +76,24 @@ $obj_cluster->setOption(
7676
$obj_cluster->setOption(
7777
RedisCluster::OPT_SLAVE_FAILOVER, RedisCluster::FAILOVER_DISTRIBUTE_SLAVES
7878
);
79-
~~~
79+
```
8080

8181
## Main command loop
8282
With the exception of commands that are directed to a specific node, each command executed via RedisCluster is processed through a command loop, where we make the request, handle any MOVED or ASK redirection, and repeat if necessary. This continues until one of the following conditions is met:
8383

84-
1. We fail to communicate with *any* node that we are aware of, in which case a ~~~RedisClusterException~~~ is raised.
84+
1. We fail to communicate with *any* node that we are aware of, in which case a `RedisClusterException` is raised.
8585
2. We have been bounced around longer than the timeout which was set on construction.
86-
3. Redis cluster returns to us a ~~~CLUSTERDOWN~~~ error, in which case a ~~~RedisClusterException~~~ is raised.
86+
3. Redis cluster returns to us a `CLUSTERDOWN` error, in which case a `RedisClusterException` is raised.
8787
4. We receive a valid response, in which case the data is returned to the caller.
8888

8989
## Transactions
9090
The RedisCluster class fully supports MULTI ... EXEC transactions, including commands such as MGET and MSET which operate on multiple keys. There are considerations that must be taken into account here however.
9191

92-
When you call ~~~RedisCluster->multi()~~~, the cluster is put into a MULTI state, but the MULTI command is not delivered to any nodes until a key is requested on that node. In addition, calls to EXEC will always return an array (even in the event that a transaction to a given node failed), as the commands can be going to any number of nodes depending on what is called.
92+
When you call `RedisCluster->multi()`, the cluster is put into a MULTI state, but the MULTI command is not delivered to any nodes until a key is requested on that node. In addition, calls to EXEC will always return an array (even in the event that a transaction to a given node failed), as the commands can be going to any number of nodes depending on what is called.
9393

9494
Consider the following example:
9595

96-
~~~php
96+
```php
9797
// Cluster is put into MULTI state locally
9898
$obj_cluster->multi();
9999

@@ -108,7 +108,7 @@ $obj_cluster->get("myotherkey");
108108
// This will always return an array, even in the event of a failed transaction
109109
// on one of the nodes, in which case that element will be FALSE
110110
print_r($obj_cluster->exec());
111-
~~~
111+
```
112112

113113
## Pipelining
114114
The RedisCluster class does not support pipelining as there is no way to detect whether the keys still live where our map indicates that they do and would therefore be inherently unsafe. It would be possible to implement this support as an option if there is demand for such a feature.
@@ -123,25 +123,25 @@ RedisCluster has specialized processing for MGET, MSET, DEL, and UNLINK which al
123123

124124
*Note: If you send keys that hash to more than one slot, these commands are no longer atomic.*
125125

126-
~~~php
126+
```php
127127
// This will send two `MGET` commands. One for `{hash1}` keys, and one for `otherkey`
128128
$obj_cluster->mget(["{hash1}key1","{hash1}key2","{hash1}key3","otherkey"]);
129-
~~~
129+
```
130130

131131
This operation can also be done in MULTI mode transparently.
132132

133133
## Directed node commands
134134
There are a variety of commands which have to be directed at a specific node. In the case of these commands, the caller can either pass a key (which will be hashed and used to direct our command), or an array with host:port.
135135

136-
~~~php
136+
```php
137137
// This will be directed at the slot/node which would store "mykey"
138138
$obj_cluster->echo("mykey","Hello World!");
139139

140140
// Here we're iterating all of our known masters, and delivering the command there
141141
foreach ($obj_cluster->_masters() as $arr_master) {
142142
$obj_cluster->echo($arr_master, "Hello: " . implode(':', $arr_master));
143143
}
144-
~~~
144+
```
145145

146146
In the case of all commands which need to be directed at a node, the calling convention is identical to the Redis call, except that they require an additional (first) argument in order to deliver the command. Following is a list of each of these commands:
147147

@@ -167,10 +167,10 @@ You can use the cluster functionality of phpredis to store PHP session informati
167167

168168
To do this, you must configure your `session.save_handler` and `session.save_path` INI variables to give phpredis enough information to communicate with the cluster.
169169

170-
~~~ini
170+
```ini
171171
session.save_handler = rediscluster
172172
session.save_path = "seed[]=host1:port1&seed[]=host2:port2&seed[]=hostN:portN&timeout=2&read_timeout=2&failover=error&persistent=1&auth=password&stream[verify_peer]=0"
173-
~~~
173+
```
174174

175175
### session.session_handler
176176
Set this variable to "rediscluster" to inform phpredis that this is a cluster instance.
@@ -179,7 +179,7 @@ Set this variable to "rediscluster" to inform phpredis that this is a cluster in
179179
The save path for cluster based session storage takes the form of a PHP GET request, and requires that you specify at least one `seed` node. Other options you can specify are as follows:
180180

181181
* _timeout (double)_: The amount of time phpredis will wait when connecting or writing to the cluster.
182-
* _read_timeout (double)_: The amount of time phpredis will wait for a result from the cluster.
182+
* _read\_timeout (double)_: The amount of time phpredis will wait for a result from the cluster.
183183
* _persistent_: Tells phpredis whether persistent connections should be used.
184184
* _failover (string)_: How phpredis should distribute session reads between master and slave nodes.
185185
* _none_ : phpredis will only communicate with master nodes

0 commit comments

Comments
 (0)