Skip to content

Commit

Permalink
some update for redis (#89)
Browse files Browse the repository at this point in the history
* remove methods in the class doc-block

* add some methods in AbstractRedisConnection
  • Loading branch information
inhere authored and wujunze committed Jun 5, 2018
1 parent 0fec662 commit ed06c9f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 85 deletions.
47 changes: 46 additions & 1 deletion src/AbstractRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,52 @@
/**
* Class AbstractRedisConnection
*
* @package Swoft\Redis
* @link https://wiki.swoole.com/wiki/page/590.html
* @link https://github.com/phpredis/phpredis
* @package Swoft\Redis
*
* set
* @method int sAdd($key, $value1, $value2 = null, $valueN = null)
* @method array|bool scan(&$iterator, $pattern = null, $count = 0)
* @method int sCard($key)
* @method array sDiff($key1, $key2, $keyN = null)
* @method array sInter($key1, $key2, $keyN = null)
* @method int sInterStore($dstKey, $key1, $key2, $keyN = null)
* @method int sDiffStore($dstKey, $key1, $key2, $keyN = null)
* @method array sMembers($key)
* @method bool sMove($srcKey, $dstKey, $member)
* @method bool sPop($key)
* @method string|array sRandMember($key, $count = null)
* @method int sRem($key, $member1, $member2 = null, $memberN = null)
* @method array sUnion($key1, $key2, $keyN = null)
* @method int sUnionStore($dstKey, $key1, $key2, $keyN = null)
* sort
* @method int zAdd($key, $score1, $value1, $score2 = null, $value2 = null, $scoreN = null, $valueN = null)
* @method array zRange($key, $start, $end, $withscores = null)
* @method int zRem($key, $member1, $member2 = null, $memberN = null)
* @method array zRevRange($key, $start, $end, $withscore = null)
* @method array zRangeByScore($key, $start, $end, array $options = array())
* @method array zRangeByLex($key, $min, $max, $offset = null, $limit = null)
* @method int zCount($key, $start, $end)
* @method int zRemRangeByScore($key, $start, $end)
* @method int zRemRangeByRank($key, $start, $end)
* @method int zCard($key)
* @method float zScore($key, $member)
* @method int zRank($key, $member)
* @method float zIncrBy($key, $value, $member)
* @method int zUnion($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM')
* @method int zInter($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM')
* pub/sub
* @method int publish($channel, $message)
* @method string|array psubscribe($patterns, $callback)
* @method string|array subscribe($channels, $callback)
* @method array|int pubsub($keyword, $argument)
* script
* @method mixed eval($script, $args = array(), $numKeys = 0)
* @method mixed evalSha($scriptSha, $args = array(), $numKeys = 0)
* @method mixed script($command, $script)
* @method string getLastError()
* @method bool clearLastError()
*/
abstract class AbstractRedisConnection extends AbstractConnection
{
Expand Down
88 changes: 4 additions & 84 deletions src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,87 +20,7 @@
use Swoft\Redis\Pool\RedisPool;

/**
* Redis
* key and string
* @method bool setex($key, $ttl, $value)
* @method bool setnx($key, $value)
* @method int append($key, $value)
* @method int decr($key)
* @method int decrBy($key, $value)
* @method string getRange($key, $start, $end)
* @method int incr($key)
* @method int incrBy($key, $value)
* @method float incrByFloat($key, $increment)
* @method int strlen($key)
* @method bool mset(array $array)
* @method int ttl($key)
* @method int expire($key, $seconds)
* @method int pttl($key)
* @method int persist($key)
* hash
* @method int hSet($key, $hashKey, $value)
* @method bool hSetNx($key, $hashKey, $value)
* @method string hGet($key, $hashKey)
* @method int hLen($key)
* @method int hDel($key, $hashKey1, $hashKey2 = null, $hashKeyN = null)
* @method array hKeys($key)
* @method array hVals($key)
* @method array hGetAll($key)
* @method bool hExists($key, $hashKey)
* @method bool hIncrBy($key, $hashKey, $value)
* @method bool hIncrByFloat($key, $field, $increment)
* @method bool hMset($key, $hashKeys)
* list
* @method array brPop(array $keys, $timeout)
* @method array blPop(array $keys, $timeout)
* @method int lLen($key)
* @method int lPush($key, $value1, $value2 = null, $valueN = null)
* @method string lPop($key)
* @method array lRange($key, $start, $end)
* @method int lRem($key, $value, $count)
* @method bool lSet($key, $index, $value)
* @method int rPush($key, $value1, $value2 = null, $valueN = null)
* @method string rPop($key)
* set
* @method int sAdd($key, $value1, $value2 = null, $valueN = null)
* @method array|bool scan(&$iterator, $pattern = null, $count = 0)
* @method int sCard($key)
* @method array sDiff($key1, $key2, $keyN = null)
* @method array sInter($key1, $key2, $keyN = null)
* @method int sInterStore($dstKey, $key1, $key2, $keyN = null)
* @method int sDiffStore($dstKey, $key1, $key2, $keyN = null)
* @method array sMembers($key)
* @method bool sMove($srcKey, $dstKey, $member)
* @method bool sPop($key)
* @method string|array sRandMember($key, $count = null)
* @method int sRem($key, $member1, $member2 = null, $memberN = null)
* @method array sUnion($key1, $key2, $keyN = null)
* @method int sUnionStore($dstKey, $key1, $key2, $keyN = null)
* sort
* @method int zAdd($key, $score1, $value1, $score2 = null, $value2 = null, $scoreN = null, $valueN = null)
* @method array zRange($key, $start, $end, $withscores = null)
* @method int zRem($key, $member1, $member2 = null, $memberN = null)
* @method array zRevRange($key, $start, $end, $withscore = null)
* @method array zRangeByScore($key, $start, $end, array $options = array())
* @method array zRangeByLex($key, $min, $max, $offset = null, $limit = null)
* @method int zCount($key, $start, $end)
* @method int zRemRangeByScore($key, $start, $end)
* @method int zRemRangeByRank($key, $start, $end)
* @method int zCard($key)
* @method float zScore($key, $member)
* @method int zRank($key, $member)
* @method float zIncrBy($key, $value, $member)
* @method int zUnion($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM')
* @method int zInter($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM')
* pub/sub
* @method int publish($channel, $message)
* @method string|array psubscribe($patterns, $callback)
* @method string|array subscribe($channels, $callback)
* @method array|int pubsub($keyword, $argument)
* script
* @method mixed eval($script, $args = array(), $numKeys = 0)
* @method mixed evalSha($scriptSha, $args = array(), $numKeys = 0)
* @method mixed script($command, $script)
* Psr 16 implement by Redis
* @method string getLastError()
* @method bool clearLastError()
*/
Expand Down Expand Up @@ -134,14 +54,14 @@ public function get($key, $default = null)
*
* @param string $key
* @param mixed $value
* @param int $ttl
* @param int $ttl unit is seconds
*
* @return bool
*/
public function set($key, $value, $ttl = null): bool
{
$ttl = $this->getTtl($ttl);
$params = ($ttl === 0) ? [$key, $value] : [$key, $value, $ttl];
$params = ($ttl <= 0) ? [$key, $value] : [$key, $value, $ttl];

return $this->call('set', $params);
}
Expand Down Expand Up @@ -319,7 +239,7 @@ public function __call($method, $arguments)
*
* @return mixed
*/
private function call(string $method, array $params)
public function call(string $method, array $params)
{
/* @var PoolInterface $connectPool */
$connectPool = App::getPool($this->poolName);
Expand Down

0 comments on commit ed06c9f

Please sign in to comment.