<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### **1.String 字符串** * 最常見的數據類型 * 可以為任何類型的字符串,比如二進制,json對象 * 最大容量512M ### **2.常見操作** 1. 賦值 `$redis->set('key','value');` 2. 賦值并添加過期時間 `$redis->setex('key','expire','value');` 3. 取值 `$redis->get('key');` 4. 遞增數字 `$redis->incr('int_key');` 5. 增加指定的數字 `$redis->incrBy('int_key','number');` 6. 遞減數字 `$redis->decr('key1');` 7. 減少指定的數字 `$redis->descBy('key1','number');` 8. 增加指定浮點數 `$redis->incrByFloat('key1',1.5);` 9. 向尾部追加值 `$redis->append('key','value2');` 10. 獲取字符串長度 `$redis->strlen('key');` 11. 同時設置多個key的值 `$redis->mSet(array('key0' => 'value0','key1' => 'value1'));` 12. 同時獲取多個key的值 `$redis->mGet(array('key0','key1'));` ### **3.封裝自己的Redis類** #### 1.編寫 Redis 類 ``` class Redis { private static $write_handle = null; private static $read_handle = null; /**初始化 * @return Redis|null */ public static function getWrite() { $option = array( 'host' => Config::get('cache.REDIS_W_HOST', '127.0.0.1'), 'port' => Config::get('cache.REDIS_W_PORT', '6379'), 'auth' => Config::get('cache.REDIS_W_PASSWORD', '') ); if (!self::$write_handle) { self::$write_handle = new \Redis(); self::$write_handle->connect($option['host'], $option['port']); self::$write_handle->auth($option['auth']); } return self::$write_handle; } public static function getRead() { $option = array( 'host' => Config::get('cache.REDIS_R_HOST', '127.0.0.1'), 'port' => Config::get('cache.REDIS_R_PORT', '6379'), 'auth' => Config::get('cache.REDIS_R_PASSWORD', '') ); if (!self::$read_handle) { self::$read_handle = new \Redis(); self::$read_handle->connect($option['host'], $option['port']); self::$read_handle->auth($option['auth']); } return self::$read_handle; } /** * 存儲 * @param $key * @param $value * @param int $expire */ public static function set($key, $value, $expire = 0) { if (!self::getWrite()) { return false; } if ($expire == 0) { return self::getWrite()->set($key, $value); } else { return self::getWrite()->setex($key, $expire, $value); } } /** * 獲取 * @param $key * @return mixed */ public static function get($key) { $func = is_array($key) ? 'mget' : 'get'; return self::getRead()->{$func}($key); } /**自增 * @param $key * @param int $number * @return false|int */ public static function incr($key, $number = 1) { if (!self::getWrite()) { return false; } if ($number == 1) { return self::getWrite()->incr($key); } else { return self::getWrite()->incrBy($key, $number); } } /**獲取長度 * @param $key * @return int */ public static function strlen($key) { return self::getRead()->strlen(); } } ``` #### 2.調用 ``` \Driver\Cache\Redis::set('user','李四',600); echo \Driver\Cache\Redis::get('user'); ``` ### **5.Zset 可排序集合**
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看