中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久

CI框架中redis緩存相關操作文件示例代碼
來源:易賢網 閱讀:2478 次 日期:2016-08-22 15:01:55
溫馨提示:易賢網小編為您整理了“CI框架中redis緩存相關操作文件示例代碼”,方便廣大網友查閱!

本文實例講述了CI框架中redis緩存相關操作文件。分享給大家供大家參考,具體如下:

redis緩存類文件位置:

'ci\system\libraries\Cache\drivers\Cache_redis.php'

<?php

/**

 * CodeIgniter

 *

 * An open source application development framework for PHP 5.2.4 or newer

 *

 * NOTICE OF LICENSE

 *

 * Licensed under the Open Software License version 3.0

 *

 * This source file is subject to the Open Software License (OSL 3.0) that is

 * bundled with this package in the files license.txt / license.rst. It is

 * also available through the world wide web at this URL:

 * http://opensource.org/licenses/OSL-3.0

 * If you did not receive a copy of the license and are unable to obtain it

 * through the world wide web, please send an email to

 * licensing@ellislab.com so we can send you a copy immediately.

 *

 * @package   CodeIgniter

 * @author   EllisLab Dev Team

 * @copyright  Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)

 * @license   http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)

 * @link    http://codeigniter.com

 * @since    Version 3.0

 * @filesource

 */

defined('BASEPATH') OR exit('No direct script access allowed');

/**

 * CodeIgniter Redis Caching Class

 *

 * @package  CodeIgniter

 * @subpackage Libraries

 * @category  Core

 * @author   Anton Lindqvist <anton@qvister.se>

 * @link

 */

class CI_Cache_redis extends CI_Driver

{

  /**

   * Default config

   *

   * @static

   * @var array

   */

  protected static $_default_config = array(

    /*

    'socket_type' => 'tcp',

    'host' => '127.0.0.1',

    'password' => NULL,

    'port' => 6379,

    'timeout' => 0

    */

  );

  /**

   * Redis connection

   *

   * @var Redis

   */

  protected $_redis;

  /**

   * Get cache

   *

   * @param  string like *$key*

   * @return array(hash)

   */

  public function keys($key)

  {

    return $this->_redis->keys($key);

  }

  /**

   * Get cache

   *

   * @param  string Cache ID

   * @return mixed

   */

  public function get($key)

  {

    return $this->_redis->get($key);

  }

  /**

   * mGet cache

   *

   * @param  array  Cache ID Array

   * @return mixed

   */

  public function mget($keys)

  {

    return $this->_redis->mget($keys);

  }

  /**

   * Save cache

   *

   * @param  string $id Cache ID

   * @param  mixed  $data  Data to save

   * @param  int $ttl  Time to live in seconds

   * @param  bool  $raw  Whether to store the raw value (unused)

   * @return bool  TRUE on success, FALSE on failure

   */

  public function save($id, $data, $ttl = 60, $raw = FALSE)

  {

    return ($ttl)

      ? $this->_redis->setex($id, $ttl, $data)

      : $this->_redis->set($id, $data);

  }

  /**

   * Delete from cache

   *

   * @param  string Cache key

   * @return bool

   */

  public function delete($key)

  {

    return ($this->_redis->delete($key) === 1);

  }

  /**

   * hIncrBy a raw value

   *

   * @param  string $id Cache ID

   * @param  string $field Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hincrby($key, $field, $value = 1)

  {

    return $this->_redis->hIncrBy($key, $field, $value);

  }

  /**

   * hIncrByFloat a raw value

   *

   * @param  string $id Cache ID

   * @param  string $field Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hincrbyfloat($key, $field, $value = 1)

  {

    return $this->_redis->hIncrByFloat($key, $field, $value);

  }

  /**

   * lpush a raw value

   *

   * @param  string $key  Cache ID

   * @param  string $value value

   * @return mixed  New value on success or FALSE on failure

   */

  public function lpush($key, $value)

  {

    return $this->_redis->lPush($key, $value);

  }

   /**

   * rpush a raw value

   *

   * @param  string $key  Cache ID

   * @param  string $value value

   * @return mixed  New value on success or FALSE on failure

   */

  public function rpush($key, $value)

  {

    return $this->_redis->rPush($key, $value);

  }

