精华内容
下载资源
问答
  • * php redis扩展 * @author Max Kamashev <max.kamashev@gmail.com> * @link https://github.com/ukko/phpredis-phpdoc * * @method echo string $string Sends a string to Redis, which re...
    <?php
    /**
     * php redis扩展
     * @author Max Kamashev <max.kamashev@gmail.com>
     * @link https://github.com/ukko/phpredis-phpdoc
     *
     * @method echo string $string Sends a string to Redis, which replies with the same string
     *
     * @method  eval( $script, $args = array(), $numKeys = 0 )
     *  Evaluate a LUA script serverside
     *  @param  string  $script
     *  @param  array   $args
     *  @param  int     $numKeys
     *  @return mixed   What is returned depends on what the LUA script itself returns, which could be a scalar value
     *  (int/string), or an array. 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 executing the LUA script, the getLastError() function can tell you the
     *  message that came back from Redis (e.g. compile error).
     *  @link   http://redis.io/commands/eval
     *  @example
     *  <pre>
     *  $redis->eval("return 1"); // Returns an integer: 1
     *  $redis->eval("return {1,2,3}"); // Returns Array(1,2,3)
     *  $redis->del('mylist');
     *  $redis->rpush('mylist','a');
     *  $redis->rpush('mylist','b');
     *  $redis->rpush('mylist','c');
     *  // Nested response:  Array(1,2,3,Array('a','b','c'));
     *  $redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}}");
     * </pre>
     *
     */
    class Redis
    {
        const AFTER                 = 'after';
        const BEFORE                = 'before';
    
        /**
         * 选项
         */
        const OPT_SERIALIZER        = 1;
        const OPT_PREFIX            = 2;
        const OPT_READ_TIMEOUT      = 3;
        const OPT_SCAN              = 4;
        const OPT_SLAVE_FAILOVER    = 5;
    
        /**
         * 集群选项
         */
        const FAILOVER_NONE         = 0;
        const FAILOVER_ERROR        = 1;
        const FAILOVER_DISTRIBUTE   = 2;
    
        /**
         * 扫描选项s
         */
        const SCAN_NORETRY          = 0;
        const SCAN_RETRY            = 1;
    
        /**
         * 序列化
         */
        const SERIALIZER_NONE       = 0;
        const SERIALIZER_PHP        = 1;
        const SERIALIZER_IGBINARY   = 2;
    
        /**
         * Multi
         */
        const ATOMIC                = 0;
        const MULTI                 = 1;
        const PIPELINE              = 2;
    
        /**
         * 类型
         */
        const REDIS_NOT_FOUND       = 0;
        const REDIS_STRING          = 1;
        const REDIS_SET             = 2;
        const REDIS_LIST            = 3;
        const REDIS_ZSET            = 4;
        const REDIS_HASH            = 5;
    
    
        /**
         * 创建Redis客户端
         *
         * @example $redis = new Redis();
         */
        public function __construct( ) {}
    
        /**
         * 连接到Redis实例。
         *
         * @param string    $host       can be a host, or the path to a unix domain socket
         * @param int       $port       optional
         * @param float     $timeout    value in seconds (optional, default is 0.0 meaning unlimited)
         * @param null      $reserved   should be null if $retry_interval is specified
         * @param int       $retry_interval  retry interval in milliseconds.
         * @return bool                 TRUE on success, FALSE on error.
         * @example
         * <pre>
         * $redis->connect('127.0.0.1', 6379);
         * $redis->connect('127.0.0.1');            // port 6379 by default
         * $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout.
         * $redis->connect('/tmp/redis.sock');      // unix domain socket.
         * </pre>
         */
        public function connect( $host, $port = 6379, $timeout = 0.0, $reserved = null, $retry_interval = 0 ) {}
    
        /**
         * 一种确定phpredis对象是否认为它已连接到服务器的方法
         * @return bool Returns TRUE if phpredis thinks it's connected and FALSE if not
         */
        public function isConnected() {}
    
        /**
         * @see connect()
         * @param string    $host
         * @param int       $port
         * @param float     $timeout
         * @param null      $reserved
         * @param int       $retry_interval
         */
        public function open( $host, $port = 6379, $timeout = 0.0, $reserved = null, $retry_interval = 0 ) {}
    
        /**
         * 连接到Redis实例或重用已使用pconnect / popen建立的连接。
         *
         * The connection will not be closed on close or end of request until the php process ends.
         * So be patient on to many open FD's (specially on redis server side) when using persistent connections on
         * many servers connecting to one redis server.
         *
         * Also more than one persistent connection can be made identified by either host + port + timeout
         * or unix socket + timeout.
         *
         * This feature is not available in threaded versions. pconnect and popen then working like their non persistent
         * equivalents.
         *
         * @param string    $host       can be a host, or the path to a unix domain socket
         * @param int       $port       optional
         * @param float     $timeout    value in seconds (optional, default is 0 meaning unlimited)
         * @param string    $persistent_id   unique identifier string for the connection
         * @param int       $retry_interval  retry time in milliseconds 
         * @return bool                 TRUE on success, FALSE on error.
         * @example
         * <pre>
         * $redis->connect('127.0.0.1', 6379);
         * $redis->connect('127.0.0.1');            // port 6379 by default
         * $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout.
         * $redis->connect('/tmp/redis.sock');      // unix domain socket.
         * </pre>
         */
        public function pconnect( $host, $port = 6379, $timeout = 0.0, $persistent_id = '', $retry_interval = 0 ) {}
    
        /**
         * @see pconnect()
         * @param string    $host
         * @param int       $port
         * @param float     $timeout
         * @param string    $persistent_id
         * @param int       $retry_interval
         */
        public function popen( $host, $port = 6379, $timeout = 0.0, $persistent_id = '', $retry_interval = 0 ) {}
    
        /**
         * 断开与Redis实例的连接,除非使用pconnect。
         */
        public function close( ) {}
    
        /**
         * 设置客户端选项。
         *
         * @param   string  $name    parameter name
         * @param   string  $value   parameter value
         * @return  bool:   TRUE on success, FALSE on error.
         * @example
         * <pre>
         * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);        // don't serialize data
         * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);         // use built-in serialize/unserialize
         * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);    // use igBinary serialize/unserialize
         * $redis->setOption(Redis::OPT_PREFIX, 'myAppName:');                      // use custom prefix on all keys
         * </pre>
         */
        public function setOption( $name, $value ) {}
    
        /**
         * 获取客户端选项
         *
         * @param   string  $name parameter name
         * @return  int     Parameter value.
         * @example
         * // return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, or Redis::SERIALIZER_IGBINARY.
         * $redis->getOption(Redis::OPT_SERIALIZER);
         */
        public function getOption( $name ) {}
    
        /**
         * 检查当前连接状态
         *
         * @return  string STRING: +PONG on success. Throws a RedisException object on connectivity error, as described above.
         * @link    http://redis.io/commands/ping
         */
        public function ping( ) {}
    
        /**
         * 获取与指定键相关的值
         *
         * @param   string  $key
         * @return  string|bool: If key didn't exist, FALSE is returned. Otherwise, the value related to this key is returned.
         * @link    http://redis.io/commands/get
         * @example $redis->get('key');
         */
        public function get( $key ) {}
    
    
        /**
         * 将参数中的字符串值设置为键的值。
         *
         * @since If you're using Redis >= 2.6.12, you can pass extended options as explained in example
         *
         * @param   string    $key
         * @param   string    $value
         * @param   int|array $timeout If you pass an integer, phpredis will redirect to SETEX, and will try to use Redis >= 2.6.12 extended options if you pass an array with valid values
         *
         * <pre>
         * // Simple key -> value set
         * $redis->set('key', 'value');
         *
         * // Will redirect, and actually make an SETEX call
         * $redis->set('key','value', 10);
         *
         * // Will set the key, if it doesn't exist, with a ttl of 10 seconds
         * $redis->set('key', 'value', Array('nx', 'ex'=>10));
         *
         * // Will set a key, if it does exist, with a ttl of 1000 miliseconds
         * $redis->set('key', 'value', Array('xx', 'px'=>1000));
         * </pre>
         *
         * @return  bool TRUE if the command is successful.
         *
         * @link     http://redis.io/commands/set
         */
        public function set( $key, $value, $timeout = null ) {}
    
        /**
         * 将参数中的字符串值设置为键的值,并设置生存时间。
         *
         * @param   string  $key
         * @param   int     $ttl
         * @param   string  $value
         * @return  bool:   TRUE if the command is successful.
         * @link    http://redis.io/commands/setex
         * @example $redis->setex('key', 3600, 'value'); // sets key → value, with 1h TTL.
         */
        public function setex( $key, $ttl, $value ) {}
    
        /**
         * 如果数据库中尚不存在该键,则将参数中的字符串值设置为键的值。
         *
         * @param   string  $key
         * @param   string  $value
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/setnx
         * @example
         * <pre>
         * $redis->setnx('key', 'value');   // return TRUE
         * $redis->setnx('key', 'value');   // return FALSE
         * </pre>
         */
        public function setnx( $key, $value ) {}
    
        /**
         * 删除指定的键。
         *
         * @param   string|array   $key1 An array of keys, or an undefined number of parameters, each a key: key1 key2 key3 ... keyN
         * @param   string      $key2 ...
         * @param   string      $key3 ...
         * @return int Number of keys deleted.
         * @link    http://redis.io/commands/del
         * @example
         * <pre>
         * $redis->set('key1', 'val1');
         * $redis->set('key2', 'val2');
         * $redis->set('key3', 'val3');
         * $redis->set('key4', 'val4');
         * $redis->delete('key1', 'key2');          // return 2
         * $redis->delete(array('key3', 'key4'));   // return 2
         * </pre>
         */
        public function del( $key1, $key2 = null, $key3 = null ) {}
    
        /**
         * @see del()
         * @param   string|array   $key1
         * @param   string      $key2
         * @param   string      $key3
         * @return int Number of keys deleted.
         */
        public function delete( $key1, $key2 = null, $key3 = null ) {}
    
        /**
         * 进入和退出交易模式。
         *
         * @param int 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.
         * @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.
         * @link    http://redis.io/commands/multi
         * @example
         * <pre>
         * $ret = $redis->multi()
         *      ->set('key1', 'val1')
         *      ->get('key1')
         *      ->set('key2', 'val2')
         *      ->get('key2')
         *      ->exec();
         *
         * //$ret == array (
         * //    0 => TRUE,
         * //    1 => 'val1',
         * //    2 => TRUE,
         * //    3 => 'val2');
         * </pre>
         */
        public function multi( $mode = Redis::MULTI ) {}
    
        /**
         * @see multi()
         * @return void|array
         * @link    http://redis.io/commands/exec
         */
        public function exec( ) {}
    
        /**
         * @see multi()
         * @link    http://redis.io/commands/discard
         */
        public function discard( ) {}
    
        /**
         * 观察另一个客户修改的密钥。 如果在WATCH和EXEC之间修改密钥,
         * the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client.
         * @param string | array $key: a list of keys
         * @return void
         * @link    http://redis.io/commands/watch
         * @example
         * <pre>
         * $redis->watch('x');
         * // long code here during the execution of which other clients could well modify `x`
         * $ret = $redis->multi()
         *          ->incr('x')
         *          ->exec();
         * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
         * </pre>
         */
        public function watch( $key ) {}
    
        /**
         * @see watch()
         * @link    http://redis.io/commands/unwatch
         */
        public function unwatch( ) {}
    
        /**
         * 订阅频道。
         *
         * @param array             $channels an array of channels to subscribe to
         * @param string | array    $callback either a string or an array($instance, 'method_name').
         * The callback function receives 3 parameters: the redis instance, the channel name, and the message.
         * @return mixed            Any non-null return value in the callback will be returned to the caller.
         * @link    http://redis.io/commands/subscribe
         * @example
         * <pre>
         * function f($redis, $chan, $msg) {
         *  switch($chan) {
         *      case 'chan-1':
         *          ...
         *          break;
         *
         *      case 'chan-2':
         *                     ...
         *          break;
         *
         *      case 'chan-2':
         *          ...
         *          break;
         *      }
         * }
         *
         * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
         * </pre>
         */
        public function subscribe( $channels, $callback ) {}
    
        /**
         * 按模式订阅频道
         *
         * @param   array           $patterns   The number of elements removed from the set.
         * @param   string|array    $callback   Either a string or an array with an object and method.
         *                          The callback will get four arguments ($redis, $pattern, $channel, $message)
         * @param   mixed           Any non-null return value in the callback will be returned to the caller.
         * @link    http://redis.io/commands/psubscribe
         * @example
         * <pre>
         * function psubscribe($redis, $pattern, $chan, $msg) {
         *  echo "Pattern: $pattern\n";
         *  echo "Channel: $chan\n";
         *  echo "Payload: $msg\n";
         * }
         * </pre>
         */
        public function psubscribe( $patterns, $callback ) {}
    
        /**
         * 将消息发布到频道。
         *
         * @param   string $channel a channel to publish to
         * @param   string $message string
         * @link    http://redis.io/commands/publish
         * @return  int Number of clients that received the message
         * @example $redis->publish('chan-1', 'hello, world!'); // send message.
         */
        public function publish( $channel, $message ) {}
    
        /**
         * 一个命令,允许您获取有关Redis发布/订阅系统的信息。
         * @param   string          $keyword    String, which can be: "channels", "numsub", or "numpat"
         * @param   string|array    $argument   Optional, variant.
         *                                      For the "channels" subcommand, you can pass a string pattern.
         *                                      For "numsub" an array of channel names
         * @return  array|int                   Either an integer or an array.
         *                          - channels  Returns an array where the members are the matching channels.
         *                          - numsub    Returns a key/value array where the keys are channel names and
         *                                      values are their counts.
         *                          - numpat    Integer return containing the number active pattern subscriptions.
         * @link    http://redis.io/commands/pubsub
         * @example
         * <pre>
         * $redis->pubsub('channels'); // All channels
         * $redis->pubsub('channels', '*pattern*'); // Just channels matching your pattern
         * $redis->pubsub('numsub', array('chan1', 'chan2')); // Get subscriber counts for 'chan1' and 'chan2'
         * $redis->pubsub('numpat'); // Get the number of pattern subscribers
         * </pre>
         */
        public function pubsub( $keyword, $argument ) {}
    
        /**
         * 验证指定的key是否存在。
         *
         * @param   string $key
         * @return  bool: If the key exists, return TRUE, otherwise return FALSE.
         * @link    http://redis.io/commands/exists
         * @example
         * <pre>
         * $redis->set('key', 'value');
         * $redis->exists('key');               //  TRUE
         * $redis->exists('NonExistingKey');    // FALSE
         * </pre>
         */
        public function exists( $key ) {}
    
        /**
         * 将键存储的数量增加一。
         *
         * @param   string $key
         * @return  int    the new value
         * @link    http://redis.io/commands/incr
         * @example
         * <pre>
         * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
         * $redis->incr('key1'); // 2
         * $redis->incr('key1'); // 3
         * $redis->incr('key1'); // 4
         * </pre>
         */
        public function incr( $key ) {}
    
        /**
         * 按指定的数量增加键的浮点值
         *
         * @param   string  $key
         * @param   float   $increment
         * @return  float
         * @link    http://redis.io/commands/incrbyfloat
         * @example
         * <pre>
         * $redis = new Redis();
         * $redis->connect('127.0.0.1');
         * $redis->set('x', 3);
         * var_dump( $redis->incrByFloat('x', 1.5) );   // float(4.5)
         *
         * // ! SIC
         * var_dump( $redis->get('x') );                // string(3) "4.5"
         * </pre>
         */
        public function incrByFloat( $key, $increment ) {}
    
        /**
         * 将密钥存储的数量增加一。如果第二个参数被填充,它将被用作增量的整数值。
         *
         *
         * @param   string    $key    key
         * @param   int       $value  value that will be added to key (only for incrBy)
         * @return  int         the new value
         * @link    http://redis.io/commands/incrby
         * @example
         * <pre>
         * $redis->incr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value 1
         * $redis->incr('key1');        // 2
         * $redis->incr('key1');        // 3
         * $redis->incr('key1');        // 4
         * $redis->incrBy('key1', 10);  // 14
         * </pre>
         */
        public function incrBy( $key, $value ) {}
    
        /**
         * 将键中存储的数字减1。
         *
         * @param   string $key
         * @return  int    the new value
         * @link    http://redis.io/commands/decr
         * @example
         * <pre>
         * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
         * $redis->decr('key1'); // -2
         * $redis->decr('key1'); // -3
         * </pre>
         */
        public function decr( $key ) {}
    
        /**
         * 将键中存储的数字减1。 如果第二个参数被填充,它将被用作减量的整数值。
         *
         *
         * @param   string    $key
         * @param   int       $value  that will be substracted to key (only for decrBy)
         * @return  int       the new value
         * @link    http://redis.io/commands/decrby
         * @example
         * <pre>
         * $redis->decr('key1');        // key1 didn't exists, set to 0 before the increment and now has the value -1
         * $redis->decr('key1');        // -2
         * $redis->decr('key1');        // -3
         * $redis->decrBy('key1', 10);  // -13
         * </pre>
         */
        public function decrBy( $key, $value ) {}
    
        /**
         * 获取所有指定键的值。 如果一个或多个键不存在,则数组将在键的位置包含FALSE。
         *
         *
         * @param   array $keys Array containing the list of the keys
         * @return  array Array containing the values related to keys in argument
         * @example
         * <pre>
         * $redis->set('key1', 'value1');
         * $redis->set('key2', 'value2');
         * $redis->set('key3', 'value3');
         * $redis->getMultiple(array('key1', 'key2', 'key3')); // array('value1', 'value2', 'value3');
         * $redis->getMultiple(array('key0', 'key1', 'key5')); // array(`FALSE`, 'value2', `FALSE`);
         * </pre>
         */
        public function getMultiple( array $keys ) {}
    
        /**
         * 将字符串值添加到列表的头部(左侧)。 如果key不存在,则创建列表。
         * If the key exists and is not a list, FALSE is returned.
         *
         * @param   string $key
         * @param   string $value1  String, value to push in key
         * @param   string $value2  Optional
         * @param   string $valueN  Optional
         * @return  int    The new length of the list in case of success, FALSE in case of Failure.
         * @link    http://redis.io/commands/lpush
         * @example
         * <pre>
         * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4')   // int(4)
         * var_dump( $redis->lRange('l', 0, -1) );
         *  Output:
         * // array(4) {
         * //   [0]=> string(2) "v4"
         * //   [1]=> string(2) "v3"
         * //   [2]=> string(2) "v2"
         * //   [3]=> string(2) "v1"
         * // }
         * </pre>
         */
        public function lPush( $key, $value1, $value2 = null, $valueN = null ) {}
    
        /**
         * 将字符串值添加到列表的尾部(右侧)。 如果密钥不存在,则创建列表。
         * If the key exists and is not a list, FALSE is returned.
         *
         * @param   string  $key
         * @param   string  $value1 String, value to push in key
         * @param   string  $value2 Optional
         * @param   string  $valueN Optional
         * @return  int     The new length of the list in case of success, FALSE in case of Failure.
         * @link    http://redis.io/commands/rpush
         * @example
         * <pre>
         * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4');    // int(4)
         * var_dump( $redis->lRange('l', 0, -1) );
         *  Output:
         * // array(4) {
         * //   [0]=> string(2) "v1"
         * //   [1]=> string(2) "v2"
         * //   [2]=> string(2) "v3"
         * //   [3]=> string(2) "v4"
         * // }
         * </pre>
         */
        public function rPush( $key, $value1, $value2 = null, $valueN = null ) {}
    
        /**
         * 如果列表存在,则将字符串值添加到列表的头部(左侧)。
         *
         * @param   string  $key
         * @param   string  $value String, value to push in key
         * @return  int     The new length of the list in case of success, FALSE in case of Failure.
         * @link    http://redis.io/commands/lpushx
         * @example
         * <pre>
         * $redis->delete('key1');
         * $redis->lPushx('key1', 'A');     // returns 0
         * $redis->lPush('key1', 'A');      // returns 1
         * $redis->lPushx('key1', 'B');     // returns 2
         * $redis->lPushx('key1', 'C');     // returns 3
         * // key1 now points to the following list: [ 'A', 'B', 'C' ]
         * </pre>
         */
        public function lPushx( $key, $value ) {}
    
        /**
         * 如果ist存在,则将字符串值添加到列表的尾部(右侧)。 如果失败,则为FALSE。
         *
         * @param   string  $key
         * @param   string  $value String, value to push in key
         * @return  int     The new length of the list in case of success, FALSE in case of Failure.
         * @link    http://redis.io/commands/rpushx
         * @example
         * <pre>
         * $redis->delete('key1');
         * $redis->rPushx('key1', 'A'); // returns 0
         * $redis->rPush('key1', 'A'); // returns 1
         * $redis->rPushx('key1', 'B'); // returns 2
         * $redis->rPushx('key1', 'C'); // returns 3
         * // key1 now points to the following list: [ 'A', 'B', 'C' ]
         * </pre>
         */
        public function rPushx( $key, $value ) {}
    
        /**
         * 返回并删除列表的第一个元素。
         *
         * @param   string $key
         * @return  string if command executed successfully BOOL FALSE in case of failure (empty list)
         * @link    http://redis.io/commands/lpop
         * @example
         * <pre>
         * $redis->rPush('key1', 'A');
         * $redis->rPush('key1', 'B');
         * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
         * $redis->lPop('key1');        // key1 => [ 'B', 'C' ]
         * </pre>
         */
        public function lPop( $key ) {}
    
        /**
         * 返回并删除列表的最后一个元素。
         *
         * @param   string $key
         * @return  string if command executed successfully BOOL FALSE in case of failure (empty list)
         * @link    http://redis.io/commands/rpop
         * @example
         * <pre>
         * $redis->rPush('key1', 'A');
         * $redis->rPush('key1', 'B');
         * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
         * $redis->rPop('key1');        // key1 => [ 'A', 'B' ]
         * </pre>
         */
        public function rPop( $key ) {}
    
        /**
         * Is a blocking lPop primitive. If at least one of the lists contains at least one element,
         * the element will be popped from the head of the list and returned to the caller.
         * Il all the list identified by the keys passed in arguments are empty, blPop will block
         * during the specified timeout until an element is pushed to one of those lists. This element will be popped.
         *
         * @param array $keys    Array containing the keys of the lists
         * Or STRING Key1 STRING Key2 STRING Key3 ... STRING Keyn
         * @param int   $timeout Timeout
         *
         * @return  array array('listName', 'element')
         * @link    http://redis.io/commands/blpop
         * @example
         * <pre>
         * // Non blocking feature
         * $redis->lPush('key1', 'A');
         * $redis->delete('key2');
         *
         * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
         * // OR
         * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
         *
         * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
         * // OR
         * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
         *
         * // Blocking feature
         *
         * // process 1
         * $redis->delete('key1');
         * $redis->blPop('key1', 10);
         * // blocking for 10 seconds
         *
         * // process 2
         * $redis->lPush('key1', 'A');
         *
         * // process 1
         * // array('key1', 'A') is returned
         * </pre>
         */
        public function blPop( array $keys, $timeout) {}
    
        /**
         * Is a blocking rPop primitive. If at least one of the lists contains at least one element,
         * the element will be popped from the head of the list and returned to the caller.
         * Il all the list identified by the keys passed in arguments are empty, brPop will
         * block during the specified timeout until an element is pushed to one of those lists. T
         * his element will be popped.
         *
         * @param array $keys    Array containing the keys of the lists
         * Or STRING Key1 STRING Key2 STRING Key3 ... STRING Keyn
         * @param int   $timeout Timeout
         * @return  array array('listName', 'element')
         * @link    http://redis.io/commands/brpop
         * @example
         * <pre>
         * // Non blocking feature
         * $redis->lPush('key1', 'A');
         * $redis->delete('key2');
         *
         * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
         * // OR
         * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
         *
         * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
         * // OR
         * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
         *
         * // Blocking feature
         *
         * // process 1
         * $redis->delete('key1');
         * $redis->blPop('key1', 10);
         * // blocking for 10 seconds
         *
         * // process 2
         * $redis->lPush('key1', 'A');
         *
         * // process 1
         * // array('key1', 'A') is returned
         * </pre>
         */
        public function brPop( array $keys, $timeout ) {}
    
    
        /**
         * 返回Key标识的列表的大小。
         * If the list didn't exist or is empty,
         * the command returns 0. If the data type identified by Key is not a list, the command return FALSE.
         *
         * @param   string  $key
         * @return  int     The size of the list identified by Key exists.
         * bool FALSE if the data type identified by Key is not list
         * @link    http://redis.io/commands/llen
         * @example
         * <pre>
         * $redis->rPush('key1', 'A');
         * $redis->rPush('key1', 'B');
         * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
         * $redis->lLen('key1');       // 3
         * $redis->rPop('key1');
         * $redis->lLen('key1');       // 2
         * </pre>
         */
        public function lLen( $key ) {}
    
        /**
         * @see     lLen()
         * @param   string    $key
         * @link    http://redis.io/commands/llen
         */
        public function lSize( $key ) {}
    
    
        /**
         * 返回存储在指定键中的列表的指定元素。
         * 0 the first element, 1 the second ... -1 the last element, -2 the penultimate ...
         * Return FALSE in case of a bad index or a key that doesn't point to a list.
         * @param string    $key
         * @param int       $index
         * @return String the element at this index
         * Bool FALSE if the key identifies a non-string data type, or no value corresponds to this index in the list Key.
         * @link    http://redis.io/commands/lindex
         * @example
         * <pre>
         * $redis->rPush('key1', 'A');
         * $redis->rPush('key1', 'B');
         * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
         * $redis->lGet('key1', 0);     // 'A'
         * $redis->lGet('key1', -1);    // 'C'
         * $redis->lGet('key1', 10);    // `FALSE`
         * </pre>
         */
        public function lIndex( $key, $index ) {}
    
        /**
         * @see lIndex()
         * @param   string    $key
         * @param   int       $index
         * @link    http://redis.io/commands/lindex
         */
        public function lGet( $key, $index ) {}
    
    
        /**
         * 使用新值在index处设置列表。
         *
         * @param string    $key
         * @param int       $index
         * @param string    $value
         * @return BOOL TRUE if the new value is setted. FALSE if the index is out of range, or data type identified by key
         * is not a list.
         * @link    http://redis.io/commands/lset
         * @example
         * <pre>
         * $redis->rPush('key1', 'A');
         * $redis->rPush('key1', 'B');
         * $redis->rPush('key1', 'C');  // key1 => [ 'A', 'B', 'C' ]
         * $redis->lGet('key1', 0);     // 'A'
         * $redis->lSet('key1', 0, 'X');
         * $redis->lGet('key1', 0);     // 'X'
         * </pre>
         */
        public function lSet( $key, $index, $value ) {}
    
    
        /**
         * 返回存储在[start,end]范围内指定键的列表的指定元素。
         * start and stop are interpretated as indices: 0 the first element,
         * 1 the second ... -1 the last element, -2 the penultimate ...
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @return  array containing the values in specified range.
         * @link    http://redis.io/commands/lrange
         * @example
         * <pre>
         * $redis->rPush('key1', 'A');
         * $redis->rPush('key1', 'B');
         * $redis->rPush('key1', 'C');
         * $redis->lRange('key1', 0, -1); // array('A', 'B', 'C')
         * </pre>
         */
        public function lRange( $key, $start, $end ) {}
    
        /**
         * @see lRange()
         * @link http://redis.io/commands/lrange
         * @param string    $key
         * @param int       $start
         * @param int       $end
         */
        public function lGetRange( $key, $start, $end ) {}
    
    
        /**
         * 过滤列表,使其仅包含指定范围的元素。
         *
         * @param string    $key
         * @param int       $start
         * @param int       $stop
         * @return array    Bool return FALSE if the key identify a non-list value.
         * @link        http://redis.io/commands/ltrim
         * @example
         * <pre>
         * $redis->rPush('key1', 'A');
         * $redis->rPush('key1', 'B');
         * $redis->rPush('key1', 'C');
         * $redis->lRange('key1', 0, -1); // array('A', 'B', 'C')
         * $redis->lTrim('key1', 0, 1);
         * $redis->lRange('key1', 0, -1); // array('A', 'B')
         * </pre>
         */
        public function lTrim( $key, $start, $stop ) {}
    
        /**
         * @see lTrim()
         * @link  http://redis.io/commands/ltrim
         * @param string    $key
         * @param int       $start
         * @param int       $stop
         */
        public function listTrim( $key, $start, $stop ) {}
    
    
        /**
         * 从列表中删除value元素的第一次计数。
         * If count is zero, all the matching elements are removed. If count is negative,
         * elements are removed from tail to head.
         *
         * @param   string  $key
         * @param   string  $value
         * @param   int     $count
         * @return  int     the number of elements to remove
         * bool FALSE if the value identified by key is not a list.
         * @link    http://redis.io/commands/lrem
         * @example
         * <pre>
         * $redis->lPush('key1', 'A');
         * $redis->lPush('key1', 'B');
         * $redis->lPush('key1', 'C');
         * $redis->lPush('key1', 'A');
         * $redis->lPush('key1', 'A');
         *
         * $redis->lRange('key1', 0, -1);   // array('A', 'A', 'C', 'B', 'A')
         * $redis->lRem('key1', 'A', 2);    // 2
         * $redis->lRange('key1', 0, -1);   // array('C', 'B', 'A')
         * </pre>
         */
        public function lRem( $key, $value, $count ) {}
    
        /**
         * @see lRem
         * @link    http://redis.io/commands/lremove
         * @param string    $key
         * @param string    $value
         * @param int       $count
         */
        public function lRemove( $key, $value, $count ) {}
    
    
        /**
         * Insert value in the list before or after the pivot value.
         * the parameter options
         * specify the position of the insert (before or after). If the list didn't exists,
         * or the pivot didn't exists, the value is not inserted.
         *
         * @param   string  $key
         * @param   int     $position Redis::BEFORE | Redis::AFTER
         * @param   string  $pivot
         * @param   string  $value
         * @return  int     The number of the elements in the list, -1 if the pivot didn't exists.
         * @link    http://redis.io/commands/linsert
         * @example
         * <pre>
         * $redis->delete('key1');
         * $redis->lInsert('key1', Redis::AFTER, 'A', 'X');     // 0
         *
         * $redis->lPush('key1', 'A');
         * $redis->lPush('key1', 'B');
         * $redis->lPush('key1', 'C');
         *
         * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X');    // 4
         * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C')
         *
         * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y');     // 5
         * $redis->lRange('key1', 0, -1);                       // array('A', 'B', 'X', 'C', 'Y')
         *
         * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
         * </pre>
         */
        public function lInsert( $key, $position, $pivot, $value ) {}
    
    
        /**
         * 将值添加到key中存储的设置值。
         * If this value is already in the set, FALSE is returned.
         *
         * @param   string  $key        Required key
         * @param   string  $value1     Required value
         * @param   string  $value2     Optional value
         * @param   string  $valueN     Optional value
         * @return  int     The number of elements added to the set
         * @link    http://redis.io/commands/sadd
         * @example
         * <pre>
         * $redis->sAdd('k', 'v1');                // int(1)
         * $redis->sAdd('k', 'v1', 'v2', 'v3');    // int(2)
         * </pre>
         */
        public function sAdd( $key, $value1, $value2 = null, $valueN = null ) {}
    
    
        /**
         * 从key中存储的设置值中删除指定的成员。
         *
         * @param   string  $key
         * @param   string  $member1
         * @param   string  $member2
         * @param   string  $memberN
         * @return  int     The number of elements removed from the set.
         * @link    http://redis.io/commands/srem
         * @example
         * <pre>
         * var_dump( $redis->sAdd('k', 'v1', 'v2', 'v3') );    // int(3)
         * var_dump( $redis->sRem('k', 'v2', 'v3') );          // int(2)
         * var_dump( $redis->sMembers('k') );
         *  Output:
         * // array(1) {
         * //   [0]=> string(2) "v1"
         * // }
         * </pre>
         */
        public function sRem( $key, $member1, $member2 = null, $memberN = null ) {}
    
        /**
         * @see sRem()
         * @link    http://redis.io/commands/srem
         * @param   string  $key
         * @param   string  $member1
         * @param   string  $member2
         * @param   string  $memberN
         */
        public function sRemove( $key, $member1, $member2 = null, $memberN = null ) {}
    
    
        /**
         * 将指定的成员从srcKey的set移动到dstKey的set。
         *
         * @param   string  $srcKey
         * @param   string  $dstKey
         * @param   string  $member
         * @return  bool    If the operation is successful, return TRUE.
         * If the srcKey and/or dstKey didn't exist, and/or the member didn't exist in srcKey, FALSE is returned.
         * @link    http://redis.io/commands/smove
         * @example
         * <pre>
         * $redis->sAdd('key1' , 'set11');
         * $redis->sAdd('key1' , 'set12');
         * $redis->sAdd('key1' , 'set13');          // 'key1' => {'set11', 'set12', 'set13'}
         * $redis->sAdd('key2' , 'set21');
         * $redis->sAdd('key2' , 'set22');          // 'key2' => {'set21', 'set22'}
         * $redis->sMove('key1', 'key2', 'set13');  // 'key1' =>  {'set11', 'set12'}
         *                                          // 'key2' =>  {'set21', 'set22', 'set13'}
         * </pre>
         */
        public function sMove( $srcKey, $dstKey, $member ) {}
    
    
        /**
         * 检查value是否是存储在key的集合的成员。
         *
         * @param   string  $key
         * @param   string  $value
         * @return  bool    TRUE if value is a member of the set at key key, FALSE otherwise.
         * @link    http://redis.io/commands/sismember
         * @example
         * <pre>
         * $redis->sAdd('key1' , 'set1');
         * $redis->sAdd('key1' , 'set2');
         * $redis->sAdd('key1' , 'set3'); // 'key1' => {'set1', 'set2', 'set3'}
         *
         * $redis->sIsMember('key1', 'set1'); // TRUE
         * $redis->sIsMember('key1', 'setX'); // FALSE
         * </pre>
         */
        public function sIsMember( $key, $value ) {}
    
        /**
         * @see sIsMember()
         * @link    http://redis.io/commands/sismember
         * @param   string  $key
         * @param   string  $value
         */
        public function sContains( $key, $value ) {}
    
        /**
         * 返回由key标识的集合的基数。
         *
         * @param   string  $key
         * @return  int     the cardinality of the set identified by key, 0 if the set doesn't exist.
         * @link    http://redis.io/commands/scard
         * @example
         * <pre>
         * $redis->sAdd('key1' , 'set1');
         * $redis->sAdd('key1' , 'set2');
         * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set1', 'set2', 'set3'}
         * $redis->sCard('key1');           // 3
         * $redis->sCard('keyX');           // 0
         * </pre>
         */
        public function sCard( $key ) {}
    
    
        /**
         * 从Key的设置值中删除并返回一个随机元素。
         *
         * @param   string  $key
         * @return  string  "popped" value
         * bool FALSE if set identified by key is empty or doesn't exist.
         * @link    http://redis.io/commands/spop
         * @example
         * <pre>
         * $redis->sAdd('key1' , 'set1');
         * $redis->sAdd('key1' , 'set2');
         * $redis->sAdd('key1' , 'set3');   // 'key1' => {'set3', 'set1', 'set2'}
         * $redis->sPop('key1');            // 'set1', 'key1' => {'set3', 'set2'}
         * $redis->sPop('key1');            // 'set3', 'key1' => {'set2'}
         * </pre>
         */
        public function sPop( $key ) {}
    
    
        /**
         * 从Key的设置值返回一个随机元素,而不删除它。
         *
         * @param   string        $key
         * @param   int           $count [optional]
         * @return  string|array  value(s) from the set
         * bool FALSE if set identified by key is empty or doesn't exist and count argument isn't passed.
         * @link    http://redis.io/commands/srandmember
         * @example
         * <pre>
         * $redis->sAdd('key1' , 'one');
         * $redis->sAdd('key1' , 'two');
         * $redis->sAdd('key1' , 'three');              // 'key1' => {'one', 'two', 'three'}
         *
         * var_dump( $redis->sRandMember('key1') );     // 'key1' => {'one', 'two', 'three'}
         *
         * // string(5) "three"
         *
         * var_dump( $redis->sRandMember('key1', 2) );  // 'key1' => {'one', 'two', 'three'}
         *
         * // array(2) {
         * //   [0]=> string(2) "one"
         * //   [1]=> string(2) "three"
         * // }
         * </pre>
         */
        public function sRandMember( $key, $count = null ) {}
    
        /**
         * Returns the members of a set resulting from the intersection of all the sets
         * held at the specified keys. If just a single key is specified, then this command
         * produces the members of this set. If one of the keys is missing, FALSE is returned.
         *
         * @param   string  $key1  keys identifying the different sets on which we will apply the intersection.
         * @param   string  $key2  ...
         * @param   string  $keyN  ...
         * @return  array, contain the result of the intersection between those keys.
         * If the intersection between the different sets is empty, the return value will be empty array.
         * @link    http://redis.io/commands/sinterstore
         * @example
         * <pre>
         * $redis->sAdd('key1', 'val1');
         * $redis->sAdd('key1', 'val2');
         * $redis->sAdd('key1', 'val3');
         * $redis->sAdd('key1', 'val4');
         *
         * $redis->sAdd('key2', 'val3');
         * $redis->sAdd('key2', 'val4');
         *
         * $redis->sAdd('key3', 'val3');
         * $redis->sAdd('key3', 'val4');
         *
         * var_dump($redis->sInter('key1', 'key2', 'key3'));
         *
         * //array(2) {
         * //  [0]=>
         * //  string(4) "val4"
         * //  [1]=>
         * //  string(4) "val3"
         * //}
         * </pre>
         */
        public function sInter( $key1, $key2, $keyN = null ) {}
    
        /**
         * 执行sInter命令并将结果存储在新集中。
         *
         * @param   string  $dstKey the key to store the diff into.
         * @param   string  $key1 are intersected as in sInter.
         * @param   string  $key2 ...
         * @param   string  $keyN ...
         * @return  int:    The cardinality of the resulting set, or FALSE in case of a missing key.
         * @link    http://redis.io/commands/sinterstore
         * @example
         * <pre>
         * $redis->sAdd('key1', 'val1');
         * $redis->sAdd('key1', 'val2');
         * $redis->sAdd('key1', 'val3');
         * $redis->sAdd('key1', 'val4');
         *
         * $redis->sAdd('key2', 'val3');
         * $redis->sAdd('key2', 'val4');
         *
         * $redis->sAdd('key3', 'val3');
         * $redis->sAdd('key3', 'val4');
         *
         * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
         * var_dump($redis->sMembers('output'));
         *
         * //int(2)
         * //
         * //array(2) {
         * //  [0]=>
         * //  string(4) "val4"
         * //  [1]=>
         * //  string(4) "val3"
         * //}
         * </pre>
         */
        public function sInterStore( $dstKey, $key1, $key2, $keyN = null ) {}
    
        /**
         * 执行N个集合之间的并集并返回它。
         *
         * @param   string  $key1 Any number of keys corresponding to sets in redis.
         * @param   string  $key2 ...
         * @param   string  $keyN ...
         * @return  array   of strings: The union of all these sets.
         * @link    http://redis.io/commands/sunionstore
         * @example
         * <pre>
         * $redis->delete('s0', 's1', 's2');
         *
         * $redis->sAdd('s0', '1');
         * $redis->sAdd('s0', '2');
         * $redis->sAdd('s1', '3');
         * $redis->sAdd('s1', '1');
         * $redis->sAdd('s2', '3');
         * $redis->sAdd('s2', '4');
         *
         * var_dump($redis->sUnion('s0', 's1', 's2'));
         *
         * array(4) {
         * //  [0]=>
         * //  string(1) "3"
         * //  [1]=>
         * //  string(1) "4"
         * //  [2]=>
         * //  string(1) "1"
         * //  [3]=>
         * //  string(1) "2"
         * //}
         * </pre>
         */
        public function sUnion( $key1, $key2, $keyN = null ) {}
    
        /**
         * 执行与sUnion相同的操作,但将结果存储在第一个键中
         *
         * @param   string  $dstKey  the key to store the diff into.
         * @param   string  $key1    Any number of keys corresponding to sets in redis.
         * @param   string  $key2    ...
         * @param   string  $keyN    ...
         * @return  int     Any number of keys corresponding to sets in redis.
         * @link    http://redis.io/commands/sunionstore
         * @example
         * <pre>
         * $redis->delete('s0', 's1', 's2');
         *
         * $redis->sAdd('s0', '1');
         * $redis->sAdd('s0', '2');
         * $redis->sAdd('s1', '3');
         * $redis->sAdd('s1', '1');
         * $redis->sAdd('s2', '3');
         * $redis->sAdd('s2', '4');
         *
         * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
         * var_dump($redis->sMembers('dst'));
         *
         * //int(4)
         * //array(4) {
         * //  [0]=>
         * //  string(1) "3"
         * //  [1]=>
         * //  string(1) "4"
         * //  [2]=>
         * //  string(1) "1"
         * //  [3]=>
         * //  string(1) "2"
         * //}
         * </pre>
         */
        public function sUnionStore( $dstKey, $key1, $key2, $keyN = null ) {}
    
        /**
         * 执行N组之间的差异并返回它。
         *
         * @param   string  $key1 Any number of keys corresponding to sets in redis.
         * @param   string  $key2 ...
         * @param   string  $keyN ...
         * @return  array   of strings: The difference of the first set will all the others.
         * @link    http://redis.io/commands/sdiff
         * @example
         * <pre>
         * $redis->delete('s0', 's1', 's2');
         *
         * $redis->sAdd('s0', '1');
         * $redis->sAdd('s0', '2');
         * $redis->sAdd('s0', '3');
         * $redis->sAdd('s0', '4');
         *
         * $redis->sAdd('s1', '1');
         * $redis->sAdd('s2', '3');
         *
         * var_dump($redis->sDiff('s0', 's1', 's2'));
         *
         * //array(2) {
         * //  [0]=>
         * //  string(1) "4"
         * //  [1]=>
         * //  string(1) "2"
         * //}
         * </pre>
         */
        public function sDiff( $key1, $key2, $keyN = null ) {}
    
        /**
         * 执行与sDiff相同的操作,但将结果存储在第一个键中
         *
         * @param   string  $dstKey    the key to store the diff into.
         * @param   string  $key1      Any number of keys corresponding to sets in redis
         * @param   string  $key2      ...
         * @param   string  $keyN      ...
         * @return  int:    The cardinality of the resulting set, or FALSE in case of a missing key.
         * @link    http://redis.io/commands/sdiffstore
         * @example
         * <pre>
         * $redis->delete('s0', 's1', 's2');
         *
         * $redis->sAdd('s0', '1');
         * $redis->sAdd('s0', '2');
         * $redis->sAdd('s0', '3');
         * $redis->sAdd('s0', '4');
         *
         * $redis->sAdd('s1', '1');
         * $redis->sAdd('s2', '3');
         *
         * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
         * var_dump($redis->sMembers('dst'));
         *
         * //int(2)
         * //array(2) {
         * //  [0]=>
         * //  string(1) "4"
         * //  [1]=>
         * //  string(1) "2"
         * //}
         * </pre>
         */
        public function sDiffStore( $dstKey, $key1, $key2, $keyN = null ) {}
    
        /**
         * 返回集合的内容。
         *
         * @param   string  $key
         * @return  array   An array of elements, the contents of the set.
         * @link    http://redis.io/commands/smembers
         * @example
         * <pre>
         * $redis->delete('s');
         * $redis->sAdd('s', 'a');
         * $redis->sAdd('s', 'b');
         * $redis->sAdd('s', 'a');
         * $redis->sAdd('s', 'c');
         * var_dump($redis->sMembers('s'));
         *
         * //array(3) {
         * //  [0]=>
         * //  string(1) "c"
         * //  [1]=>
         * //  string(1) "a"
         * //  [2]=>
         * //  string(1) "b"
         * //}
         * // The order is random and corresponds to redis' own internal representation of the set structure.
         * </pre>
         */
        public function sMembers( $key ) {}
    
        /**
         * @see sMembers()
         * @return  array   An array of elements, the contents of the set.
         * @param   string  $key
         * @link    http://redis.io/commands/smembers
         */
        public function sGetMembers( $key ) {}
    
        /**
         * 扫描成员的集合。
         * @param   string  $key        The set to search.
         * @param   int     $iterator   LONG (reference) to the iterator as we go.
         * @param   null    $pattern    String, optional pattern to match against.
         * @param   int     $count      How many members to return at a time (Redis might return a different amount).
         * @return  array   PHPRedis will return an array of keys or FALSE when we're done iterating.
         * @link    http://redis.io/commands/sscan
         * @example
         * <pre>
         * $iterator = null;
         * while ($members = $redis->sScan('set', $iterator)) {
         *     foreach ($members as $member) {
         *         echo $member . PHP_EOL;
         *     }
         * }
         * </pre>
         */
        public function sScan( $key, &$iterator, $pattern = null, $count = 0 ) {}
    
        /**
         * 设置一个值并返回该键的上一个条目。
         *
         * @param   string  $key
         * @param   string  $value
         * @return  string  A string, the previous value located at this key.
         * @link    http://redis.io/commands/getset
         * @example
         * <pre>
         * $redis->set('x', '42');
         * $exValue = $redis->getSet('x', 'lol');   // return '42', replaces x by 'lol'
         * $newValue = $redis->get('x')'            // return 'lol'
         * </pre>
         */
        public function getSet( $key, $value ) {}
    
        /**
         * 返回一个随机密钥。
         *
         * @return string: an existing key in redis.
         * @link    http://redis.io/commands/randomkey
         * @example
         * <pre>
         * $key = $redis->randomKey();
         * $surprise = $redis->get($key);  // who knows what's in there.
         * </pre>
         */
        public function randomKey( ) {}
    
    
        /**
         * 切换到给定的数据库。
         *
         * @param   int     $dbindex
         * @return  bool    TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/select
         * @example
         * <pre>
         * $redis->select(0);       // switch to DB 0
         * $redis->set('x', '42');  // write 42 to x
         * $redis->move('x', 1);    // move to DB 1
         * $redis->select(1);       // switch to DB 1
         * $redis->get('x');        // will return 42
         * </pre>
         */
        public function select( $dbindex ) {}
    
        /**
         * 将key移动到其他数据库。
         *
         * @param   string  $key
         * @param   int     $dbindex
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/move
         * @example
         * <pre>
         * $redis->select(0);       // switch to DB 0
         * $redis->set('x', '42');  // write 42 to x
         * $redis->move('x', 1);    // move to DB 1
         * $redis->select(1);       // switch to DB 1
         * $redis->get('x');        // will return 42
         * </pre>
         */
        public function move( $key, $dbindex ) {}
    
        /**
         * 重命名一个key
         *
         * @param   string  $srcKey
         * @param   string  $dstKey
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/rename
         * @example
         * <pre>
         * $redis->set('x', '42');
         * $redis->rename('x', 'y');
         * $redis->get('y');   // → 42
         * $redis->get('x');   // → `FALSE`
         * </pre>
         */
        public function rename( $srcKey, $dstKey ) {}
    
        /**
         * @see rename()
         * @link    http://redis.io/commands/rename
         * @param   string  $srcKey
         * @param   string  $dstKey
         */
        public function renameKey( $srcKey, $dstKey ) {}
    
        /**
         * 重命名一个key
         *
         * Same as rename, but will not replace a key if the destination already exists.
         * This is the same behaviour as setNx.
         *
         * @param   string  $srcKey
         * @param   string  $dstKey
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/renamenx
         * @example
         * <pre>
         * $redis->set('x', '42');
         * $redis->rename('x', 'y');
         * $redis->get('y');   // → 42
         * $redis->get('x');   // → `FALSE`
         * </pre>
         */
        public function renameNx( $srcKey, $dstKey ) {}
    
        /**
         * 设置元素的到期日期(超时)。
         *
         * @param   string  $key    The key that will disappear.
         * @param   int     $ttl    The key's remaining Time To Live, in seconds.
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/expire
         * @example
         * <pre>
         * $redis->set('x', '42');
         * $redis->setTimeout('x', 3);  // x will disappear in 3 seconds.
         * sleep(5);                    // wait 5 seconds
         * $redis->get('x');            // will return `FALSE`, as 'x' has expired.
         * </pre>
         */
        public function expire( $key, $ttl ) {}
    
        /**
         * 设置元素的到期日期(以毫秒为单位的超时)。
         *
         * @param   string  $key    The key that will disappear.
         * @param   int     $ttl   The key's remaining Time To Live, in milliseconds.
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/pexpire
         * @example
         * <pre>
         * $redis->set('x', '42');
         * $redis->pExpire('x', 11500); // x will disappear in 11500 milliseconds.
         * $redis->ttl('x');            // 12
         * $redis->pttl('x');           // 11500
         * </pre>
         */
        public function pExpire( $key, $ttl ) {}
    
        /**
         * @see expire()
         * @param   string  $key
         * @param   int     $ttl
         * @link    http://redis.io/commands/expire
         */
        public function setTimeout( $key, $ttl ) {}
    
        /**
         * 设置item的到期日期(时间戳)。
         *
         * @param   string  $key        The key that will disappear.
         * @param   int     $timestamp  Unix timestamp. The key's date of death, in seconds from Epoch time.
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/expireat
         * @example
         * <pre>
         * $redis->set('x', '42');
         * $now = time(NULL);               // current timestamp
         * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
         * sleep(5);                        // wait 5 seconds
         * $redis->get('x');                // will return `FALSE`, as 'x' has expired.
         * </pre>
         */
        public function expireAt( $key, $timestamp ) {}
    
        /**
         * 设置item的到期日期(时间戳)。 需要以毫秒为单位的时间戳
         *
         * @param   string  $key        The key that will disappear.
         * @param   int     $timestamp  Unix timestamp. The key's date of death, in seconds from Epoch time.
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/pexpireat
         * @example
         * <pre>
         * $redis->set('x', '42');
         * $redis->pExpireAt('x', 1555555555005);
         * echo $redis->ttl('x');                       // 218270121
         * echo $redis->pttl('x');                      // 218270120575
         * </pre>
         */
        public function pExpireAt( $key, $timestamp ) {}
    
        /**
         * 返回与特定模式匹配的键。
         *
         * @param   string  $pattern pattern, using '*' as a wildcard.
         * @return  array   of STRING: The keys that match a certain pattern.
         * @link    http://redis.io/commands/keys
         * @example
         * <pre>
         * $allKeys = $redis->keys('*');   // all keys will match this.
         * $keyWithUserPrefix = $redis->keys('user*');
         * </pre>
         */
        public function keys( $pattern ) {}
    
        /**
         * @see keys()
         * @param   string  $pattern
         * @link    http://redis.io/commands/keys
         */
        public function getKeys( $pattern ) {}
    
        /**
         * 返回当前数据库的大小。
         *
         * @return int:     DB size, in number of keys.
         * @link    http://redis.io/commands/dbsize
         * @example
         * <pre>
         * $count = $redis->dbSize();
         * echo "Redis has $count keys\n";
         * </pre>
         */
        public function dbSize( ) {}
    
        /**
         * 使用密码验证连接。
         * Warning: The password is sent in plain-text over the network.
         *
         * @param   string  $password
         * @return  bool:   TRUE if the connection is authenticated, FALSE otherwise.
         * @link    http://redis.io/commands/auth
         * @example $redis->auth('foobared');
         */
        public function auth( $password ) {}
    
        /**
         * 开始后台重写AOF(仅附加文件)
         *
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/bgrewriteaof
         * @example $redis->bgrewriteaof();
         */
        public function bgrewriteaof( ) {}
    
        /**
         * Changes the slave status
         * Either host and port, or no parameter to stop being a slave.
         *
         * @param   string  $host [optional]
         * @param   int $port [optional]
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/slaveof
         * @example
         * <pre>
         * $redis->slaveof('10.0.1.7', 6379);
         * // ...
         * $redis->slaveof();
         * </pre>
         */
        public function slaveof( $host = '127.0.0.1', $port = 6379 ) {}
    
        /**
         * 描述键所指向的对象。
         * The information to retrieve (string) and the key (string).
         * Info can be one of the following:
         * - "encoding"
         * - "refcount"
         * - "idletime"
         *
         * @param   string  $string
         * @param   string  $key
         * @return  string  for "encoding", int for "refcount" and "idletime", FALSE if the key doesn't exist.
         * @link    http://redis.io/commands/object
         * @example
         * <pre>
         * $redis->object("encoding", "l"); // → ziplist
         * $redis->object("refcount", "l"); // → 1
         * $redis->object("idletime", "l"); // → 400 (in seconds, with a precision of 10 seconds).
         * </pre>
         */
        public function object( $string = '', $key = '' ) {}
    
        /**
         * 执行同步保存。
         *
         * @return  bool:   TRUE in case of success, FALSE in case of failure.
         * If a save is already running, this command will fail and return FALSE.
         * @link    http://redis.io/commands/save
         * @example $redis->save();
         */
        public function save( ) {}
    
        /**
         * 执行后台保存。
         *
         * @return  bool:    TRUE in case of success, FALSE in case of failure.
         * If a save is already running, this command will fail and return FALSE.
         * @link    http://redis.io/commands/bgsave
         * @example $redis->bgSave();
         */
        public function bgsave( ) {}
    
        /**
         * 返回上次磁盘保存的时间戳。
         *
         * @return  int:    timestamp.
         * @link    http://redis.io/commands/lastsave
         * @example $redis->lastSave();
         */
        public function lastSave( ) {}
    
        /**
         * Blocks the current client until all the previous write commands are successfully transferred and
         * acknowledged by at least the specified number of slaves.
         * @param   int $numSlaves  Number of slaves that need to acknowledge previous write commands.
         * @param   int $timeout    Timeout in milliseconds.
         * @return  int The command returns the number of slaves reached by all the writes performed in the
         *              context of the current connection.
         * @link    http://redis.io/commands/wait
         * @example $redis->wait(2, 1000);
         */
        public function wait( $numSlaves, $timeout ) {}
    
        /**
         * 返回给定键指向的数据类型。
         *
         * @param   string  $key
         * @return  int
         *
         * Depending on the type of the data pointed by the key,
         * this method will return the following value:
         * - string: Redis::REDIS_STRING
         * - set:   Redis::REDIS_SET
         * - list:  Redis::REDIS_LIST
         * - zset:  Redis::REDIS_ZSET
         * - hash:  Redis::REDIS_HASH
         * - other: Redis::REDIS_NOT_FOUND
         * @link    http://redis.io/commands/type
         * @example $redis->type('key');
         */
        public function type( $key ) {}
    
        /**
         * 将指定的字符串附加到存储在指定键中的字符串。
         *
         * @param   string  $key
         * @param   string  $value
         * @return  int:    Size of the value after the append
         * @link    http://redis.io/commands/append
         * @example
         * <pre>
         * $redis->set('key', 'value1');
         * $redis->append('key', 'value2'); // 12
         * $redis->get('key');              // 'value1value2'
         * </pre>
         */
        public function append( $key, $value ) {}
    
    
        /**
         * 返回较大字符串的子字符串
         *
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @return  string: the substring
         * @link    http://redis.io/commands/getrange
         * @example
         * <pre>
         * $redis->set('key', 'string value');
         * $redis->getRange('key', 0, 5);   // 'string'
         * $redis->getRange('key', -5, -1); // 'value'
         * </pre>
         */
        public function getRange( $key, $start, $end ) {}
    
        /**
         * 返回较大字符串的子字符串
         *
         * @deprecated
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         */
        public function substr( $key, $start, $end ) {}
    
    
        /**
         * 更改较大字符串的子字符串。
         *
         * @param   string  $key
         * @param   int     $offset
         * @param   string  $value
         * @return  string: the length of the string after it was modified.
         * @link    http://redis.io/commands/setrange
         * @example
         * <pre>
         * $redis->set('key', 'Hello world');
         * $redis->setRange('key', 6, "redis"); // returns 11
         * $redis->get('key');                  // "Hello redis"
         * </pre>
         */
        public function setRange( $key, $offset, $value ) {}
    
        /**
         * 获取字符串值的长度。
         *
         * @param   string  $key
         * @return  int
         * @link    http://redis.io/commands/strlen
         * @example
         * <pre>
         * $redis->set('key', 'value');
         * $redis->strlen('key'); // 5
         * </pre>
         */
        public function strlen( $key ) {}
    
        /**
         * Return the position of the first bit set to 1 or 0 in a string. The position is returned, thinking of the
         * string as an array of bits from left to right, where the first byte's most significant bit is at position 0,
         * the second byte's most significant bit is at position 8, and so forth.
         * @param   string  $key
         * @param   int     $bit
         * @param   int     $start
         * @param   int     $end
         * @return  int     The command returns the position of the first bit set to 1 or 0 according to the request.
         *                  If we look for set bits (the bit argument is 1) and the string is empty or composed of just
         *                  zero bytes, -1 is returned. If we look for clear bits (the bit argument is 0) and the string
         *                  only contains bit set to 1, the function returns the first bit not part of the string on the
         *                  right. So if the string is three bytes set to the value 0xff the command BITPOS key 0 will
         *                  return 24, since up to bit 23 all the bits are 1. Basically, the function considers the right
         *                  of the string as padded with zeros if you look for clear bits and specify no range or the
         *                  start argument only. However, this behavior changes if you are looking for clear bits and
         *                  specify a range with both start and end. If no clear bit is found in the specified range, the
         *                  function returns -1 as the user specified a clear range and there are no 0 bits in that range.
         * @link    http://redis.io/commands/bitpos
         * @example
         * <pre>
         * $redis->set('key', '\xff\xff');
         * $redis->bitpos('key', 1); // int(0)
         * $redis->bitpos('key', 1, 1); // int(8)
         * $redis->bitpos('key', 1, 3); // int(-1)
         * $redis->bitpos('key', 0); // int(16)
         * $redis->bitpos('key', 0, 1); // int(16)
         * $redis->bitpos('key', 0, 1, 5); // int(-1)
         * </pre>
         */
        public function bitpos( $key, $bit, $start = 0, $end = null) {}
    
        /**
         * 从更大的字符串中返回一个位
         *
         * @param   string  $key
         * @param   int     $offset
         * @return  int:    the bit value (0 or 1)
         * @link    http://redis.io/commands/getbit
         * @example
         * <pre>
         * $redis->set('key', "\x7f");  // this is 0111 1111
         * $redis->getBit('key', 0);    // 0
         * $redis->getBit('key', 1);    // 1
         * </pre>
         */
        public function getBit( $key, $offset ) {}
    
        /**
         * 更改字符串的单个位。
         *
         * @param   string  $key
         * @param   int     $offset
         * @param   bool|int $value bool or int (1 or 0)
         * @return  int:    0 or 1, the value of the bit before it was set.
         * @link    http://redis.io/commands/setbit
         * @example
         * <pre>
         * $redis->set('key', "*");     // ord("*") = 42 = 0x2f = "0010 1010"
         * $redis->setBit('key', 5, 1); // returns 0
         * $redis->setBit('key', 7, 1); // returns 0
         * $redis->get('key');          // chr(0x2f) = "/" = b("0010 1111")
         * </pre>
         */
        public function setBit( $key, $offset, $value ) {}
    
        /**
         * 计算字符串中的位数。
         *
         * @param   string  $key
         * @return  int     The number of bits set to 1 in the value behind the input key.
         * @link    http://redis.io/commands/bitcount
         * @example
         * <pre>
         * $redis->set('bit', '345'); // // 11 0011  0011 0100  0011 0101
         * var_dump( $redis->bitCount('bit', 0, 0) ); // int(4)
         * var_dump( $redis->bitCount('bit', 1, 1) ); // int(3)
         * var_dump( $redis->bitCount('bit', 2, 2) ); // int(4)
         * var_dump( $redis->bitCount('bit', 0, 2) ); // int(11)
         * </pre>
         */
        public function bitCount( $key ) {}
    
        /**
         * 按键操作多个键。
         *
         * @param   string  $operation  either "AND", "OR", "NOT", "XOR"
         * @param   string  $retKey     return key
         * @param   string  $key1
         * @param   string  $key2
         * @param   string  $key3
         * @return  int     The size of the string stored in the destination key.
         * @link    http://redis.io/commands/bitop
         * @example
         * <pre>
         * $redis->set('bit1', '1'); // 11 0001
         * $redis->set('bit2', '2'); // 11 0010
         *
         * $redis->bitOp('AND', 'bit', 'bit1', 'bit2'); // bit = 110000
         * $redis->bitOp('OR',  'bit', 'bit1', 'bit2'); // bit = 110011
         * $redis->bitOp('NOT', 'bit', 'bit1', 'bit2'); // bit = 110011
         * $redis->bitOp('XOR', 'bit', 'bit1', 'bit2'); // bit = 11
         * </pre>
         */
        public function bitOp( $operation, $retKey, $key1, $key2, $key3 = null ) {}
    
        /**
         * 从当前数据库中删除所有条目。
         *
         * @return  bool: Always TRUE.
         * @link    http://redis.io/commands/flushdb
         * @example $redis->flushDB();
         */
        public function flushDB( ) {}
    
        /**
         * 从所有数据库中删除所有条目。
         *
         * @return  bool: Always TRUE.
         * @link    http://redis.io/commands/flushall
         * @example $redis->flushAll();
         */
        public function flushAll( ) {}
    
        /**
         * 排序
         *
         * @param   string  $key
         * @param   array   $option array(key => value, ...) - optional, with the following keys and values:
         * - 'by' => 'some_pattern_*',
         * - 'limit' => array(0, 1),
         * - 'get' => 'some_other_pattern_*' or an array of patterns,
         * - 'sort' => 'asc' or 'desc',
         * - 'alpha' => TRUE,
         * - 'store' => 'external-key'
         * @return  array
         * An array of values, or a number corresponding to the number of elements stored if that was used.
         * @link    http://redis.io/commands/sort
         * @example
         * <pre>
         * $redis->delete('s');
         * $redis->sadd('s', 5);
         * $redis->sadd('s', 4);
         * $redis->sadd('s', 2);
         * $redis->sadd('s', 1);
         * $redis->sadd('s', 3);
         *
         * var_dump($redis->sort('s')); // 1,2,3,4,5
         * var_dump($redis->sort('s', array('sort' => 'desc'))); // 5,4,3,2,1
         * var_dump($redis->sort('s', array('sort' => 'desc', 'store' => 'out'))); // (int)5
         * </pre>
         */
        public function sort( $key, $option = null ) {}
    
    
        /**
         * 返回字符串和整数的关联数组
         * @param   string   $option    Optional. The option to provide redis.
         * SERVER | CLIENTS | MEMORY | PERSISTENCE | STATS | REPLICATION | CPU | CLASTER | KEYSPACE | COMANDSTATS
         *
         * Returns an associative array of strings and integers, with the following keys:
         * - redis_version
         * - redis_git_sha1
         * - redis_git_dirty
         * - arch_bits
         * - multiplexing_api
         * - process_id
         * - uptime_in_seconds
         * - uptime_in_days
         * - lru_clock
         * - used_cpu_sys
         * - used_cpu_user
         * - used_cpu_sys_children
         * - used_cpu_user_children
         * - connected_clients
         * - connected_slaves
         * - client_longest_output_list
         * - client_biggest_input_buf
         * - blocked_clients
         * - used_memory
         * - used_memory_human
         * - used_memory_peak
         * - used_memory_peak_human
         * - mem_fragmentation_ratio
         * - mem_allocator
         * - loading
         * - aof_enabled
         * - changes_since_last_save
         * - bgsave_in_progress
         * - last_save_time
         * - total_connections_received
         * - total_commands_processed
         * - expired_keys
         * - evicted_keys
         * - keyspace_hits
         * - keyspace_misses
         * - hash_max_zipmap_entries
         * - hash_max_zipmap_value
         * - pubsub_channels
         * - pubsub_patterns
         * - latest_fork_usec
         * - vm_enabled
         * - role
         * @link    http://redis.io/commands/info
         * @return string
         * @example
         * <pre>
         * $redis->info();
         *
         * or
         *
         * $redis->info("COMMANDSTATS"); //Information on the commands that have been run (>=2.6 only)
         * $redis->info("CPU"); // just CPU information from Redis INFO
         * </pre>
         */
        public function info( $option = null ) {}
    
        /**
         * Resets the statistics reported by Redis using the INFO command (`info()` function).
         * These are the counters that are reset:
         *      - Keyspace hits
         *      - Keyspace misses
         *      - Number of commands processed
         *      - Number of connections received
         *      - Number of expired keys
         *
         * @return bool: `TRUE` in case of success, `FALSE` in case of failure.
         * @example $redis->resetStat();
         * @link http://redis.io/commands/config-resetstat
         */
        public function resetStat( ) {}
    
        /**
         * 返回给定键的剩余时间,以秒为单位。
         * If the key doesn't exist, FALSE is returned.
         *
         * @param   string  $key
         * @return  int,    the time left to live in seconds.
         * @link    http://redis.io/commands/ttl
         * @example $redis->ttl('key');
         */
        public function ttl( $key ) {}
    
        /**
         * 返回给定键的剩余时间,以毫秒为单位。
         *
         * If the key doesn't exist, FALSE is returned.
         *
         * @param   string  $key
         * @return  int     the time left to live in milliseconds.
         * @link    http://redis.io/commands/pttl
         * @example $redis->pttl('key');
         */
        public function pttl( $key ) {}
    
        /**
         * 从key中删除到期计时器。
         *
         * @param   string  $key
         * @return  bool:   TRUE if a timeout was removed, FALSE if the key didn’t exist or didn’t have an expiration timer.
         * @link    http://redis.io/commands/persist
         * @example $redis->persist('key');
         */
        public function persist( $key ) {}
    
        /**
         * 在一个原子命令中设置多个键值对。
         * MSETNX only returns TRUE if all the keys were set (see SETNX).
         *
         * @param   array(key => value) $array Pairs: array(key => value, ...)
         * @return  bool    TRUE in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/mset
         * @example
         * <pre>
         * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
         * var_dump($redis->get('key0'));
         * var_dump($redis->get('key1'));
         * // Output:
         * // string(6) "value0"
         * // string(6) "value1"
         * </pre>
         */
        public function mset( array $array ) {}
    
    
        /**
         * 返回所有指定键的值。
         *
         * For every key that does not hold a string value or does not exist,
         * the special value false is returned. Because of this, the operation never fails.
         *
         * @param array $array
         * @return array
         * @link http://redis.io/commands/mget
         * @example
         * <pre>
         * $redis->delete('x', 'y', 'z', 'h');	// remove x y z
         * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
         * $redis->hset('h', 'field', 'value');
         * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
         * // Output:
         * // array(3) {
         * // [0]=>
         * // string(1) "a"
         * // [1]=>
         * // string(1) "b"
         * // [2]=>
         * // string(1) "c"
         * // [3]=>
         * // bool(false)
         * // }
         * </pre>
         */
        public function mget( array $array ) {}
    
        /**
         * @see mset()
         * @param   array $array
         * @return  int 1 (if the keys were set) or 0 (no key was set)
         * @link    http://redis.io/commands/msetnx
         */
        public function msetnx( array $array ) {}
    
        /**
         * 从列表尾部弹出一个值,并将其推送到另一个列表的前面。
         * Also return this value.
         *
         * @since   redis >= 1.1
         * @param   string  $srcKey
         * @param   string  $dstKey
         * @return  string  The element that was moved in case of success, FALSE in case of failure.
         * @link    http://redis.io/commands/rpoplpush
         * @example
         * <pre>
         * $redis->delete('x', 'y');
         *
         * $redis->lPush('x', 'abc');
         * $redis->lPush('x', 'def');
         * $redis->lPush('y', '123');
         * $redis->lPush('y', '456');
         *
         * // move the last of x to the front of y.
         * var_dump($redis->rpoplpush('x', 'y'));
         * var_dump($redis->lRange('x', 0, -1));
         * var_dump($redis->lRange('y', 0, -1));
         *
         * //Output:
         * //
         * //string(3) "abc"
         * //array(1) {
         * //  [0]=>
         * //  string(3) "def"
         * //}
         * //array(3) {
         * //  [0]=>
         * //  string(3) "abc"
         * //  [1]=>
         * //  string(3) "456"
         * //  [2]=>
         * //  string(3) "123"
         * //}
         * </pre>
         */
        public function rpoplpush( $srcKey, $dstKey ) {}
    
        /**
         * A blocking version of rpoplpush, with an integral timeout in the third parameter.
         *
         * @param   string  $srcKey
         * @param   string  $dstKey
         * @param   int     $timeout
         * @return  string  The element that was moved in case of success, FALSE in case of timeout.
         * @link    http://redis.io/commands/brpoplpush
         */
        public function brpoplpush( $srcKey, $dstKey, $timeout ) {}
    
        /**
         * 将具有给定分数的指定成员添加到存储在key中的有序集合。
         *
         * @param   string  $key    Required key
         * @param   float   $score1 Required score
         * @param   string  $value1 Required value
         * @param   float   $score2 Optional score
         * @param   string  $value2 Optional value
         * @param   float   $scoreN Optional score
         * @param   string  $valueN Optional value
         * @return  int     Number of values added
         * @link    http://redis.io/commands/zadd
         * @example
         * <pre>
         * <pre>
         * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
         * $redis->zRem('z', 'v2', 'v3');                           // int(2)
         * var_dump( $redis->zRange('z', 0, -1) );
         *  Output:
         * // array(2) {
         * //   [0]=> string(2) "v1"
         * //   [1]=> string(2) "v4"
         * // }
         * </pre>
         * </pre>
         */
        public function zAdd( $key, $score1, $value1, $score2 = null, $value2 = null, $scoreN = null, $valueN = null ) {}
    
        /**
         * 返回存储在指定键中的有序集合中的元素范围,
         * with values in the range [start, end]. start and stop are interpreted as zero-based indices:
         * 0 the first element,
         * 1 the second ...
         * -1 the last element,
         * -2 the penultimate ...
         *
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @param   bool    $withscores
         * @return  array   Array containing the values in specified range.
         * @link    http://redis.io/commands/zrange
         * @example
         * <pre>
         * $redis->zAdd('key1', 0, 'val0');
         * $redis->zAdd('key1', 2, 'val2');
         * $redis->zAdd('key1', 10, 'val10');
         * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
         * // with scores
         * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
         * </pre>
         */
        public function zRange( $key, $start, $end, $withscores = null ) {}
    
        /**
         * 从有序集中删除指定的成员。
         *
         * @param   string  $key
         * @param   string  $member1
         * @param   string  $member2
         * @param   string  $memberN
         * @return  int     Number of deleted values
         * @link    http://redis.io/commands/zrem
         * @example
         * <pre>
         * $redis->zAdd('z', 1, 'v2', 2, 'v2', 3, 'v3', 4, 'v4' );  // int(2)
         * $redis->zRem('z', 'v2', 'v3');                           // int(2)
         * var_dump( $redis->zRange('z', 0, -1) );
         *  Output:
         * // array(2) {
         * //   [0]=> string(2) "v1"
         * //   [1]=> string(2) "v4"
         * // }
         * </pre>
         */
        public function zRem( $key, $member1, $member2 = null, $memberN = null ) {}
    
        /**
         * @see zRem()
         * @param   string  $key
         * @param   string  $member1
         * @param   string  $member2
         * @param   string  $memberN
         * @return  int     Number of deleted values
         * @link    http://redis.io/commands/zrem
         */
        public function zDelete( $key, $member1, $member2 = null, $memberN = null ) {}
    
        /**
         * 返回存储在[start,end]范围内指定键的有序集的元素
         * in reverse order. start and stop are interpretated as zero-based indices:
         * 0 the first element,
         * 1 the second ...
         * -1 the last element,
         * -2 the penultimate ...
         *
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @param   bool    $withscore
         * @return  array   Array containing the values in specified range.
         * @link    http://redis.io/commands/zrevrange
         * @example
         * <pre>
         * $redis->zAdd('key', 0, 'val0');
         * $redis->zAdd('key', 2, 'val2');
         * $redis->zAdd('key', 10, 'val10');
         * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
         *
         * // with scores
         * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
         * </pre>
         */
        public function zRevRange( $key, $start, $end, $withscore = null ) {}
    
        /**
         * 返回存储在指定键中的有序集的元素,其分数范围为[start,end]。
         *
         * Adding a parenthesis before start or end excludes it from the range.
         * +inf and -inf are also valid limits.
         *
         * zRevRangeByScore returns the same items in reverse order, when the start and end parameters are swapped.
         *
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @param   array   $options Two options are available:
         *                      - withscores => TRUE,
         *                      - and limit => array($offset, $count)
         * @return  array   Array containing the values in specified range.
         * @link    http://redis.io/commands/zrangebyscore
         * @example
         * <pre>
         * $redis->zAdd('key', 0, 'val0');
         * $redis->zAdd('key', 2, 'val2');
         * $redis->zAdd('key', 10, 'val10');
         * $redis->zRangeByScore('key', 0, 3);                                          // array('val0', 'val2')
         * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE);              // array('val0' => 0, 'val2' => 2)
         * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2' => 2)
         * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1));                        // array('val2')
         * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1));  // array('val2' => 2)
         * </pre>
         */
        public function zRangeByScore( $key, $start, $end, array $options = array() ) {}
    
        /**
         * @see zRangeByScore()
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @param   array   $options
    	 *
    	 * @return 	array
         */
        public function zRevRangeByScore( $key, $start, $end, array $options = array() ) {}
    
        /**
         * 假设成员具有相同的分数,则返回有序集合中的lexigraphical范围的成员。
         * The min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values
         * '-' (negative inf) or '+' (positive inf).  The command must be called with either three *or* five
         * arguments or will return FALSE.
         * @param   string  $key    The ZSET you wish to run against.
         * @param   int     $min    The minimum alphanumeric value you wish to get.
         * @param   int     $max    The maximum alphanumeric value you wish to get.
         * @param   int     $offset Optional argument if you wish to start somewhere other than the first element.
         * @param   int     $limit  Optional argument if you wish to limit the number of elements returned.
         * @return  array   Array containing the values in the specified range.
         * @link    http://redis.io/commands/zrangebylex
         * @example
         * <pre>
         * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
         *     $redis->zAdd('key', $char);
         * }
         *
         * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
         * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
         * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
         * </pre>
         */
        public function zRangeByLex( $key, $min, $max, $offset = null, $limit = null ) {}
    
        /**
         * @see zRangeByLex()
         * @param   string  $key
         * @param   int     $min
         * @param   int     $max
         * @param   int     $offset
         * @param   int     $limit
         * @return  array
         * @link    http://redis.io/commands/zrevrangebylex
         */
        public function zRevRangeByLex( $key, $min, $max, $offset = null, $limit = null ) {}
    
        /**
         * Returns the number of elements of the sorted set stored at the specified key which have
         * scores in the range [start,end]. Adding a parenthesis before start or end excludes it
         * from the range. +inf and -inf are also valid limits.
         *
         * @param   string  $key
         * @param   string  $start
         * @param   string  $end
         * @return  int     the size of a corresponding zRangeByScore.
         * @link    http://redis.io/commands/zcount
         * @example
         * <pre>
         * $redis->zAdd('key', 0, 'val0');
         * $redis->zAdd('key', 2, 'val2');
         * $redis->zAdd('key', 10, 'val10');
         * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
         * </pre>
         */
        public function zCount( $key, $start, $end ) {}
    
        /**
         * 删除存储在指定键中的有序集的元素,其分数范围为[start,end]。
         *
         * @param   string          $key
         * @param   float|string    $start double or "+inf" or "-inf" string
         * @param   float|string    $end double or "+inf" or "-inf" string
         * @return  int             The number of values deleted from the sorted set
         * @link    http://redis.io/commands/zremrangebyscore
         * @example
         * <pre>
         * $redis->zAdd('key', 0, 'val0');
         * $redis->zAdd('key', 2, 'val2');
         * $redis->zAdd('key', 10, 'val10');
         * $redis->zRemRangeByScore('key', 0, 3); // 2
         * </pre>
         */
        public function zRemRangeByScore( $key, $start, $end ) {}
    
        /**
         * @see zRemRangeByScore()
         * @param string    $key
         * @param float     $start
         * @param float     $end
         */
        public function zDeleteRangeByScore( $key, $start, $end ) {}
    
        /**
         * 删除存储在指定键中的排序集的元素,其排名在[start,end]范围内。
         *
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @return  int     The number of values deleted from the sorted set
         * @link    http://redis.io/commands/zremrangebyrank
         * @example
         * <pre>
         * $redis->zAdd('key', 1, 'one');
         * $redis->zAdd('key', 2, 'two');
         * $redis->zAdd('key', 3, 'three');
         * $redis->zRemRangeByRank('key', 0, 1); // 2
         * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
         * </pre>
         */
        public function zRemRangeByRank( $key, $start, $end ) {}
    
        /**
         * @see zRemRangeByRank()
         * @param   string  $key
         * @param   int     $start
         * @param   int     $end
         * @link    http://redis.io/commands/zremrangebyscore
         */
        public function zDeleteRangeByRank( $key, $start, $end ) {}
    
        /**
         * 返回有序集的基数。
         *
         * @param   string  $key
         * @return  int     the set's cardinality
         * @link    http://redis.io/commands/zsize
         * @example
         * <pre>
         * $redis->zAdd('key', 0, 'val0');
         * $redis->zAdd('key', 2, 'val2');
         * $redis->zAdd('key', 10, 'val10');
         * $redis->zCard('key');            // 3
         * </pre>
         */
        public function zCard( $key ) {}
    
        /**
         * @see zCard()
         * @param string $key
         */
        public function zSize( $key ) {}
    
        /**
         * 返回指定有序集中给定成员的分数。
         *
         * @param   string  $key
         * @param   string  $member
         * @return  float
         * @link    http://redis.io/commands/zscore
         * @example
         * <pre>
         * $redis->zAdd('key', 2.5, 'val2');
         * $redis->zScore('key', 'val2'); // 2.5
         * </pre>
         */
        public function zScore( $key, $member ) {}
    
        /**
         * Returns the rank of a given member in the specified sorted set, starting at 0 for the item
         * with the smallest score. zRevRank starts at 0 for the item with the largest score.
         *
         * @param   string  $key
         * @param   string  $member
         * @return  int     the item's score.
         * @link    http://redis.io/commands/zrank
         * @example
         * <pre>
         * $redis->delete('z');
         * $redis->zAdd('key', 1, 'one');
         * $redis->zAdd('key', 2, 'two');
         * $redis->zRank('key', 'one');     // 0
         * $redis->zRank('key', 'two');     // 1
         * $redis->zRevRank('key', 'one');  // 1
         * $redis->zRevRank('key', 'two');  // 0
         * </pre>
         */
        public function zRank( $key, $member ) {}
    
        /**
         * @see zRank()
         * @param  string $key
         * @param  string $member
         * @return int    the item's score
         * @link   http://redis.io/commands/zrevrank
         */
        public function zRevRank( $key, $member ) {}
    
        /**
         * 按给定数量从排序集中增加成员的分数。
         *
         * @param   string  $key
         * @param   float   $value (double) value that will be added to the member's score
         * @param   string  $member
         * @return  float   the new value
         * @link    http://redis.io/commands/zincrby
         * @example
         * <pre>
         * $redis->delete('key');
         * $redis->zIncrBy('key', 2.5, 'member1');  // key or member1 didn't exist, so member1's score is to 0
         *                                          // before the increment and now has the value 2.5
         * $redis->zIncrBy('key', 1, 'member1');    // 3.5
         * </pre>
         */
        public function zIncrBy( $key, $value, $member ) {}
    
        /**
         * 创建第二个参数中给出的有序集的并集。
         * The result of the union will be stored in the sorted set defined by the first argument.
         * The third optionnel argument defines weights to apply to the sorted sets in input.
         * In this case, the weights will be multiplied by the score of each element in the sorted set
         * before applying the aggregation. The forth argument defines the AGGREGATE option which
         * specify how the results of the union are aggregated.
         *
         * @param string    $Output
         * @param array     $ZSetKeys
         * @param array     $Weights
         * @param string    $aggregateFunction  Either "SUM", "MIN", or "MAX": defines the behaviour to use on
         * duplicate entries during the zUnion.
         * @return int The number of values in the new sorted set.
         * @link    http://redis.io/commands/zunionstore
         * @example
         * <pre>
         * $redis->delete('k1');
         * $redis->delete('k2');
         * $redis->delete('k3');
         * $redis->delete('ko1');
         * $redis->delete('ko2');
         * $redis->delete('ko3');
         *
         * $redis->zAdd('k1', 0, 'val0');
         * $redis->zAdd('k1', 1, 'val1');
         *
         * $redis->zAdd('k2', 2, 'val2');
         * $redis->zAdd('k2', 3, 'val3');
         *
         * $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
         *
         * // Weighted zUnion
         * $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
         * $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
         * </pre>
         */
        public function zUnion($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM') {}
    
        /**
         * 创建第二个参数中给出的排序集的交集。
         * The result of the union will be stored in the sorted set defined by the first argument.
         * The third optional argument defines weights to apply to the sorted sets in input.
         * In this case, the weights will be multiplied by the score of each element in the sorted set
         * before applying the aggregation. The forth argument defines the AGGREGATE option which
         * specify how the results of the union are aggregated.
         *
         * @param   string  $Output
         * @param   array   $ZSetKeys
         * @param   array   $Weights
         * @param   string  $aggregateFunction Either "SUM", "MIN", or "MAX":
         * defines the behaviour to use on duplicate entries during the zInter.
         * @return  int     The number of values in the new sorted set.
         * @link    http://redis.io/commands/zinterstore
         * @example
         * <pre>
         * $redis->delete('k1');
         * $redis->delete('k2');
         * $redis->delete('k3');
         *
         * $redis->delete('ko1');
         * $redis->delete('ko2');
         * $redis->delete('ko3');
         * $redis->delete('ko4');
         *
         * $redis->zAdd('k1', 0, 'val0');
         * $redis->zAdd('k1', 1, 'val1');
         * $redis->zAdd('k1', 3, 'val3');
         *
         * $redis->zAdd('k2', 2, 'val1');
         * $redis->zAdd('k2', 3, 'val3');
         *
         * $redis->zInter('ko1', array('k1', 'k2'));               // 2, 'ko1' => array('val1', 'val3')
         * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1));  // 2, 'ko2' => array('val1', 'val3')
         *
         * // Weighted zInter
         * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
         * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
         * </pre>
         */
        public function zInter($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM') {}
    
        /**
         * 扫描成员的有序集,具有可选的模式和计数。
         * @param   string  $key        String, the set to scan.
         * @param   int     $iterator   Long (reference), initialized to NULL.
         * @param   string  $pattern    String (optional), the pattern to match.
         * @param   int     $count      How many keys to return per iteration (Redis might return a different number).
         * @return  array   PHPRedis will return matching keys from Redis, or FALSE when iteration is complete.
         * @link    http://redis.io/commands/zscan
         * @example
         * <pre>
         * $iterator = null;
         * while ($members = $redis-zscan('zset', $iterator)) {
         *     foreach ($members as $member => $score) {
         *         echo $member . ' => ' . $score . PHP_EOL;
         *     }
         * }
         * </pre>
         */
        public function zScan( $key, &$iterator, $pattern = null, $count = 0 ) {}
    
        /**
         * 为key中存储的哈希值添加一个值。 如果此值已在散列中,则返回FALSE。
         *
         * @param string $key
         * @param string $hashKey
         * @param string $value
         * @return int
         * 1 if value didn't exist and was added successfully,
         * 0 if the value was already present and was replaced, FALSE if there was an error.
         * @link    http://redis.io/commands/hset
         * @example
         * <pre>
         * $redis->delete('h')
         * $redis->hSet('h', 'key1', 'hello');  // 1, 'key1' => 'hello' in the hash at "h"
         * $redis->hGet('h', 'key1');           // returns "hello"
         *
         * $redis->hSet('h', 'key1', 'plop');   // 0, value was replaced.
         * $redis->hGet('h', 'key1');           // returns "plop"
         * </pre>
         */
        public function hSet( $key, $hashKey, $value ) {}
    
        /**
         * 仅当此字段不在散列中时,才向key中存储的散列添加值。
         *
         * @param   string  $key
         * @param   string  $hashKey
         * @param   string  $value
         * @return  bool    TRUE if the field was set, FALSE if it was already present.
         * @link    http://redis.io/commands/hsetnx
         * @example
         * <pre>
         * $redis->delete('h')
         * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
         * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
         * wasn't replaced.
         * </pre>
         */
        public function hSetNx( $key, $hashKey, $value ) {}
    
        /**
         * 从key中存储的哈希值中获取一个值。
         * If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
         *
         * @param   string  $key
         * @param   string  $hashKey
         * @return  string  The value, if the command executed successfully BOOL FALSE in case of failure
         * @link    http://redis.io/commands/hget
         */
        public function hGet($key, $hashKey) {}
    
        /**
         * 以元素个数返回哈希的长度
         *
         * @param   string  $key
         * @return  int     the number of items in a hash, FALSE if the key doesn't exist or isn't a hash.
         * @link    http://redis.io/commands/hlen
         * @example
         * <pre>
         * $redis->delete('h')
         * $redis->hSet('h', 'key1', 'hello');
         * $redis->hSet('h', 'key2', 'plop');
         * $redis->hLen('h'); // returns 2
         * </pre>
         */
        public function hLen( $key ) {}
    
        /**
         * 从key中存储的哈希中删除值。
         * If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
         *
         * @param   string  $key
         * @param   string  $hashKey1
         * @param   string  $hashKey2
         * @param   string  $hashKeyN
         * @return  int     Number of deleted fields
         * @link    http://redis.io/commands/hdel
         * @example
         * <pre>
         * $redis->hMSet('h',
         *               array(
         *                    'f1' => 'v1',
         *                    'f2' => 'v2',
         *                    'f3' => 'v3',
         *                    'f4' => 'v4',
         *               ));
         *
         * var_dump( $redis->hDel('h', 'f1') );        // int(1)
         * var_dump( $redis->hDel('h', 'f2', 'f3') );  // int(2)
         * s
         * var_dump( $redis->hGetAll('h') );
         *  Output:
         * //  array(1) {
         * //    ["f4"]=> string(2) "v4"
         * //  }
         * </pre>
         */
        public function hDel( $key, $hashKey1, $hashKey2 = null, $hashKeyN = null ) {}
    
        /**
         * 返回哈希中的键,作为字符串数组。
         *
         * @param   string  $key
         * @return  array   An array of elements, the keys of the hash. This works like PHP's array_keys().
         * @link    http://redis.io/commands/hkeys
         * @example
         * <pre>
         * $redis->delete('h');
         * $redis->hSet('h', 'a', 'x');
         * $redis->hSet('h', 'b', 'y');
         * $redis->hSet('h', 'c', 'z');
         * $redis->hSet('h', 'd', 't');
         * var_dump($redis->hKeys('h'));
         *
         * // Output:
         * // array(4) {
         * // [0]=>
         * // string(1) "a"
         * // [1]=>
         * // string(1) "b"
         * // [2]=>
         * // string(1) "c"
         * // [3]=>
         * // string(1) "d"
         * // }
         * // The order is random and corresponds to redis' own internal representation of the set structure.
         * </pre>
         */
        public function hKeys( $key ) {}
    
        /**
         * 以字符串数组的形式返回哈希值。
         *
         * @param   string  $key
         * @return  array   An array of elements, the values of the hash. This works like PHP's array_values().
         * @link    http://redis.io/commands/hvals
         * @example
         * <pre>
         * $redis->delete('h');
         * $redis->hSet('h', 'a', 'x');
         * $redis->hSet('h', 'b', 'y');
         * $redis->hSet('h', 'c', 'z');
         * $redis->hSet('h', 'd', 't');
         * var_dump($redis->hVals('h'));
         *
         * // Output
         * // array(4) {
         * //   [0]=>
         * //   string(1) "x"
         * //   [1]=>
         * //   string(1) "y"
         * //   [2]=>
         * //   string(1) "z"
         * //   [3]=>
         * //   string(1) "t"
         * // }
         * // The order is random and corresponds to redis' own internal representation of the set structure.
         * </pre>
         */
        public function hVals( $key ) {}
    
        /**
         * 返回整个哈希,作为由字符串索引的字符串数组。
         *
         * @param   string  $key
         * @return  array   An array of elements, the contents of the hash.
         * @link    http://redis.io/commands/hgetall
         * @example
         * <pre>
         * $redis->delete('h');
         * $redis->hSet('h', 'a', 'x');
         * $redis->hSet('h', 'b', 'y');
         * $redis->hSet('h', 'c', 'z');
         * $redis->hSet('h', 'd', 't');
         * var_dump($redis->hGetAll('h'));
         *
         * // Output:
         * // array(4) {
         * //   ["a"]=>
         * //   string(1) "x"
         * //   ["b"]=>
         * //   string(1) "y"
         * //   ["c"]=>
         * //   string(1) "z"
         * //   ["d"]=>
         * //   string(1) "t"
         * // }
         * // The order is random and corresponds to redis' own internal representation of the set structure.
         * </pre>
         */
        public function hGetAll( $key ) {}
    
        /**
         * 验证key中是否存在指定的成员。
         *
         * @param   string  $key
         * @param   string  $hashKey
         * @return  bool:   If the member exists in the hash table, return TRUE, otherwise return FALSE.
         * @link    http://redis.io/commands/hexists
         * @example
         * <pre>
         * $redis->hSet('h', 'a', 'x');
         * $redis->hExists('h', 'a');               //  TRUE
         * $redis->hExists('h', 'NonExistingKey');  // FALSE
         * </pre>
         */
        public function hExists( $key, $hashKey ) {}
    
        /**
         * 将散列中的成员值增加给定量。
         *
         * @param   string  $key
         * @param   string  $hashKey
         * @param   int     $value (integer) value that will be added to the member's value
         * @return  int     the new value
         * @link    http://redis.io/commands/hincrby
         * @example
         * <pre>
         * $redis->delete('h');
         * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
         * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
         * </pre>
         */
        public function hIncrBy( $key, $hashKey, $value ) {}
    
        /**
         * 按给定量增加散列字段的浮点值
         * @param   string  $key
         * @param   string  $field
         * @param   float   $increment
         * @return  float
         * @link    http://redis.io/commands/hincrbyfloat
         * @example
         * <pre>
         * $redis = new Redis();
         * $redis->connect('127.0.0.1');
         * $redis->hset('h', 'float', 3);
         * $redis->hset('h', 'int',   3);
         * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
         *
         * var_dump( $redis->hGetAll('h') );
         *
         * // Output
         *  array(2) {
         *    ["float"]=>
         *    string(3) "4.5"
         *    ["int"]=>
         *    string(1) "3"
         *  }
         * </pre>
         */
        public function hIncrByFloat( $key, $field, $increment ) {}
    
        /**
         * 填写一个完整的哈希。 使用标准(字符串)强制转换将非字符串值转换为字符串。
         * NULL values are stored as empty strings
         *
         * @param   string  $key
         * @param   array   $hashKeys key → value array
         * @return  bool
         * @link    http://redis.io/commands/hmset
         * @example
         * <pre>
         * $redis->delete('user:1');
         * $redis->hMSet('user:1', array('name' => 'Joe', 'salary' => 2000));
         * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
         * </pre>
         */
        public function hMSet( $key, $hashKeys ) {}
    
        /**
         * 检索与哈希中指定字段关联的值。
         *
         * @param   string  $key
         * @param   array   $hashKeys
         * @return  array   Array An array of elements, the values of the specified fields in the hash,
         * with the hash keys as array keys.
         * @link    http://redis.io/commands/hmget
         * @example
         * <pre>
         * $redis->delete('h');
         * $redis->hSet('h', 'field1', 'value1');
         * $redis->hSet('h', 'field2', 'value2');
         * $redis->hmGet('h', array('field1', 'field2')); // returns array('field1' => 'value1', 'field2' => 'value2')
         * </pre>
         */
        public function hMGet( $key, $hashKeys ) {}
    
        /**
         * 使用可选的模式和计数扫描成员的HASH值。
         * @param   string    $key
         * @param   int       $iterator
         * @param   string    $pattern    Optional pattern to match against.
         * @param   int       $count      How many keys to return in a go (only a sugestion to Redis).
         * @return  array     An array of members that match our pattern.
         * @link    http://redis.io/commands/hscan
         * @example
         * <pre>
         * // $iterator = null;
         * // while($elements = $redis->hscan('hash', $iterator)) {
         * //     foreach($elements as $key => $value) {
         * //         echo $key . ' => ' . $value . PHP_EOL;
         * //     }
         * // }
         * </pre>
         */
        public function hScan( $key, &$iterator, $pattern = null, $count = 0 ) {}
    
    
        /**
         * 获取或设置redis配置密钥。
         *
         * @param   string  $operation  either `GET` or `SET`
         * @param   string  $key        for `SET`, glob-pattern for `GET`. See http://redis.io/commands/config-get for examples.
         * @param   string  $value      optional string (only for `SET`)
         * @return  array   Associative array for `GET`, key -> value
         * @link    http://redis.io/commands/config-get
         * @link    http://redis.io/commands/config-set
         * @example
         * <pre>
         * $redis->config("GET", "*max-*-entries*");
         * $redis->config("SET", "dir", "/var/run/redis/dumps/");
         * </pre>
         */
        public function config( $operation, $key, $value ) {}
    
        /**
         * @see eval()
         * @param   string  $script
         * @param   array   $args
         * @param   int     $numKeys
         * @return  mixed   @see eval()
         */
        public function evaluate( $script, $args = array(), $numKeys = 0 ) {}
    
        /**
         * Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself.
         * In order to run this command Redis will have to have already loaded the script, either by running it or via
         * the SCRIPT LOAD command.
         * @param   string  $scriptSha
         * @param   array   $args
         * @param   int     $numKeys
         * @return  mixed   @see eval()
         * @see     eval()
         * @link    http://redis.io/commands/evalsha
         * @example
         * <pre>
         * $script = 'return 1';
         * $sha = $redis->script('load', $script);
         * $redis->evalSha($sha); // Returns 1
         * </pre>
         */
        public function evalSha( $scriptSha, $args = array(), $numKeys = 0 ) {}
    
        /**
         * @see evalSha()
         * @param string $scriptSha
         * @param array  $args
         * @param int    $numKeys
         */
        public function evaluateSha( $scriptSha, $args = array(), $numKeys = 0 ) {}
    
        /**
         * 执行Redis SCRIPT命令以对脚本子系统执行各种操作。
         * @param   string  $command load | flush | kill | exists
         * @param   string  $script
         * @return  mixed
         * @link    http://redis.io/commands/script-load
         * @link    http://redis.io/commands/script-kill
         * @link    http://redis.io/commands/script-flush
         * @link    http://redis.io/commands/script-exists
         * @example
         * <pre>
         * $redis->script('load', $script);
         * $redis->script('flush');
         * $redis->script('kill');
         * $redis->script('exists', $script1, [$script2, $script3, ...]);
         * </pre>
         *
         * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure.
         * SCRIPT FLUSH should always return TRUE
         * SCRIPT KILL will return true if a script was able to be killed and false if not
         * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script
         */
        public function script( $command, $script ) {}
    
        /**
         * 最后一条错误消息(如果有的话)
         * @return  string  A string with the last returned script based error message, or NULL if there is no error
         * @example
         * <pre>
         * $redis->eval('this-is-not-lua');
         * $err = $redis->getLastError();
         * // "ERR Error compiling script (new function): user_script:1: '=' expected near '-'"
         * </pre>
         */
        public function getLastError() {}
    
        /**
         * 清除最后一条错误消息
         *
         * @return bool true
         * @example
         * <pre>
         * $redis->set('x', 'a');
         * $redis->incr('x');
         * $err = $redis->getLastError();
         * // "ERR value is not an integer or out of range"
         * $redis->clearLastError();
         * $err = $redis->getLastError();
         * // NULL
         * </pre>
         */
        public function clearLastError() {}
    
        /**
         * 一种实用方法,用于为值添加phpredis的前缀设置。
         * @param   mixed   $value  The value you wish to prefix
         * @return  string  If a prefix is set up, the value now prefixed.  If there is no prefix, the value will be returned unchanged.
         * @example
         * <pre>
         * $redis->setOption(Redis::OPT_PREFIX, 'my-prefix:');
         * $redis->_prefix('my-value'); // Will return 'my-prefix:my-value'
         * </pre>
         */
        public function _prefix( $value ) {}
    
        /**
         * A utility method to unserialize data with whatever serializer is set up.  If there is no serializer set, the
         * value will be returned unchanged.  If there is a serializer set up, and the data passed in is malformed, an
         * exception will be thrown. This can be useful if phpredis is serializing values, and you return something from
         * redis in a LUA script that is serialized.
         * @param   string  $value  The value to be unserialized
         * @return mixed
         * @example
         * <pre>
         * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
         * $redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)
         * </pre>
         */
        public function _unserialize( $value ) {}
    
        /**
         * A utility method to serialize values manually. This method allows you to serialize a value with whatever
         * serializer is configured, manually. This can be useful for serialization/unserialization of data going in
         * and out of EVAL commands as phpredis can't automatically do this itself.  Note that if no serializer is
         * set, phpredis will change Array values to 'Array', and Objects to 'Object'.
         * @param   mixed   $value  The value to be serialized.
         * @return  mixed
         * @example
         * <pre>
         * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
         * $redis->_serialize("foo"); // returns "foo"
         * $redis->_serialize(Array()); // Returns "Array"
         * $redis->_serialize(new stdClass()); // Returns "Object"
         *
         * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
         * $redis->_serialize("foo"); // Returns 's:3:"foo";'
         * </pre>
         */
        public function _serialize( $value ) {}
    
        /**
         * 从Redis数据库转储密钥,稍后可以使用RESTORE命令将其值传递给redis。
         * The data that comes out of DUMP is a binary representation of the key as Redis stores it.
         * @param   string  $key
         * @return  string  The Redis encoded value of the key, or FALSE if the key doesn't exist
         * @link    http://redis.io/commands/dump
         * @example
         * <pre>
         * $redis->set('foo', 'bar');
         * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
         * </pre>
         */
        public function dump( $key ) {}
    
        /**
         * 从DUMP操作的结果中恢复密钥。
         *
         * @param   string  $key    The key name
         * @param   int     $ttl    How long the key should live (if zero, no expire will be set on the key)
         * @param   string  $value  (binary).  The Redis encoded key value (from DUMP)
         * @return  bool
         * @link    http://redis.io/commands/restore
         * @example
         * <pre>
         * $redis->set('foo', 'bar');
         * $val = $redis->dump('foo');
         * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
         * </pre>
         */
        public function restore( $key, $ttl, $value ) {}
    
        /**
         * 将密钥迁移到其他Redis实例。
         *
         * @param   string  $host       The destination host
         * @param   int     $port       The TCP port to connect to.
         * @param   string  $key        The key to migrate.
         * @param   int     $db         The target DB.
         * @param   int     $timeout    The maximum amount of time given to this transfer.
         * @param   bool    $copy       Should we send the COPY flag to redis.
         * @param   bool    $replace    Should we send the REPLACE flag to redis.
         * @return  bool
         * @link    http://redis.io/commands/migrate
         * @example
         * <pre>
         * $redis->migrate('backup', 6379, 'foo', 0, 3600);
         * </pre>
         */
        public function migrate( $host, $port, $key, $db, $timeout, $copy = false, $replace = false ) {}
    
        /**
         * 返回当前Redis服务器时间。
         * @return  array If successfull, the time will come back as an associative array with element zero being the
         * unix timestamp, and element one being microseconds.
         * @link    http://redis.io/commands/time
         * @example
         * <pre>
         * var_dump( $redis->time() );
         * // array(2) {
         * //   [0] => string(10) "1342364352"
         * //   [1] => string(6) "253002"
         * // }
         * </pre>
         */
        public function time() {}
    
        /**
         * 扫描密钥空间以获取密钥.
         * @param  int    $iterator Iterator, initialized to NULL.
         * @param  string $pattern  Pattern to match.
         * @param  int    $count    Count of keys per iteration (only a suggestion to Redis).
         * @return array            This function will return an array of keys or FALSE if there are no more keys.
         * @link   http://redis.io/commands/scan
         * @example
         * <pre>
         * $iterator = null;
         * while($keys = $redis->scan($iterator)) {
         *     foreach($keys as $key) {
         *         echo $key . PHP_EOL;
         *     }
         * }
         * </pre>
         */
        public function scan( &$iterator, $pattern = null, $count = 0 ) {}
    
        /**
         * 将所有元素参数添加到存储在密钥中的HyperLogLog数据结构。
         * @param   string  $key
         * @param   array   $elements
         * @return  bool
         * @link    http://redis.io/commands/pfadd
         * @example $redis->pfAdd('key', array('elem1', 'elem2'))
         */
        public function pfAdd( $key, array $elements ) {}
    
        /**
         * When called with a single key, returns the approximated cardinality computed by the HyperLogLog data
         * structure stored at the specified variable, which is 0 if the variable does not exist.
         * @param   string|array    $key
         * @return  int
         * @link    http://redis.io/commands/pfcount
         * @example
         * <pre>
         * $redis->pfAdd('key1', array('elem1', 'elem2'));
         * $redis->pfAdd('key2', array('elem3', 'elem2'));
         * $redis->pfCount('key1'); // int(2)
         * $redis->pfCount(array('key1', 'key2')); // int(3)
         */
        public function pfCount( $key ) {}
    
        /**
         * Merge multiple HyperLogLog values into an unique value that will approximate the cardinality
         * of the union of the observed Sets of the source HyperLogLog structures.
         * @param   string  $destkey
         * @param   array   $sourcekeys
         * @return  bool
         * @link    http://redis.io/commands/pfmerge
         * @example
         * <pre>
         * $redis->pfAdd('key1', array('elem1', 'elem2'));
         * $redis->pfAdd('key2', array('elem3', 'elem2'));
         * $redis->pfMerge('key3', array('key1', 'key2'));
         * $redis->pfCount('key3'); // int(3)
         */
        public function pfMerge( $destkey, array $sourcekeys ) {}
    
        /**
         * 将任意内容发送到redis服务器。
         * @param   string      $command    Required command to send to the server.
         * @param   mixed,...   $arguments  Optional variable amount of arguments to send to the server.
         * @return  mixed
         * @example
         * <pre>
         * $redis->rawCommand('SET', 'key', 'value'); // bool(true)
         * $redis->rawCommand('GET", 'key'); // string(5) "value"
         * </pre>
         */
        public function rawCommand( $command, $arguments ) {}
    
        /**
         * 检测我们是否处于ATOMIC / MULTI / PIPELINE模式。
         * @return  int     Either Redis::ATOMIC, Redis::MULTI or Redis::PIPELINE
         * @example $redis->getMode();
         */
        public function getMode() {}
    }
    
    class RedisException extends Exception {}
    
    class RedisArray {
        /**
         * Constructor
         *
         * @param   string  $name   Name of the redis array to create (required if using redis.ini to define array)
         * @param   array   $hosts  Array of hosts to construct the array with
         * @param   array   $opts   Array of options
         * @link    https://github.com/nicolasff/phpredis/blob/master/arrays.markdown
         */
        function __construct($name = '', array $hosts = NULL, array $opts = NULL) {}
    
        /**
         * @return  array   所选阵列的主机列表
         */
        public function _hosts() {}
    
        /**
         * @return  string  用于在一致性散列期间提取关键部分的函数的名称
         */
        public function _function() {}
    
        /**
         * @param   $ key要查找主机的密钥
         * @return  string  the host to be used for a certain key
         */
        public function _target($key) {}
    
        /**
         * 添加新节点并且需要重新键入键时使用此功能。
         */
        public function _rehash() {}
    }
    

     

    展开全文
  • 主要介绍了CentOS环境下安装Redis3.0及phpredis扩展测试,结合实例形式分析了CentOS下Redis安装相关步骤、命令及phpredis扩展的测试代码,需要的朋友可以参考下
  • 主要介绍了Ubuntu18.04系统安装、配置Redis及phpredis扩展操作,结合实例形式分析了Ubuntu18.04系统安装、配置Redis及phpredis扩展的相关原理、步骤、配置命令与操作注意事项,需要的朋友可以参考下
  • 主要介绍了linux平台编译安装PHP7并安装Redis扩展与Swoole扩展的方法,结合实例形式详细分析了Linux平台上安装php7并安装Redis扩展与Swoole扩展的具体步骤与操作技巧,需要的朋友可以参考下
  • 主要介绍了PHP7安装Redis扩展的方法,简单分析了Linux与Windows平台Redis扩展的安装方法,并提供了一个实例进一步分析php操作Redis的相关技巧,需要的朋友可以参考下
  • 背景 一个高并发(预估1000并发量,实际达到6000并发量)的项目,要用到云数据库进行数据同步。Redis要比RDS(MySQL)的读写性能高很多倍,而且相同最大连接...而通过镜像配置的PHP并没有Redis扩展,需要自行安装扩展...

    背景

    一个高并发(预估1000并发量,实际达到6000并发量)的项目,要用到云数据库进行数据同步。Redis要比RDS(MySQL)的读写性能高很多倍,而且相同最大连接数Redis的价格要比RDS便宜近百倍。所以,选择Redis来做云数据库。

     

    分析

    后端选择SLB配12台ECS服务器,为节省时间肯定要通过镜像市场来做系统镜像。而通过镜像配置的PHP并没有Redis扩展,需要自行安装扩展文件。所以,需要总结一套为ECS安装Redis的方法流程,对节省配置服务器时间非常重要。

     

    解决方法

    第一步:配置镜像,PHP版本。

    操作方法见《阿里云负载均衡SLB配置方法——附实例操作说明》,PHP版本习惯性的选择5.6.30。

     

    第二步,根据phpinfo,下载Redis。

    下载地址:注意php版本号

    http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/

    http://windows.php.net/downloads/pecl/releases/igbinary/2.0.1/

    由于版本比较老,已经无法下载,我整理上传到CSDN可以下载到。扩展文件下载地址:https://download.csdn.net/download/gaofei880219/10927313

     

    第三步,给php配置Redis扩展。

     解压缩后,将php_redis.dll、php_redis.pdb和php_redis.dll、php_redis.pdb复制至php的ext目录下,注意php版本号。

     

    第四步,修改php.ini。

    在该文件中加入:

    ; php_redis

    extension=php_igbinary.dll

    extension=php_redis.dll

    注意:extension=php_igbinary.dll一定要放在extension=php_redis.dll的前面,否则此扩展不会生效。

     

    第五步,重启Apache后,使用phpinfo查看扩展是否成功安装。

     

    BTW

    1、镜像里有多个php版本,注意复制扩展文件到制定的文件夹里;

    2、php的线程安全分TS和NTS,注意选择相对应的扩展文件。

     

    参考链接

    Apache配置php redis扩展:https://www.cnblogs.com/web-fusheng/p/7259151.html

    展开全文
  • 点击上方蓝色字体,选择“标星公众号”优质文章,第一时间送达上一篇:这300G的Java资料是我师傅当年给我的,...主要内容本文的主要内容为对比Redis的两个框架:Jedis与Redisson,分析各自的优势与缺点,为项目中Jav...

    点击上方蓝色字体,选择“标星公众号”

    优质文章,第一时间送达

    上一篇:这300G的Java资料是我师傅当年给我的,免费分享给大家(已修复)

    下一篇:昨天分享资料不小心把百度网盘深处的秘密泄露了(已修复)

    作者:McBye

    链接:http://suo.im/6mlfyr

    1.概述

    1.1.主要内容

    本文的主要内容为对比Redis的两个框架:Jedis与Redisson,分析各自的优势与缺点,为项目中Java缓存方案中的Redis编程模型的选择提供参考。

    2. JedisRedisson对比

    2.1. 概况对比

    Jedis是Redis的Java实现的客户端,其API提供了比较全面的Redis命令的支持;Redisson实现了分布式和可扩展的Java数据结构,和Jedis相比,功能较为简单,不支持字符串操作,不支持排序、事务、管道、分区等Redis特性。Redisson的宗旨是促进使用者对Redis的关注分离,从而让使用者能够将精力更集中地放在处理业务逻辑上。

    2.2. 编程模型

    Jedis中的方法调用是比较底层的暴露的Redis的API,也即Jedis中的Java方法基本和Redis的API保持着一致,了解Redis的API,也就能熟练的使用Jedis。而Redisson中的方法则是进行比较高的抽象,每个方法调用可能进行了一个或多个Redis方法调用。

    如下分别为Jedis和Redisson操作的简单示例:

    Jedis设置key-value与set操作:

    Jedis jedis = …;

    jedis.set("key", "value");

    List values = jedis.mget("key", "key2", "key3");

    Redisson操作map:

    Redisson redisson = …

    RMap map = redisson.getMap("my-map"); // implement java.util.Map

    map.put("key", "value");

    map.containsKey("key");

    map.get("key");

    2.3. 可伸缩性

    Jedis使用阻塞的I/O,且其方法调用都是同步的,程序流需要等到sockets处理完I/O才能执行,不支持异步。Jedis客户端实例不是线程安全的,所以需要通过连接池来使用Jedis。

    Redisson使用非阻塞的I/O和基于Netty框架的事件驱动的通信层,其方法调用是异步的。Redisson的API是线程安全的,所以可以操作单个Redisson连接来完成各种操作。

    2.4. 数据结构

    Jedis仅支持基本的数据类型如:String、Hash、List、Set、Sorted Set。

    Redisson不仅提供了一系列的分布式Java常用对象,基本可以与Java的基本数据结构通用,还提供了许多分布式服务,其中包括(BitSet, Set, Multimap, SortedSet, Map, List, Queue, BlockingQueue, Deque, BlockingDeque, Semaphore, Lock, AtomicLong, CountDownLatch, Publish / Subscribe, Bloom filter, Remote service, Spring cache, Executor service, Live Object service, Scheduler service)。

    在分布式开发中,Redisson可提供更便捷的方法。

    2.5. 第三方框架整合

    2.5.1.Redisson提供了和Spring框架的各项特性类似的,以Spring XML的命名空间的方式配置RedissonClient实例和它所支持的所有对象和服务;

    2.5.2Redisson完整的实现了Spring框架里的缓存机制;

    2.5.3.Redisson在Redis的基础上实现了Java缓存标准规范;

    2.5.4.Redisson为Apache Tomcat集群提供了基于Redis的非黏性会话管理功能。该功能支持Apache Tomcat的6、7和8版。

    2.5.5.Redisson还提供了Spring Session会话管理器的实现。

    说句题外话,springboot全家桶技术交流群可以加我微信,但是坑位有限哦,由于忙于工作,有时不能及时回复大家,请多包涵。

    精彩推荐

    1、技术选型:HTTP客户端连接,选择HttpClient还是OkHttp?

    2、聊聊高并发下的接口幂等性

    3、八幅漫画理解使用JWT设计单点登录系统

    4、看完知乎轮子哥的编程之路,我只想说,收下我的膝盖。。。

    5、JVM 性能调优监控工具 jps、jstack、jmap、jhat、jstat、hprof 使用详解

    6、未来有望干掉 Python 和 JavaScript 的编程语言

    7、冒着被开除风险也要给大家看看看这份Spring Cloud 总结

    8、全面了解 Nginx 主要应用场景

    点个在看少个 bug

    展开全文
  • Redis的安装、使用以及php扩展redis并实现php操作redis的一个例子 从结果中可以看出,redis并没有起到作用,后来分析分析,由于之前在redis.conf文件中配置了密码登录redis的限制,现在只需要把redis.conf里面的 ...

    1、下载源码包redis-2.8.21.tar.gz,并将其上传到指定目录/urs/src,然后对其进行解压:

    [root@Slave1pc src]# tar -xvf redis-2.8.21.tar.gz

    进入解压后的目录,并执行下面命令,指定安装目录为/urs/local/redis

    [root@Slave1pc src]# cd redis-2.8.21 

    [root@Slave1pc redis-2.8.21]# make PREFIX=/usr/local/redis install

    安装redis成功后,可以在/usr/local/redis看到一个bin的目录,里面包括了以下文件:

    [root@Slave1pc ~]# cd /usr/local/redis/bin/

    [root@Slave1pc bin]# ls

    redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis-sentinel  redis-server

     

    2、添加redis启动脚本到服务中:

    /etc/rc.d/init.d目录,创建一个文件,名为redis(说明:/etc/rc.d/init.d/目录下的脚本在系统启动的时候某些指定脚本将被执行),然后在文件中添加如下内容:

    [root@Slave1pc ~]# vim /etc/init.d/redis

    #!/bin/bash 

    # Init file for redis 

    # chkconfig: - 80 12 

    # description: redis daemon 

    # processname: redis 

    # config: /etc/redis.conf 

    # pidfile: /var/run/redis.pid 

    source /etc/init.d/functions

    BIN="/usr/local/redis/bin"

    CONFIG="/etc/redis/redis.conf"

    PIDFILE="/var/run/redis.pid"

    ### Read configuration 

    [ -r "$SYSCONFIG" ] && source "$SYSCONFIG"

    RETVAL=0

    prog="redis-server"

    desc="Redis Server"

    start() {

            if [ -e $PIDFILE ];then

                 echo "$desc already running...." 

                 exit 1

            fi

            echo -n $"Starting $desc: " 

            daemon $BIN/$prog $CONFIG

            RETVAL=$?

            echo 

            [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog

            return $RETVAL

    }

    stop() {

            echo -n $"Stop $desc: " 

            killproc $prog

            RETVAL=$?

            echo 

            [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE

            return $RETVAL

    }

    restart() {

            stop

            start

    }

    case "$1" in

      start)

            start

            ;;

      stop)

            stop

            ;;

      restart)

            restart

            ;;

      condrestart)

            [ -e /var/lock/subsys/$prog ] && restart

            RETVAL=$?

            ;;

      status)

            status $prog

            RETVAL=$?

            ;;

       *)

            echo $"Usage: $0 {start|stop|restart|condrestart|status}" 

            RETVAL=1

    esac

    exit $RETVAL

     

    将解压后的redis目录下的配置文件redis.conf拷贝到/etc/redis/redis.conf  (注意要与redis的启动脚本中的路径一致

    [root@Slave1pc ~]# mkdir /etc/redis

    [root@Slave1pc ~]# cp /usr/src/redis-2.8.21/redis.conf  /etc/redis/redis.conf

     

    然后将redis添加到注册服务:

    [root@Slave1pc ~]# chkconfig --add redis 

    [root@Slave1pc ~]# chkconfig redis on

    [root@Slave1pc ~]# chkconfig --list redis

    redis           0:off   1:off   2:on    3:on    4:on    5:on    6:off

    重启redis

    [root@Slave1pc ~]# service redis restart

    Stop Redis Server:                                         [  OK  ]

    Starting Redis Server:                                     [  OK  ]

    查看是否启动成功:

    [root@Slave1pc ~]# ps -ef | grep redis  

    root      2984     1  0 13:40 ?        00:00:00 /usr/local/bin/redis-server 0.0.0.0:6379         

    root      2989  2444  0 13:40 pts/1    00:00:00 grep redis

     

    修改/etc/redis/redis.conf,设置redis进程为后台守护进程,并指定一个密码:

    [root@Slave1pc ~]# vim /etc/redis/6379.conf 

    daemonize yes     //daemonize:是否以后台daemon方式运行

    requirepass  20082009  //设置密码为20082009

    设置完后,需要重启redis才能使设置生效:

    [root@Slave1pc ~]# service redis restart

     

    修改环境变量文件,添加如下内容:

    vim /etc/profile  

    #set redis path

    export REDIS_HOME=/usr/local/redis

    export PATH=${REDIS_HOME}/bin:${PATH}

    通过source /etc/profile 使其立刻生效

     

    3、调用redis-cli的命令进行简单操作(注意是否启动密码验证):

    [root@Slave1pc ~]# redis-cli                

    127.0.0.1:6379> ping

    (error) NOAUTH Authentication required.

    127.0.0.1:6379> auth 20082009   //需要输入密码

    OK

    127.0.0.1:6379> ping

    PONG

    127.0.0.1:6379> set name lebron james

    (error) ERR syntax error

    127.0.0.1:6379> set name "lebron james"  //有空格的字符串需要加“”

    OK

    127.0.0.1:6379> get name

    "lebron james"

    127.0.0.1:6379> set name lebronjames

    OK

    127.0.0.1:6379> get name

    "lebronjames"

    127.0.0.1:6379> 

     

    4、php中扩展redis

    下载php的一个扩展phpredis的源码包phpredis-2.2.4.tar.gz,将其上传到服务器指定位置,对其进行解压,然后进入解压后的目录:

    tar -xvf phpredis-2.2.4.tar.gz

    cd phpredis-2.2.4

    phpize生成configure配置文件

    [root@Slave1pc phpredis-2.2.4]# /usr/local/php/bin/phpize 

    然后执行如下命令:

    [root@Slave1pc phpredis-2.2.4]# ./configure --with-php-config=/usr/local/php/bin/php-config

    [root@Slave1pc phpredis-2.2.4]# make && make install

    配置php支持phpredis,在php.ini文件添加如下内容:

    vim /usr/local/php/lib/php.ini 

    extension=  /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/redis.so

     

    然后重启分别重启nginxphp-fpmredis

    service nginx restart

    service php-fpm restart

    service redis restart

    查看phpinfo(),显示如下,表明php扩展redis成功:


    一个简单的php操作redis的例子:

    <?php
       $redis = new Redis();
       $redis->connect('127.0.0.1', '6379') or die ("Could not to connect to redis"); //或者具体主机的IP地址也行
       $redis->set("test", “php handle redis");
       var_dump($redis->get('test'));
       echo "<br/>";
       $redis->del('test');   //删除赋值
       var_dump($redis->get('test'));
      ?>


    输出结果:


    从结果中可以看出,redis并没有起到作用,后来分析分析,由于之前在redis.conf文件中配置了密码登录redis的限制,现在只需要把redis.conf里面的 requirepass 20082009  这句注释掉即可:#requirepass 20082009,然后重启redisservice redis restart

    再次执行php文件,显示如下结果,表明php操作redis成功:


    Redis主从Master/Slave集群配置:

    Master: 172.16.2.33   6379

    Slave:172.16.2.42  63791

    由于前面已经配置好了masterredis了,现在配置slave只需按照前面的步骤进行即可,简单步骤如下:

    1)将redis的源码包redis-2.8.21.tar.gz通过scp 的方法远程复制到slave主机上,进行解压,进入解压后的文件,执行命令:make PREFIX=/usr/local/redis install,这样就在slave上安装了redis

    2)接着修改环境变量文件:vim etc/profile,添加export REDIS_HOME=/usr/local/redis export PATH=${REDIS_HOME}/bin:${PATH},并通过source使其生效;

    3)然后将master主机上的/etc/init.d/redis 复制到slave对应的目录上,另外把master主机上的/etc/redis/redis.conf文件也复制到slave主机上对应的目录上;

    4)然后修改slave主机上的redis.conf,只需要将 # slaveof <masterip> <masterport> 修改为master对应的IPPORT即可:即修改为:slaveof 172.16.2.33 6379

    5)接着将redis添加到chkconfig列表中:chkconfig --add redischkconfig redis on;然后重启redisservice redis restart

    6)查看master主机上的信息:

    [root@Slave1pc ~]# redis-cli info replication

    # Replication

    role:master

    connected_slaves:1

    slave0:ip=172.16.2.42,port=63791,state=online,offset=924,lag=1

    master_repl_offset:924

    。。。

    查看slave主机上的信息:

    [root@Masterpc ~]# redis-cli -p 63791 info replication

    # Replication

    role:slave

    master_host:172.16.2.33

    master_port:6379

    master_link_status:up

    。。。

    7)写同步测试(master主机上的写入数据同步到slave主机上):

    Master主机上:

    [root@Slave1pc ~]# redis-cli 

    127.0.0.1:6379> set name james

    OK

    127.0.0.1:6379> get name

    "james"

    Slave主机上:

    [root@Masterpc ~]# redis-cli -p 63791

    127.0.0.1:63791> get name

    "james"

    127.0.0.1:63791> set name "lebron james"

    (error) READONLY You can't write against a read only slave. 

    slave开启了只读模式,所以从将不能写入数据,可以保证数据只从主服务器同步至从服务器)

     

    如果需要让slave也能写入数据,需要修改配置文件redis.conf:将slave-read-only yes 修改为slave-read-only no,然后重启redis(这样配置后可以向slave写入数据,但是不会同步到master,如下所示:)

    Slave主机上:

    [root@Masterpc ~]# redis-cli -p 63791   

    127.0.0.1:63791> set name "lebron james"

    OK

    127.0.0.1:63791> get name

    "lebron james"

    Master主机上(slave主机上的数据并没有同步到master上):

    [root@Slave1pc ~]# redis-cli 

    127.0.0.1:6379> get name

    "james"

    127.0.0.1:6379> 



    展开全文
  • 分析Redis Server went away产生的原因

    万次阅读 2019-05-14 18:06:45
    PHP Fatal error: Uncaught RedisException: Redis server went away in /data/php/redis.php:670常见的网络连接...项目对Redis依赖较重,使用phpredis扩展操作Redis, 但频繁出现Redis server went away错误。 常见...
  • 好了,这次是PHP报错,“Redis” not found,要么Redis扩展没装,要么Redis版本不兼容,还要么找不到Redis的默认安装路径。经过排查之后,发现是没装Redis扩展,可能在源码编译的时候,没有加入Redis扩展选项。 备注...
  • 目前项目对Redis依赖较重,使用phpredis扩展操作Redis, 但频繁出现Redis server went away错误。   常见的网络连接错误原因: Network is unreachable 到目标ip无可用路由 非常罕见(断网,或没有网关时...
  • 背景 由于对redis缓存中数据有批量操作,例如预热缓存数据,或者在列表页批量去获取缓存数据,在使用了multi批量提交事务后,发现redis压力...我用php扩展调起redis服务,执行,代码如下: $redis = new redis(); $
  • 主要介绍了PHP Swoole异步Redis客户端实现方法,结合实例形式详细分析php操作Swoole异步Redis客户端相关扩展安装与功能实现技巧,需要的朋友可以参考下
  • 一.提高Redis使用性能秘诀KEY尽量少的原则,能放在1个KEY的就放入1个KEY,KEY开销很大尽量减少与Redis发生的交互...还是O(N),切记滥用,认准每个命令的特性再使用也不迟使用PHP Redis的C语言扩展,性能远远高于P...
  • 好了,这次是PHP报错,“Redis” not found,要么Redis扩展没装,要么Redis版本不兼容,还要么找不到Redis的默认安装路径。经过排查之后,发现是没装Redis扩展,可能在源码编译的时候,没有加入Redis扩展选项。 ...
  • 给我的PHP环境增加了redis扩展。因为网上对php操作redis的实际应用的比较少,所以我结合实际来聊聊redis具体是怎么在PHP项目中使用的。今天就来看看我们常用的取最新几条数据这个例子。 先说明一下需求,一个cms...
  • 10分钟学会缓存redis

    2017-02-24 09:44:00
    其实redis就是这么简单,但大部分教材都说的太过复杂,此文目的就是让复杂的redis变成简单的redis扩展分析深入了解redis。 安装redis时,建议复制一份配置文件再做修改。主要是启用守护进程,设置数据库
  • 一、使用 memcache:如果大家有看过我之前的这篇博客 《memcache 和 memcached 的区别分析》,就会发现,PHP两个扩展中的 memcached 工作的更好,因此这篇博客在使用 memcache 服务时我选择的是 memcached 扩展。...
  • 扩展实现PHP Benchmark

    万次阅读 2013-05-11 15:43:47
    在看Redis慢查询日志实现的过程中,觉得这个功能很有用,能够帮助快速分析出性能问题出处,所以想到为PHP实现这样的功能。 实现思路也是借鉴Redis对于慢查询的处理流程。(此扩展目前仅支持Linux) 此扩展的作用...
  • 6-3 安装PHPredis扩展 6-4 安装Yii2的Redis插件 6-5 扩展SwiftMailer将邮件存储至Redis队列 6-6 扩展SwiftMailer将队列中的邮件进行离线发送 6-7 建立计划任务定时离线发送队列中的邮件 6-8 提交自定义...
  • 备份几篇文章

    2015-09-29 10:33:25
    Redis系列-php怎么通过redis扩展使用redis YYI之Model方法 mysql查询优化 1、Java 全文搜索引擎框架 Lucene 毫无疑问,Lucene是目前最受欢迎的Java全文搜索框架,准确地说,它是一个全文检索引擎的架构,提供了...
  • WinCacheGrind Xdebug分析器 2.PHP集成yaf框架,ZendLoader加速器..等必备的扩展 注意: 1.MySQL默认用户名:root,密码为空 2.MySQL数据库文件存放目录:MySQL\data 3.MariaDB默认用户名:root,密码为空 4.MariaDB...
  • 1. Linux / Nginx / Mysql / Redis 基础平台工具,搭配PHP原生代码不在局限框架选择2.从需求分析、数据结构创建到基础功能开发、程序优化实现完整开发思路3.不仅仅是CDN/Redis数据库索引等常用优化方法更有程序逻辑...
  • 系统在网络环境上线后,网站的安全性是开发...redis的安装及php扩展可参见:https://mp.csdn.net/postedit/89470966 本机的调试环境在上文中windows安装及redis服务器启动都已谈过。 需求分析:我们可以根据访问ip...
  • 只是小小的性能牺牲就能满足调试开发过程中的日志和分析需要,并确保将来的 部署顺利,一旦切换到部署模式则可以迅速提升性能。 ORM :简洁轻巧的ORM实现,配合简单的CURD以及AR模式,让开发效率无处不在。 数据库...
  • 系统性能优化方案

    千次阅读 2017-07-07 17:26:56
    一、性能优化 1. 代码分析 ...使用扩展替换php代码 架构优化Mysql转换成Redis 微服务 二、优化方向的选择 1、 优化重点接口 => 优化有问题的代码 2、 优化语言侧面 => 优化外部调用 3、 重构代码 => 重
  • 初遇项目网络平台架构设计方案 设计者:普金   目录 一 概述…4 二 引言…4 ...缓存高可用(Redis) …6 消息队列高可用(RabbitMQ) …6 高性能…6 高扩展…7 安全性…7 易管理、易维护…8 四 瓶颈分析…9 4...
  • 一、简介 前面讲解的功能开发都是简单的调用API 完成的,没有对数据库进行操作。在接下来的高级功能开发中,需要使用到数据库,所以在这一篇中,将对MySQL 数据库的操作做...可使用标准的PHP Mysql 或PHP Mysqli 扩展
  • 相比redis,nginx的代码量要多几倍,结构也比较复杂,稍后将补充nginx的源码分析。在研究nginx的同时,笔者也开始着手阅读CodeIgniter源码。CodeIgniter是一款非常流行且轻量级的框架。CodeIgniter,设计灵活,扩展...

空空如也

空空如也

1 2 3
收藏数 50
精华内容 20
关键字:

phpredis扩展分析

redis 订阅