@@ -421,6 +421,24 @@ $redis->incr('key1'); /* 4 */
421
421
$redis->incrBy('key1', 10); /* 14 */
422
422
</pre >
423
423
424
+ ## incrByFloat
425
+ ##### Description
426
+ Increment the key with floating point precision.
427
+ ##### Parameters
428
+ * key*
429
+ * value* : (float) value that will be added to the key
430
+ ##### Return value
431
+ * FLOAT* the new value
432
+ ##### Examples
433
+ <pre >
434
+ $redis->incrByFloat('key1', 1.5); /* key1 didn't exist, so it will now be 1.5 */
435
+
436
+
437
+ $redis->incrByFloat('key1', 1.5); /* 3 */
438
+ $redis->incrByFloat('key1', -1.5); /* 1.5 */
439
+ $redis->incrByFloat('key1', 2.5); /* 3.5 */
440
+ </pre >
441
+
424
442
## decr, decrBy
425
443
##### Description
426
444
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.
@@ -1561,6 +1579,29 @@ $redis->setBit('key', 7, 1); /* returns 0 */
1561
1579
$redis->get('key'); /* chr(0x2f) = "/" = b("0010 1111") */
1562
1580
</pre >
1563
1581
1582
+ ## bitop
1583
+ ##### * Description*
1584
+ Bitwise operation on multiple keys.
1585
+
1586
+ ##### * Parameters*
1587
+ * operation* : either "AND", "OR", "NOT", "XOR"
1588
+ * ret_key* : return key
1589
+ * key1*
1590
+ * key2...*
1591
+
1592
+ ##### * Return value*
1593
+ * LONG* : The size of the string stored in the destination key.
1594
+
1595
+ ## bitcount
1596
+ ##### * Description*
1597
+ Count bits in a string.
1598
+
1599
+ ##### * Parameters*
1600
+ * key*
1601
+
1602
+ ##### * Return value*
1603
+ * LONG* : The number of bits set to 1 in the value behind the input key.
1604
+
1564
1605
## flushDB
1565
1606
1566
1607
##### * Description*
@@ -1626,7 +1667,9 @@ var_dump($redis->sort('s', array('sort' => 'desc', 'store' => 'out'))); // (int)
1626
1667
1627
1668
## info
1628
1669
##### * Description*
1629
- Returns an associative array of strings and integers, with the following keys:
1670
+ Returns an associative array from REDIS that provides information about the server. Passing
1671
+ no arguments to INFO will call the standard REDIS INFO command, which returns information such
1672
+ as the following:
1630
1673
1631
1674
* redis_version
1632
1675
* arch_bits
@@ -1642,13 +1685,17 @@ Returns an associative array of strings and integers, with the following keys:
1642
1685
* total_commands_processed
1643
1686
* role
1644
1687
1688
+ You can pass a variety of options to INFO (per the Redis documentation), which will modify what is
1689
+ returned.
1645
1690
1646
1691
##### * Parameters*
1647
- None.
1692
+ * option * : The option to provide redis (e.g. "COMMANDSTATS", "CPU")
1648
1693
1649
1694
##### * Example*
1650
1695
<pre >
1651
- $redis->info();
1696
+ $redis->info(); /* standard redis INFO command */
1697
+ $redis->info("COMMANDSTATS"); /* Information on the commands that have been run (>=2.6 only)
1698
+ $redis->info("CPU"); /* just CPU information from Redis INFO */
1652
1699
</pre >
1653
1700
1654
1701
## resetStat
@@ -2301,6 +2348,23 @@ $redis->hIncrBy('h', 'x', 2); /* returns 2: h[x] = 2 now. */
2301
2348
$redis->hIncrBy('h', 'x', 1); /* h[x] ← 2 + 1. Returns 3 */
2302
2349
</pre >
2303
2350
2351
+ ## hIncrByFloat
2352
+ ##### Description
2353
+ Increments the value of a hash member by the provided float value
2354
+ ##### Parameters
2355
+ * key*
2356
+ * member*
2357
+ * value* : (float) value that will be added to the member's value
2358
+ ##### Return value
2359
+ * FLOAT* the new value
2360
+ ##### Examples
2361
+ <pre >
2362
+ $redis->delete('h');
2363
+ $redis->hIncrByFloat('h','x', 1.5); /* returns 1.5: h[x] = 1.5 now */
2364
+ $redis->hIncrByFLoat('h', 'x', 1.5); /* returns 3.0: h[x] = 3.0 now */
2365
+ $redis->hIncrByFloat('h', 'x', -3.0); /* returns 0.0: h[x] = 0.0 now */
2366
+ </pre >
2367
+
2304
2368
## hMset
2305
2369
##### Description
2306
2370
Fills in a whole hash. Non-string values are converted to string, using the standard ` (string) ` cast. NULL values are stored as empty strings.
@@ -2347,3 +2411,127 @@ Get or Set the redis config keys.
2347
2411
$redis->config("GET", "*max-*-entries*");
2348
2412
$redis->config("SET", "dir", "/var/run/redis/dumps/");
2349
2413
</pre >
2414
+
2415
+ ## eval
2416
+ ##### Description
2417
+ Evaluate a LUA script serverside
2418
+ ##### Parameters
2419
+ * script* string.
2420
+ * args* array, optional.
2421
+ * num_keys* int, optional.
2422
+ ##### Return value
2423
+ Mixed. What is returned depends on what the LUA script itself returns, which could be a scalar value (int/string), or an array.
2424
+ Arrays that are returned can also contain other arrays, if that's how it was set up in your LUA script. If there is an error
2425
+ executing the LUA script, the getLastError() function can tell you the message that came back from Redis (e.g. compile error).
2426
+ ##### Examples
2427
+ <pre >
2428
+ $redis->eval("return 1"); // Returns an integer: 1
2429
+ $redis->eval("return {1,2,3}"); // Returns Array(1,2,3)
2430
+ $redis->del('mylist');
2431
+ $redis->rpush('mylist','a');
2432
+ $redis->rpush('mylist','b');
2433
+ $redis->rpush('mylist','c');
2434
+ // Nested response: Array(1,2,3,Array('a','b','c'));
2435
+ $redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}}");
2436
+ </pre >
2437
+
2438
+ ## evalSha
2439
+ ##### Description
2440
+ Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself. In order to run this command Redis
2441
+ will have to have already loaded the script, either by running it or via the SCRIPT LOAD command.
2442
+ ##### Parameters
2443
+ * script_sha* string. The sha1 encoded hash of the script you want to run.
2444
+ * args* array, optional. Arguments to pass to the LUA script.
2445
+ * num_keys* int, optional. The number of arguments that should go into the KEYS array, vs. the ARGV array when Redis spins the script
2446
+ ##### Return value
2447
+ Mixed. See EVAL
2448
+ ##### Examples
2449
+ <pre >
2450
+ $script = 'return 1';
2451
+ $sha = $redis->script('load', $script);
2452
+ $redis->evalSha($sha); // Returns 1
2453
+ </pre >
2454
+
2455
+ ## script
2456
+ ##### Description
2457
+ Execute the Redis SCRIPT command to perform various operations on the scripting subsystem.
2458
+ ##### Usage
2459
+ <pre >
2460
+ $redis->script('load', $script);
2461
+ $redis->script('flush');
2462
+ $redis->script('kill');
2463
+ $redis->script('exists', $script1, [$script2, $script3, ...]);
2464
+ </pre >
2465
+ ##### Return value
2466
+ * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure.
2467
+ * SCRIPT FLUSH should always return TRUE
2468
+ * SCRIPT KILL will return true if a script was able to be killed and false if not
2469
+ * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script
2470
+
2471
+ ## getLastError
2472
+ ##### Description
2473
+ The last error message (if any) returned from a SCRIPT call
2474
+ ##### Parameters
2475
+ * none*
2476
+ ##### Return Value
2477
+ A string with the last returned script based error message, or NULL if there is no error
2478
+ ##### Examples
2479
+ <pre >
2480
+ $redis->eval('this-is-not-lua');
2481
+ $err = $redis->getLastError();
2482
+ // "ERR Error compiling script (new function): user_script:1: '=' expected near '-'"
2483
+ </pre >
2484
+
2485
+ ## _ prefix
2486
+ ##### Description
2487
+ A utility method to prefix the value with the prefix setting for phpredis.
2488
+ ##### Parameters
2489
+ * value* string. The value you wish to prefix
2490
+ ##### Return value
2491
+ If a prefix is set up, the value now prefixed. If there is no prefix, the value will be returned unchanged.
2492
+ ##### Examples
2493
+ <pre >
2494
+ $redis->setOpt(Redis::OPT_PREFIX, 'my-prefix:');
2495
+ $redis->_prefix('my-value'); // Will return 'my-prefix:my-value'
2496
+ </pre >
2497
+
2498
+ ## _ unserialize
2499
+ ##### Description
2500
+ A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the value will be
2501
+ returned unchanged. If there is a serializer set up, and the data passed in is malformed, an exception will be thrown.
2502
+ This can be useful if phpredis is serializing values, and you return something from redis in a LUA script that is serialized.
2503
+ ##### Parameters
2504
+ * value* string. The value to be unserialized
2505
+ ##### Examples
2506
+ <pre >
2507
+ $redis->setOpt(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
2508
+ $redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)
2509
+ </pre >
2510
+
2511
+ ## dump
2512
+ ##### Description
2513
+ Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. The data
2514
+ that comes out of DUMP is a binary representation of the key as Redis stores it.
2515
+ ##### Parameters
2516
+ * key* string
2517
+ ##### Return value
2518
+ The Redis encoded value of the key, or FALSE if the key doesn't exist
2519
+ ##### Examples
2520
+ <pre >
2521
+ $redis->set('foo', 'bar');
2522
+ $val = $redis->dump('foo'); // $val will be the Redis encoded key value
2523
+ </pre >
2524
+
2525
+ ## restore
2526
+ ##### Description
2527
+ Restore a key from the result of a DUMP operation.
2528
+ ##### Parameters
2529
+ * key* string. The key name
2530
+ * ttl* integer. How long the key should live (if zero, no expire will be set on the key)
2531
+ * value* string (binary). The Redis encoded key value (from DUMP)
2532
+ ##### Examples
2533
+ <pre >
2534
+ $redis->set('foo', 'bar');
2535
+ $val = $redis->dump('foo');
2536
+ $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
2537
+ </pre >
0 commit comments