  /**

   * rpop a raw value

   *

   * @param  string $key  Cache ID

   * @param  string $value value

   * @return mixed  New value on success or FALSE on failure

   */

  public function rpop($key)

  {

    return $this->_redis->rPop($key);

  }

   /**

   * brpop a raw value

   *

   * @param  string $key  Cache ID

   * @param  string $ontime 阻塞等待時間

   * @return mixed  New value on success or FALSE on failure

   */

  public function brpop($key,$ontime=0)

  {

    return $this->_redis->brPop($key,$ontime);

  }

  /**

   * lLen a raw value

   *

   * @param  string $key  Cache ID

   * @return mixed  Value on success or FALSE on failure

   */

  public function llen($key)

  {

    return $this->_redis->lLen($key);

  }

  /**

   * Increment a raw value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function increment($id, $offset = 1)

  {

    return $this->_redis->exists($id)

      ? $this->_redis->incr($id, $offset)

      : FALSE;

  }

  /**

   * incrby a raw value

   *

   * @param  string $key Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function incrby($key, $value = 1)

  {

    return $this->_redis->incrby($key, $value);

  }

  /**

   * set a value expire time

   *

   * @param  string $key Cache ID

   * @param  int $seconds expire seconds

   * @return mixed  New value on success or FALSE on failure

   */

  public function expire($key, $seconds)

  {

    return $this->_redis->expire($key, $seconds);

  }

  /**

   * Increment a raw value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hset($alias,$key, $value)

  {

    return $this->_redis->hset($alias,$key, $value);

  }

  /**

   * Increment a raw value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hget($alias,$key)

  {

    return $this->_redis->hget($alias,$key);

  }

  /**

   * Increment a raw value

   *

   * @param  string $id Cache ID

   * @return mixed  New value on success or FALSE on failure

   */

  public function hkeys($alias)

  {

    return $this->_redis->hkeys($alias);

  }

  /**

   * Increment a raw value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hgetall($alias)

  {

    return $this->_redis->hgetall($alias);

  }

  /**

   * Increment a raw value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hmget($alias,$key)

  {

    return $this->_redis->hmget($alias,$key);

  }

  /**

   * del a key value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hdel($alias,$key)

  {

    return $this->_redis->hdel($alias,$key);

  }

  /**

   * del a key value

   *

   * @param  string $id Cache ID

   * @return mixed  New value on success or FALSE on failure

   */

  public function hvals($alias)

  {

    return $this->_redis->hvals($alias);

  }

  /**

   * Increment a raw value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to add

   * @return mixed  New value on success or FALSE on failure

   */

  public function hmset($alias,$array)

  {

    return $this->_redis->hmset($alias,$array);

  }

  /**

   * Decrement a raw value

   *

   * @param  string $id Cache ID

   * @param  int $offset Step/value to reduce by

   * @return mixed  New value on success or FALSE on failure

   */

  public function decrement($id, $offset = 1)

  {

    return $this->_redis->exists($id)

      ? $this->_redis->decr($id, $offset)

      : FALSE;

  }

  /**

   * Clean cache

   *

   * @return bool

   * @see   Redis::flushDB()

   */

  public function clean()

  {

    return $this->_redis->flushDB();

  }

  /**

   * Get cache driver info

   *

   * @param  string Not supported in Redis.

   *     Only included in order to offer a

   *     consistent cache API.

   * @return array

   * @see   Redis::info()

   */

  public function cache_info($type = NULL)

  {

    return $this->_redis->info();

  }

  /**

   * Get cache metadata

   *

   * @param  string Cache key

   * @return array

   */

  public function get_metadata($key)

  {

    $value = $this->get($key);

    if ($value)

    {

      return array(

        'expire' => time() + $this->_redis->ttl($key),

        'data' => $value

      );

    }

    return FALSE;

  }

  /**

   * Check if Redis driver is supported

   *

   * @return bool

   */

  public function is_supported()

  {

    if (extension_loaded('redis'))

    {

      return $this->_setup_redis();

    }

    else

    {

      log_message('debug', 'The Redis extension must be loaded to use Redis cache.');

      return FALSE;

    }

  }

