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

CI框架中redis緩存相關操作文件示例代碼
來源:易賢網 閱讀:2452 次 日期: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程序設計有所幫助。

更多信息請查看網絡編程
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!

2026上岸·考公考編培訓報班

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久
亚洲性感美女99在线| 欧美在线你懂的| 久久久亚洲高清| 亚洲欧洲中文日韩久久av乱码| 欧美精品一区在线发布| 性欧美8khd高清极品| 一区二区三区高清在线| 在线看不卡av| 亚洲第一成人在线| 韩国av一区二区三区四区| 老司机成人在线视频| 欧美精品国产一区二区| 欧美激情综合色综合啪啪| 欧美视频在线观看视频极品| 欧美顶级大胆免费视频| 午夜欧美不卡精品aaaaa| 日韩午夜av| 一区二区三区欧美视频| 日韩香蕉视频| 亚洲欧美精品在线| 久久av一区二区三区漫画| 午夜精品福利一区二区三区av | 亚洲福利视频一区二区| 伊人婷婷欧美激情| 亚洲激情网址| 亚洲免费在线观看视频| 欧美一区二区视频在线| 美女啪啪无遮挡免费久久网站| 欧美成年人视频| 国产精品大片wwwwww| 好吊日精品视频| 精品999久久久| 中国成人黄色视屏| 久久亚洲国产成人| 国产精品成人v| 尤物精品国产第一福利三区| 妖精成人www高清在线观看| 亚洲男女毛片无遮挡| 久久亚洲一区| 国产欧美日韩在线观看| 亚洲狼人综合| 久久天天躁夜夜躁狠狠躁2022| 欧美三级网页| 亚洲精品国产精品国产自| 性欧美长视频| 国产精品久久福利| 一区二区免费在线播放| 欧美高清视频| 亚洲国产一区二区三区在线播| 午夜日韩在线| 国产三区精品| 久久精品视频在线播放| 欧美另类videos死尸| 一区二区三区中文在线观看| 亚洲欧美成人网| 欧美视频在线一区二区三区| 亚洲另类视频| 欧美日本视频在线| 亚洲日本理论电影| 欧美日本在线一区| 99re成人精品视频| 欧美日韩国产在线观看| 91久久精品国产91性色tv| 毛片av中文字幕一区二区| 国内外成人在线| 久久综合色88| 亚洲国产另类久久精品| 欧美高清视频在线 | 亚洲午夜av在线| 欧美xx视频| 在线中文字幕一区| 国产精品久久久久久久一区探花 | 欧美刺激性大交免费视频| 亚洲电影毛片| 欧美视频在线观看一区二区| 午夜一级在线看亚洲| **欧美日韩vr在线| 欧美日韩一二区| 久久精品主播| 亚洲无亚洲人成网站77777| 国产一区二区三区黄视频| 久久精品女人天堂| 一区二区三区欧美在线| 国产日韩一区二区三区在线播放| 蜜桃av一区二区三区| 久久婷婷人人澡人人喊人人爽 | 国产精品视频免费观看www| 夜夜嗨av一区二区三区中文字幕 | 欧美国产日韩亚洲一区| 午夜精品福利一区二区蜜股av| 国产精品综合av一区二区国产馆| 麻豆国产精品一区二区三区| 一本在线高清不卡dvd | 欧美第一黄网免费网站| 亚洲欧美视频一区二区三区| 亚洲人体一区| 亚洲国产一区二区a毛片| 国产精品亚洲一区| 国产精品v亚洲精品v日韩精品 | 久久久久久久综合狠狠综合| 欧美一级久久久| 久久av在线看| 欧美伦理视频网站| 国产精品久久久久久久久久三级| 国产精品一区二区a| 狠狠色2019综合网| 91久久国产自产拍夜夜嗨| 亚洲精选一区二区| 性欧美暴力猛交69hd| 开元免费观看欧美电视剧网站| 蜜桃av一区二区在线观看| 狠狠色狠狠色综合日日91app| 亚洲大胆美女视频| 99一区二区| 欧美一级久久久| 欧美大秀在线观看| 国产精品一级久久久| 久久国产视频网| 欧美剧在线观看| 国产日韩欧美不卡在线| 亚洲全部视频| 久久亚洲欧美| 国产伦精品免费视频 | 国产亚洲一区精品| 99视频超级精品| 久久一区二区三区av| 国产欧美激情| 一区二区三区国产精品| 欧美91大片| 亚洲成人影音| 国产精品系列在线| 亚洲免费观看视频| 免费成年人欧美视频| 黄色日韩网站视频| 久久九九有精品国产23| 国产欧美日韩视频在线观看| 在线亚洲免费| 欧美性猛交99久久久久99按摩| 亚洲黄色免费电影| 毛片一区二区三区| 在线观看欧美亚洲| 免费人成精品欧美精品| 在线激情影院一区| 免费观看成人| 亚洲蜜桃精久久久久久久| 欧美日韩国产一级| 亚洲欧美区自拍先锋| 国产农村妇女毛片精品久久麻豆| 亚洲一区精品视频| 国模精品一区二区三区| 另类激情亚洲| 一本大道久久a久久精二百| 欧美日韩国产欧美日美国产精品| 亚洲精品免费在线| 欧美色视频日本高清在线观看| 亚洲一区二区三区在线观看视频 | 久久精品1区| 黄色欧美日韩| 欧美精品七区| 久久国产精品99精品国产| 亚洲国产视频一区| 国产精品久久国产三级国电话系列| 亚洲午夜91| 在线成人h网| 欧美视频亚洲视频| 久久久久九九视频| 一区二区三区|亚洲午夜| 国产视频在线观看一区| 欧美激情91| 欧美在线观看视频一区二区| 亚洲免费观看高清完整版在线观看熊 | 夜夜嗨一区二区| 国内免费精品永久在线视频| 欧美日韩999| 久久综合狠狠综合久久综合88| 国产精品99久久久久久久vr | 国产精品日韩高清| 欧美精品97| 美日韩精品视频免费看| 久久久久九九视频| 欧美在线观看视频在线| 亚洲欧美韩国| 亚洲香蕉视频| 国产精品99久久不卡二区| 亚洲人人精品| 亚洲国产三级| 黄色成人免费网站| 国产亚洲成av人在线观看导航| 国产精品初高中精品久久| 男人的天堂成人在线| 欧美自拍偷拍午夜视频| 一区二区三区四区五区在线| 亚洲第一区中文99精品| 永久免费精品影视网站| 国产一区二区精品久久| 狠狠入ady亚洲精品| 国产字幕视频一区二区| 好吊日精品视频| 亚洲欧洲综合另类| 久久久免费观看视频|