Skip to content

Commit 75434ae

Browse files
author
Tit Petric
committed
bold/italics, whitespace
1 parent b44fa17 commit 75434ae

File tree

1 file changed

+64
-10
lines changed

1 file changed

+64
-10
lines changed

README.markdown

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ You can send comments, patches, questions [here on github](https://github.com/ni
1515
* [Distributed Redis Array](#distributed-redis-array)
1616
* [Error handling](#error-handling)
1717
1. [Methods](#methods)
18-
* General
19-
* Connection
18+
* [General](#general)
19+
* [Connection](#connection)
2020
* Server
2121
* Keys and strings
2222
* Hashes
@@ -108,17 +108,18 @@ phpredis throws a `RedisException` object if it can't reach the Redis server. Th
108108

109109
### Redis::__construct
110110
-----
111-
**Description**: Creates a Redis client
111+
_**Description**_: Creates a Redis client
112112

113113
##### *Example*
114114

115115
<pre>
116116
$redis = new Redis();
117117
</pre>
118118

119+
## Connection
120+
119121
### connect, open
120122
-----
121-
122123
Connects to a Redis instance.
123124

124125
##### *Parameters*
@@ -142,7 +143,6 @@ $redis->connect('/tmp/redis.sock'); // unix domain socket.
142143

143144
### pconnect, popen
144145
-----
145-
146146
Connects to a Redis instance or reuse a connection already established with `pconnect`/`popen`.
147147

148148
The connection will not be closed on `close` or end of request until the php process ends.
@@ -218,7 +218,6 @@ $redis->getOption(Redis::OPT_SERIALIZER); // return Redis::SERIALIZER_NONE, Redi
218218

219219
### ping
220220
-----
221-
222221
Check the current connection status
223222

224223
##### *Parameters*
@@ -232,7 +231,6 @@ Check the current connection status
232231

233232
### echo
234233
-----
235-
236234
Sends a string to Redis, which replies with the same string
237235

238236
##### *Parameters*
@@ -246,7 +244,6 @@ Sends a string to Redis, which replies with the same string
246244

247245
### get
248246
-----
249-
250247
Get the value related to the specified key
251248

252249
##### *Parameters*
@@ -265,7 +262,6 @@ $redis->get('key');
265262

266263
### set
267264
-----
268-
269265
Set the string value in argument as value of the key.
270266

271267
##### *Parameters*
@@ -284,7 +280,6 @@ $redis->set('key', 'value');
284280

285281
### setex, psetex
286282
-----
287-
288283
Set the string value in argument as value of the key, with a time to live. PSETEX uses a TTL in milliseconds.
289284

290285
##### *Parameters*
@@ -301,6 +296,7 @@ Set the string value in argument as value of the key, with a time to live. PSETE
301296
$redis->setex('key', 3600, 'value'); // sets key → value, with 1h TTL.
302297
$redis->psetex('key', 100, 'value'); // sets key → value, with 0.1 sec TTL.
303298
</pre>
299+
304300
### setnx
305301
-----
306302
Set the string value in argument as value of the key if the key doesn't already exist in the database.
@@ -321,10 +317,13 @@ $redis->setnx('key', 'value'); /* return FALSE */
321317
### del, delete
322318
-----
323319
Remove specified keys.
320+
324321
##### *Parameters*
325322
An array of keys, or an undefined number of parameters, each a key: *key1* *key2* *key3* ... *keyN*
323+
326324
##### *Return value*
327325
*Long* Number of keys deleted.
326+
328327
##### *Examples*
329328
<pre>
330329
$redis->set('key1', 'val1');
@@ -339,10 +338,13 @@ $redis->delete(array('key3', 'key4')); /* return 2 */
339338
### multi, exec, discard.
340339
-----
341340
Enter and exit transactional mode.
341+
342342
##### *Parameters*
343343
(optional) `Redis::MULTI` or `Redis::PIPELINE`. Defaults to `Redis::MULTI`. A `Redis::MULTI` block of commands runs as a single transaction; a `Redis::PIPELINE` block is simply transmitted faster to the server, but without any guarantee of atomicity. `discard` cancels a transaction.
344+
344345
##### *Return value*
345346
`multi()` returns the Redis instance and enters multi-mode. Once in multi-mode, all subsequent method calls return the same object until `exec()` is called.
347+
346348
##### *Example*
347349
<pre>
348350
$ret = $redis->multi()
@@ -364,8 +366,10 @@ $ret == array(
364366
### watch, unwatch
365367
-----
366368
Watches a key for modifications by another client. If the key is modified between `WATCH` and `EXEC`, the MULTI/EXEC transaction will fail (return `FALSE`). `unwatch` cancels all the watching of all keys by this client.
369+
367370
##### *Parameters*
368371
*keys*: a list of keys
372+
369373
##### *Example*
370374
<pre>
371375
$redis->watch('x');
@@ -381,9 +385,11 @@ $ret = FALSE if x has been modified between the call to WATCH and the call to EX
381385
### subscribe
382386
-----
383387
Subscribe to channels. Warning: this function will probably change in the future.
388+
384389
##### *Parameters*
385390
*channels*: an array of channels to subscribe to
386391
*callback*: either a string or an array($instance, 'method_name'). The callback function receives 3 parameters: the redis instance, the channel name, and the message.
392+
387393
##### *Example*
388394
<pre>
389395
function f($redis, $chan, $msg) {
@@ -408,9 +414,11 @@ $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 c
408414
### psubscribe
409415
-----
410416
Subscribe to channels by pattern
417+
411418
##### *Parameters*
412419
*patterns*: An array of patterns to match
413420
*callback*: Either a string or an array with an object and method. The callback will get four arguments ($redis, $pattern, $channel, $message)
421+
414422
##### *Example*
415423
<pre>
416424
function psubscribe($redis, $pattern, $chan, $msg) {
@@ -423,9 +431,11 @@ function psubscribe($redis, $pattern, $chan, $msg) {
423431
### publish
424432
-----
425433
Publish messages to channels. Warning: this function will probably change in the future.
434+
426435
##### *Parameters*
427436
*channel*: a channel to publish to
428437
*messsage*: string
438+
429439
##### *Example*
430440
<pre>
431441
$redis->publish('chan-1', 'hello, world!'); // send message.
@@ -435,10 +445,13 @@ $redis->publish('chan-1', 'hello, world!'); // send message.
435445
### exists
436446
-----
437447
Verify if the specified key exists.
448+
438449
##### *Parameters*
439450
*key*
451+
440452
##### *Return value*
441453
*BOOL*: If the key exists, return `TRUE`, otherwise return `FALSE`.
454+
442455
##### *Examples*
443456
<pre>
444457
$redis->set('key', 'value');
@@ -449,11 +462,14 @@ $redis->exists('NonExistingKey'); /* FALSE */
449462
### incr, incrBy
450463
-----
451464
Increment the number stored at key by one. If the second argument is filled, it will be used as the integer value of the increment.
465+
452466
##### *Parameters*
453467
*key*
454468
*value*: value that will be added to key (only for incrBy)
469+
455470
##### *Return value*
456471
*INT* the new value
472+
457473
##### *Examples*
458474
<pre>
459475
$redis->incr('key1'); /* key1 didn't exists, set to 0 before the increment */
@@ -468,11 +484,14 @@ $redis->incrBy('key1', 10); /* 14 */
468484
### incrByFloat
469485
-----
470486
Increment the key with floating point precision.
487+
471488
##### *Parameters*
472489
*key*
473490
*value*: (float) value that will be added to the key
491+
474492
##### *Return value*
475493
*FLOAT* the new value
494+
476495
##### *Examples*
477496
<pre>
478497
$redis->incrByFloat('key1', 1.5); /* key1 didn't exist, so it will now be 1.5 */
@@ -486,11 +505,14 @@ $redis->incrByFloat('key1', 2.5); /* 3.5 */
486505
### decr, decrBy
487506
-----
488507
Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer value of the decrement.
508+
489509
##### *Parameters*
490510
*key*
491511
*value*: value that will be substracted to key (only for decrBy)
512+
492513
##### *Return value*
493514
*INT* the new value
515+
494516
##### *Examples*
495517
<pre>
496518
$redis->decr('key1'); /* key1 didn't exists, set to 0 before the increment */
@@ -504,10 +526,13 @@ $redis->decrBy('key1', 10); /* -13 */
504526
### mGet, getMultiple
505527
-----
506528
Get the values of all the specified keys. If one or more keys dont exist, the array will contain `FALSE` at the position of the key.
529+
507530
##### *Parameters*
508531
*Array*: Array containing the list of the keys
532+
509533
##### *Return value*
510534
*Array*: Array containing the values related to keys in argument
535+
511536
##### *Examples*
512537
<pre>
513538
$redis->set('key1', 'value1');
@@ -520,11 +545,14 @@ $redis->mGet(array('key0', 'key1', 'key5')); /* array(`FALSE`, 'value2', `FALSE`
520545
### lPush
521546
-----
522547
Adds the string value to the head (left) of the list. Creates the list if the key didn't exist. If the key exists and is not a list, `FALSE` is returned.
548+
523549
##### *Parameters*
524550
*key*
525551
*value* String, value to push in key
552+
526553
##### *Return value*
527554
*LONG* The new length of the list in case of success, `FALSE` in case of Failure.
555+
528556
##### *Examples*
529557
<pre>
530558
$redis->delete('key1');
@@ -537,11 +565,14 @@ $redis->lPush('key1', 'A'); // returns 3
537565
### rPush
538566
-----
539567
Adds the string value to the tail (right) of the list. Creates the list if the key didn't exist. If the key exists and is not a list, `FALSE` is returned.
568+
540569
##### *Parameters*
541570
*key*
542571
*value* String, value to push in key
572+
543573
##### *Return value*
544574
*LONG* The new length of the list in case of success, `FALSE` in case of Failure.
575+
545576
##### *Examples*
546577
<pre>
547578
$redis->delete('key1');
@@ -554,11 +585,14 @@ $redis->rPush('key1', 'C'); // returns 3
554585
### lPushx
555586
-----
556587
Adds the string value to the head (left) of the list if the list exists.
588+
557589
##### *Parameters*
558590
*key*
559591
*value* String, value to push in key
592+
560593
##### *Return value*
561594
*LONG* The new length of the list in case of success, `FALSE` in case of Failure.
595+
562596
##### *Examples*
563597
<pre>
564598
$redis->delete('key1');
@@ -572,11 +606,14 @@ $redis->lPushx('key1', 'C'); // returns 3
572606
### rPushx
573607
-----
574608
Adds the string value to the tail (right) of the list if the ist exists. `FALSE` in case of Failure.
609+
575610
##### *Parameters*
576611
*key*
577612
*value* String, value to push in key
613+
578614
##### *Return value*
579615
*LONG* The new length of the list in case of success, `FALSE` in case of Failure.
616+
580617
##### *Examples*
581618
<pre>
582619
$redis->delete('key1');
@@ -590,11 +627,14 @@ $redis->rPushx('key1', 'C'); // returns 3
590627
### lPop
591628
-----
592629
Return and remove the first element of the list.
630+
593631
##### *Parameters*
594632
*key*
633+
595634
##### *Return value*
596635
*STRING* if command executed successfully
597636
*BOOL* `FALSE` in case of failure (empty list)
637+
598638
##### *Example*
599639
<pre>
600640
$redis->rPush('key1', 'A');
@@ -606,11 +646,14 @@ $redis->lPop('key1'); /* key1 => [ 'B', 'C' ] */
606646
### rPop
607647
-----
608648
Returns and removes the last element of the list.
649+
609650
##### *Parameters*
610651
*key*
652+
611653
##### *Return value*
612654
*STRING* if command executed successfully
613655
*BOOL* `FALSE` in case of failure (empty list)
656+
614657
##### *Example*
615658
<pre>
616659
$redis->rPush('key1', 'A');
@@ -634,6 +677,7 @@ Or
634677
...
635678
*STRING* Keyn
636679
*INTEGER* Timeout
680+
637681
##### *Return value*
638682
*ARRAY* array('listName', 'element')
639683

@@ -669,6 +713,7 @@ $redis->lPush('key1', 'A');
669713
### lSize
670714
-----
671715
Returns the size of a list identified by Key. If the list didn't exist or is empty, the command returns 0. If the data type identified by Key is not a list, the command return `FALSE`.
716+
672717
##### *Parameters*
673718
*Key*
674719
##### *Return value*
@@ -711,12 +756,15 @@ $redis->lGet('key1', 10); /* `FALSE` */
711756
### lSet
712757
-----
713758
Set the list at index with the new value.
759+
714760
##### *Parameters*
715761
*key*
716762
*index*
717763
*value*
764+
718765
##### *Return value*
719766
*BOOL* `TRUE` if the new value is setted. `FALSE` if the index is out of range, or data type identified by key is not a list.
767+
720768
##### *Example*
721769
<pre>
722770
$redis->rPush('key1', 'A');
@@ -732,13 +780,15 @@ $redis->lGet('key1', 0); /* 'X' */
732780
Returns the specified elements of the list stored at the specified key in the range [start, end]. start and stop are interpretated as indices:
733781
0 the first element, 1 the second ...
734782
-1 the last element, -2 the penultimate ...
783+
735784
##### *Parameters*
736785
*key*
737786
*start*
738787
*end*
739788

740789
##### *Return value*
741790
*Array* containing the values in specified range.
791+
742792
##### *Example*
743793
<pre>
744794
$redis->rPush('key1', 'A');
@@ -750,13 +800,16 @@ $redis->lRange('key1', 0, -1); /* array('A', 'B', 'C') */
750800
### lTrim, listTrim
751801
-----
752802
Trims an existing list so that it will contain only a specified range of elements.
803+
753804
##### *Parameters*
754805
*key*
755806
*start*
756807
*stop*
808+
757809
##### *Return value*
758810
*Array*
759811
*Bool* return `FALSE` if the key identify a non-list value.
812+
760813
##### *Example*
761814
<pre>
762815
$redis->rPush('key1', 'A');
@@ -781,6 +834,7 @@ Removes the first `count` occurences of the value element from the list. If coun
781834
##### *Return value*
782835
*LONG* the number of elements to remove
783836
*BOOL* `FALSE` if the value identified by key is not a list.
837+
784838
##### *Example*
785839
<pre>
786840
$redis->lPush('key1', 'A');

0 commit comments

Comments
 (0)