  /**

   * Setup Redis config and connection

   *

   * Loads Redis config file if present. Will halt execution

   * if a Redis connection can't be established.

   *

   * @return bool

   * @see   Redis::connect()

   */

  protected function _setup_redis()

  {

    $config = array();

    $CI =& get_instance();

    if ($CI->config->load('redis', TRUE, TRUE))

    {

      $config += $CI->config->item('redis');

    }

    $config = array_merge(self::$_default_config, $config);

    $config = !empty($config['redis'])?$config['redis']:$config;

    $this->_redis = new Redis();

    try

    {

      if ($config['socket_type'] === 'unix')

      {

        $success = $this->_redis->connect($config['socket']);

      }

      else // tcp socket

      {

        $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']);

      }

      if ( ! $success)

      {

        log_message('debug', 'Cache: Redis connection refused. Check the config.');

        return FALSE;

      }

    }

    catch (RedisException $e)

    {

      log_message('debug', 'Cache: Redis connection refused ('.$e->getMessage().')');

      return FALSE;

    }

    if (isset($config['password']))

    {

      $this->_redis->auth($config['password']);

    }

    return TRUE;

  }

  /**

   * Class destructor

   *

   * Closes the connection to Redis if present.

   *

   * @return void

   */

  public function __destruct()

  {

    if ($this->_redis)

    {

      $this->_redis->close();

    }

  }

}

/* End of file Cache_redis.php */

/* Location: ./system/libraries/Cache/drivers/Cache_redis.php */

希望本文所述對大家基于CodeIgniter框架的PHP程序設計有所幫助。

更多信息請查看網絡編程
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網

