Skip to content

Commit eef20d7

Browse files
author
Max Kamashev
committed
Add all Z functions
1 parent 7281381 commit eef20d7

File tree

1 file changed

+194
-1
lines changed

1 file changed

+194
-1
lines changed

redisphp.php

Lines changed: 194 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
class Redis
88
{
9+
const AFTER = '';
10+
const BEFORE = '';
911
/**
1012
* Creates a Redis client
1113
*
@@ -161,7 +163,7 @@ public function delete($key1, $key2 = NULL, $key3 = NULL) {}
161163
* Enter and exit transactional mode.
162164
*
163165
* @param Redis::MULTI | 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.
164-
* @return 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.
166+
* @return Redis returns the Redis instance and enters multi-mode. Once in multi-mode, all subsequent method calls return the same object until exec() is called.
165167
* @example
166168
* $ret = $redis->multi()
167169
* ->set('key1', 'val1')
@@ -1570,5 +1572,196 @@ public function zRangeByScore($key, $start, $end, array $options) {}
15701572
*/
15711573
public function zRevRangeByScore($key, $start, $end, array $options) {}
15721574

1575+
/**
1576+
* Returns the number of elements of the sorted set stored at the specified key which have
1577+
* scores in the range [start,end]. Adding a parenthesis before start or end excludes it
1578+
* from the range. +inf and -inf are also valid limits.
1579+
* @param string $key
1580+
* @param string $start
1581+
* @param string $end
1582+
* @return LONG the size of a corresponding zRangeByScore.
1583+
* @example
1584+
* $redis->zAdd('key', 0, 'val0');
1585+
* $redis->zAdd('key', 2, 'val2');
1586+
* $redis->zAdd('key', 10, 'val10');
1587+
* $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
1588+
*/
1589+
public function zCount($key, $start, $end) {}
1590+
1591+
/**
1592+
* Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end].
1593+
* @param string $key
1594+
* @param double|string $start double or "+inf" or "-inf" string
1595+
* @param double|string $end double or "+inf" or "-inf" string
1596+
* @returnLONG The number of values deleted from the sorted set
1597+
* @example
1598+
* $redis->zAdd('key', 0, 'val0');
1599+
* $redis->zAdd('key', 2, 'val2');
1600+
* $redis->zAdd('key', 10, 'val10');
1601+
* $redis->zRemRangeByScore('key', 0, 3); // 2
1602+
*/
1603+
public function zRemRangeByScore($key, $start, $end) {}
1604+
1605+
/**
1606+
* @see zRemRangeByScore()
1607+
*/
1608+
public function zDeleteRangeByScore($key, $start, $end) {}
1609+
1610+
/**
1611+
* Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end].
1612+
* @param string $key
1613+
* @param long $start
1614+
* @param long $end
1615+
* @return LONG The number of values deleted from the sorted set
1616+
* @example
1617+
* $redis->zAdd('key', 1, 'one');
1618+
* $redis->zAdd('key', 2, 'two');
1619+
* $redis->zAdd('key', 3, 'three');
1620+
* $redis->zRemRangeByRank('key', 0, 1); // 2
1621+
* $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
1622+
*/
1623+
public function zRemRangeByRank($key, $start, $end) {}
1624+
1625+
/**
1626+
* @see zRemRangeByRank()
1627+
*/
1628+
public function zDeleteRangeByRank($key, $start, $end) {}
1629+
1630+
/**
1631+
* Returns the cardinality of an ordered set.
1632+
* @param string $key
1633+
* @return Long, the set's cardinality
1634+
* @example
1635+
* $redis->zAdd('key', 0, 'val0');
1636+
* $redis->zAdd('key', 2, 'val2');
1637+
* $redis->zAdd('key', 10, 'val10');
1638+
* $redis->zSize('key'); // 3
1639+
*/
1640+
public function zSize($key) {}
1641+
1642+
/**
1643+
* @see zSize()
1644+
*/
1645+
public function zCard($key) {}
1646+
1647+
/**
1648+
* Returns the score of a given member in the specified sorted set.
1649+
* @param string $key
1650+
* @param string $member
1651+
* @return Double
1652+
* @example
1653+
* $redis->zAdd('key', 2.5, 'val2');
1654+
* $redis->zScore('key', 'val2'); // 2.5
1655+
*/
1656+
public function zScore($key, $member) {}
1657+
1658+
/**
1659+
* Returns the rank of a given member in the specified sorted set, starting at 0 for the item
1660+
* with the smallest score. zRevRank starts at 0 for the item with the largest score.
1661+
* @param string $key
1662+
* @param string $member
1663+
* @return Long, the item's score.
1664+
* @example
1665+
* $redis->delete('z');
1666+
* $redis->zAdd('key', 1, 'one');
1667+
* $redis->zAdd('key', 2, 'two');
1668+
* $redis->zRank('key', 'one'); // 0
1669+
* $redis->zRank('key', 'two'); // 1
1670+
* $redis->zRevRank('key', 'one'); // 1
1671+
* $redis->zRevRank('key', 'two'); // 0
1672+
*/
1673+
public function zRank($key, $member) {}
1674+
1675+
/**
1676+
* @see zRank()
1677+
*/
1678+
public function zRevRank($key, $member) {}
1679+
1680+
/**
1681+
* Increments the score of a member from a sorted set by a given amount.
1682+
* @param string $key
1683+
* @param double $value (double) value that will be added to the member's score
1684+
* @param string $member
1685+
* @return DOUBLE the new value
1686+
* @example
1687+
* $redis->delete('key');
1688+
* $redis->zIncrBy('key', 2.5, 'member1'); // key or member1 didn't exist, so member1's score is to 0
1689+
* // before the increment and now has the value 2.5
1690+
* $redis->zIncrBy('key', 1, 'member1'); // 3.5
1691+
*/
1692+
public function zIncrBy($key, $value, $member) {}
1693+
1694+
/**
1695+
* Creates an union of sorted sets given in second argument.
1696+
* The result of the union will be stored in the sorted set defined by the first argument.
1697+
* The third optionnel argument defines weights to apply to the sorted sets in input.
1698+
* In this case, the weights will be multiplied by the score of each element in the sorted set
1699+
* before applying the aggregation. The forth argument defines the AGGREGATE option which
1700+
* specify how the results of the union are aggregated.
1701+
* @param string $Output
1702+
* @param array $ZSetKeys
1703+
* @param array $Weights
1704+
* @param type $aggregateFunction Either "SUM", "MIN", or "MAX": defines the behaviour to use on duplicate entries during the zUnion.
1705+
* @return LONG The number of values in the new sorted set.
1706+
* @example
1707+
* $redis->delete('k1');
1708+
* $redis->delete('k2');
1709+
* $redis->delete('k3');
1710+
* $redis->delete('ko1');
1711+
* $redis->delete('ko2');
1712+
* $redis->delete('ko3');
1713+
*
1714+
* $redis->zAdd('k1', 0, 'val0');
1715+
* $redis->zAdd('k1', 1, 'val1');
1716+
*
1717+
* $redis->zAdd('k2', 2, 'val2');
1718+
* $redis->zAdd('k2', 3, 'val3');
1719+
*
1720+
* $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
1721+
*
1722+
* // Weighted zUnion
1723+
* $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
1724+
* $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko1' => array('val0', 'val2', 'val3', 'val1')
1725+
*/
1726+
public function zUnion($Output, $ZSetKeys, $Weights, $aggregateFunction) {}
1727+
1728+
/**
1729+
* Creates an intersection of sorted sets given in second argument.
1730+
* The result of the union will be stored in the sorted set defined by the first argument.
1731+
* The third optionnel argument defines weights to apply to the sorted sets in input.
1732+
* In this case, the weights will be multiplied by the score of each element in the sorted set
1733+
* before applying the aggregation. The forth argument defines the AGGREGATE option which
1734+
* specify how the results of the union are aggregated.
1735+
* @param string $Output
1736+
* @param array $ZSetKeys
1737+
* @param array $Weights
1738+
* @param string $aggregateFunction Either "SUM", "MIN", or "MAX": defines the behaviour to use on duplicate entries during the zInter.
1739+
* @return LONG The number of values in the new sorted set.
1740+
* @example
1741+
* $redis->delete('k1');
1742+
* $redis->delete('k2');
1743+
* $redis->delete('k3');
1744+
*
1745+
* $redis->delete('ko1');
1746+
* $redis->delete('ko2');
1747+
* $redis->delete('ko3');
1748+
* $redis->delete('ko4');
1749+
*
1750+
* $redis->zAdd('k1', 0, 'val0');
1751+
* $redis->zAdd('k1', 1, 'val1');
1752+
* $redis->zAdd('k1', 3, 'val3');
1753+
*
1754+
* $redis->zAdd('k2', 2, 'val1');
1755+
* $redis->zAdd('k2', 3, 'val3');
1756+
*
1757+
* $redis->zInter('ko1', array('k1', 'k2')); // 2, 'ko1' => array('val1', 'val3')
1758+
* $redis->zInter('ko2', array('k1', 'k2'), array(1, 1)); // 2, 'ko2' => array('val1', 'val3')
1759+
*
1760+
* // Weighted zInter
1761+
* $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
1762+
* $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
1763+
*/
1764+
public function zInter($Output, $ZSetKeys, $Weights, $aggregateFunction) {}
1765+
15731766

15741767
}

0 commit comments

Comments
 (0)