Skip to content

Commit 90f8924

Browse files
committed
- Add new commands incrByFloat(), hIncrByFloat()
- Add optional params for Info()
1 parent cd97786 commit 90f8924

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

redisphp.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,26 @@ public function exists( $key ) {}
362362
*/
363363
public function incr( $key ) {}
364364

365+
/**
366+
* Increment the float value of a key by the given amount
367+
*
368+
* @param string $key
369+
* @param float $increment
370+
* @return float
371+
* @link http://redis.io/commands/incrbyfloat
372+
* @example
373+
* <pre>
374+
* $redis = new Redis();
375+
* $redis->connect('127.0.0.1');
376+
* $redis->set('x', 3);
377+
* var_dump( $redis->incrByFloat('x', 1.5) ); // float(4.5)
378+
*
379+
* // ! SIC
380+
* var_dump( $redis->get('x') ); // string(3) "4.5"
381+
* </pre>
382+
*/
383+
public function incrByFloat( $key, $increment )
384+
365385
/**
366386
* Increment the number stored at key by one. If the second argument is filled, it will be used as the integer
367387
* value of the increment.
@@ -1734,8 +1754,11 @@ public function sort( $key, $option = null ) {}
17341754

17351755

17361756
/**
1737-
* Returns an associative array of strings and integers, with the following keys:
1757+
* Returns an associative array of strings and integers
1758+
* @param string $option Optional. The option to provide redis.
1759+
* SERVER | CLIENTS | MEMORY | PERSISTENCE | STATS | REPLICATION | CPU | CLASTER | KEYSPACE | COMANDSTATS
17381760
*
1761+
* Returns an associative array of strings and integers, with the following keys:
17391762
* - redis_version
17401763
* - redis_git_sha1
17411764
* - redis_git_dirty
@@ -1781,7 +1804,7 @@ public function sort( $key, $option = null ) {}
17811804
* @link http://redis.io/commands/info
17821805
* @example $redis->info();
17831806
*/
1784-
public function info( ) {}
1807+
public function info( $option = null ) {}
17851808

17861809
/**
17871810
* Resets the statistics reported by Redis using the INFO command (`info()` function).
@@ -2556,6 +2579,34 @@ public function hExists( $key, $hashKey ) {}
25562579
*/
25572580
public function hIncrBy( $key, $hashKey, $value ) {}
25582581

2582+
/**
2583+
* Increment the float value of a hash field by the given amount
2584+
* @param string $key
2585+
* @param string $field
2586+
* @param float $increment
2587+
* @return float
2588+
* @link http://redis.io/commands/hincrbyfloat
2589+
* @example
2590+
* <pre>
2591+
* $redis = new Redis();
2592+
* $redis->connect('127.0.0.1');
2593+
* $redis->hset('h', 'float', 3);
2594+
* $redis->hset('h', 'int', 3);
2595+
* var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
2596+
*
2597+
* var_dump( $redis->hGetAll('h') );
2598+
*
2599+
* // Output
2600+
* array(2) {
2601+
* ["float"]=>
2602+
* string(3) "4.5"
2603+
* ["int"]=>
2604+
* string(1) "3"
2605+
* }
2606+
* </pre>
2607+
*/
2608+
public function hIncrByFloat( $key, $field, $increment ) {}
2609+
25592610
/**
25602611
* Fills in a whole hash. Non-string values are converted to string, using the standard (string) cast.
25612612
* NULL values are stored as empty strings

0 commit comments

Comments
 (0)