中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久
欧美精品在线观看一区二区| 精品制服美女久久| 在线观看中文字幕不卡| 成人综合在线视频| 精品中文字幕一区二区| 日韩高清不卡在线| 天天色天天爱天天射综合| 亚洲综合色噜噜狠狠| 伊人色综合久久天天| 亚洲女性喷水在线观看一区| 国产精品乱码人人做人人爱 | 国产精品另类一区| 国产精品久久久久一区二区三区共| 久久综合九色综合97婷婷女人| 日韩欧美久久一区| 精品对白一区国产伦| 久久久99精品久久| 国产精品网曝门| 亚洲精品大片www| 亚洲成a人v欧美综合天堂| 午夜伦理一区二区| 精品一区二区在线观看| 成人免费精品视频| 欧美三级视频在线| 久久一日本道色综合| 国产欧美日韩综合精品一区二区| 综合亚洲深深色噜噜狠狠网站| 亚洲自拍偷拍图区| 久久国产综合精品| 国产麻豆91精品| 国产成人丝袜美腿| 精品少妇一区二区三区日产乱码| 丰满亚洲少妇av| 日本欧美大码aⅴ在线播放| 精品一区二区免费在线观看| 欧美色倩网站大全免费| 中文字幕日韩av资源站| 在线看不卡av| 国产一区免费电影| 91精品国产综合久久蜜臀| 国产精品美女www爽爽爽| 99久久婷婷国产精品综合| 国产一区二区主播在线| 亚洲va国产va欧美va观看| 亚洲一区二区三区三| 亚洲欧美日韩国产一区二区三区 | 天天色图综合网| 日韩国产欧美一区二区三区| 麻豆传媒一区二区三区| 99亚偷拍自图区亚洲| 7777精品伊人久久久大香线蕉最新版 | 日韩欧美美女一区二区三区| 亚洲欧美日韩国产另类专区| 国产精品久久久久aaaa| 偷拍日韩校园综合在线| 99视频精品免费视频| 日韩网站在线看片你懂的| 夜夜嗨av一区二区三区| 国产成人福利片| 欧美一级xxx| 夜夜嗨av一区二区三区四季av| 国产电影精品久久禁18| 日韩三级伦理片妻子的秘密按摩| ...xxx性欧美| 韩国av一区二区| 欧美精品色综合| 一区二区三区久久| 96av麻豆蜜桃一区二区| 国产午夜精品久久| 精品系列免费在线观看| 欧美一区二区视频在线观看2020| 亚洲欧美电影院| 久久精品国产成人一区二区三区 | av网站一区二区三区| 久久久久久久久岛国免费| 男女性色大片免费观看一区二区| 欧美视频一区二| 一级日本不卡的影视| 99精品视频一区| 亚洲欧洲日产国码二区| 99这里都是精品| 国产精品久久影院| 97久久久精品综合88久久| 国产精品久久二区二区| av成人免费在线观看| 亚洲视频一区在线观看| jlzzjlzz亚洲日本少妇| 亚洲欧洲精品一区二区三区| 成人福利视频在线看| 中文字幕综合网| 91色|porny| 亚洲福利视频导航| 在线综合视频播放| 国内精品伊人久久久久av一坑| 久久理论电影网| av激情成人网| 一区二区三区四区在线播放| 在线免费观看日本欧美| 日日欢夜夜爽一区| 久久综合久久久久88| 不卡在线视频中文字幕| 亚洲精品老司机| 欧美一区二区三区四区视频| 国内精品视频666| 中文字幕在线一区| 欧美唯美清纯偷拍| 美女网站色91| 国产精品久线在线观看| 欧美日韩精品一区二区三区四区| 麻豆成人在线观看| 国产精品久久二区二区| 欧美日韩国产bt| 国产一区二区三区观看| 一区在线中文字幕| 日韩一级大片在线| 99久久精品国产网站| 偷拍自拍另类欧美| 国产精品久久久久影院| 91精品一区二区三区久久久久久 | 久久成人麻豆午夜电影| 国产精品久久影院| 欧美日韩国产首页在线观看| 国产麻豆午夜三级精品| 亚洲综合色婷婷| 国产校园另类小说区| 欧美日韩国产片| 成人动漫av在线| 日本vs亚洲vs韩国一区三区二区| 国产欧美一区二区精品忘忧草| 欧美午夜免费电影| 高清不卡一区二区| 首页欧美精品中文字幕| 国产精品久久久99| 26uuu久久综合| 欧美日韩aaaaaa| av成人动漫在线观看| 国产在线国偷精品产拍免费yy| 亚洲图片有声小说| 国产精品不卡在线观看| 久久影院午夜片一区| 欧美日韩二区三区| 99久久精品免费观看| 国产成人亚洲综合a∨婷婷| 奇米一区二区三区| 婷婷成人激情在线网| 亚洲免费视频中文字幕| 欧美国产成人精品| 精品国产乱码久久久久久久| 欧美精品乱码久久久久久| 色94色欧美sute亚洲线路一久 | 欧美电影免费观看高清完整版在线观看 | 欧美理论电影在线| 色哟哟亚洲精品| 高清不卡一二三区| 国产精品亚洲а∨天堂免在线| 天堂影院一区二区| 一区二区三区欧美在线观看| 国产精品美日韩| 国产喷白浆一区二区三区| 精品欧美一区二区在线观看 | 狠狠色丁香婷婷综合| 日本亚洲三级在线| 婷婷开心久久网| 日韩高清在线观看| 日韩二区在线观看| 午夜成人在线视频| 午夜精品久久久久久久99樱桃| 一区二区三区在线观看视频| 一区二区三区四区激情| 亚洲一区二区成人在线观看| 亚洲高清免费视频| 五月天久久比比资源色| 欧美aⅴ一区二区三区视频| 日本成人在线视频网站| 久久国产成人午夜av影院| 久久精品国产亚洲高清剧情介绍| 美女mm1313爽爽久久久蜜臀| 国内精品视频一区二区三区八戒| 国产综合色在线视频区| 粉嫩av亚洲一区二区图片| 懂色av中文一区二区三区| 99国产麻豆精品| 欧美在线制服丝袜| 欧美精品xxxxbbbb| 亚洲精品一区二区三区蜜桃下载 | 亚洲午夜一二三区视频| 午夜天堂影视香蕉久久| 蜜桃视频第一区免费观看| 久久av资源站| 成人深夜在线观看| 在线一区二区三区做爰视频网站| 在线观看国产精品网站| 欧美日韩成人一区二区| 精品国产免费一区二区三区四区 | 欧美性猛交xxxx黑人交| 欧美成人r级一区二区三区| 国产欧美日韩在线| 亚洲午夜电影在线观看| 精品一区二区三区视频在线观看| 成人av免费在线观看|