Skip to content

Commit c5f13d2

Browse files
committed
Add new commands bitCount(), bitOp()
Change info for Info()
1 parent d65f4b8 commit c5f13d2

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

redisphp.php

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,44 @@ public function getBit( $key, $offset ) {}
17031703
*/
17041704
public function setBit( $key, $offset, $value ) {}
17051705

1706+
/**
1707+
* Count bits in a string.
1708+
*
1709+
* @param string $key
1710+
* @return int The number of bits set to 1 in the value behind the input key.
1711+
* @link http://redis.io/commands/bitcount
1712+
* @example
1713+
* <pre>
1714+
* $redis->set('bit', '345'); // // 11 0011 0011 0100 0011 0101
1715+
* var_dump( $redis->bitCount('bit', 0, 0) ); // int(4)
1716+
* var_dump( $redis->bitCount('bit', 1, 1) ); // int(3)
1717+
* var_dump( $redis->bitCount('bit', 2, 2) ); // int(4)
1718+
* var_dump( $redis->bitCount('bit', 0, 2) ); // int(11)
1719+
* </pre>
1720+
*/
1721+
public function bitCount( $key ) {}
1722+
1723+
/**
1724+
* Bitwise operation on multiple keys.
1725+
*
1726+
* @param string $operation either "AND", "OR", "NOT", "XOR"
1727+
* @param string $retKey return key
1728+
* @param string $key1
1729+
* @param string $key2
1730+
* @return int The size of the string stored in the destination key.
1731+
* @link http://redis.io/commands/bitop
1732+
* @example
1733+
* <pre>
1734+
* $redis->set('bit1', '1'); // 11 0001
1735+
* $redis->set('bit2', '2'); // 11 0010
1736+
*
1737+
* $redis->bitOp('AND', 'bit', 'bit1', 'bit2'); // bit = 110000
1738+
* $redis->bitOp('OR', 'bit', 'bit1', 'bit2'); // bit = 110011
1739+
* $redis->bitOp('NOT', 'bit', 'bit1', 'bit2'); // bit = 110011
1740+
* $redis->bitOp('XOR', 'bit', 'bit1', 'bit2'); // bit = 11
1741+
* </pre>
1742+
*/
1743+
public function bitOp( $operation, $retKey, $key1, $key2, $key3 = null ) {}
17061744

17071745
/**
17081746
* Removes all entries from the current database.
@@ -1802,7 +1840,15 @@ public function sort( $key, $option = null ) {}
18021840
* - vm_enabled
18031841
* - role
18041842
* @link http://redis.io/commands/info
1805-
* @example $redis->info();
1843+
* @example
1844+
* <pre>
1845+
* $redis->info();
1846+
*
1847+
* or
1848+
*
1849+
* $redis->info("COMMANDSTATS"); //Information on the commands that have been run (>=2.6 only)
1850+
* $redis->info("CPU"); // just CPU information from Redis INFO
1851+
* </pre>
18061852
*/
18071853
public function info( $option = null ) {}
18081854

@@ -2112,7 +2158,7 @@ public function zRangeByScore( $key, $start, $end, array $options = array() ) {}
21122158
* @param int $start
21132159
* @param int $end
21142160
* @param array $options
2115-
*
2161+
*
21162162
* @return array
21172163
*/
21182164
public function zRevRangeByScore( $key, $start, $end, array $options = array() ) {}

0 commit comments

Comments
 (0)