Heim >Backend-Entwicklung >PHP-Tutorial >Redis创建实例

Redis创建实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:47:26990Durchsuche
Redis创建实例
                   
                               
                                       
                                       
            
  1. 'REDIS_HOST'                        => '',
  2.         'REDIS_PORT'                        => 6379,
  3.     //缓存
  4.     'DATA_CACHE_TYPE'  =>        'Redis',  // 数据缓存类型,
  5.     'DATA_CACHE_TIME'         =>        36000,
  6.                
  7.     'REDIS_IP' =>array (
  8.         'host'          => '',
  9.         'port'          => 6379,
  10.         'timeout'       => false,
  11.         'persistent'    => false,
  12.     ),
  13.         'CACHETABLE'=>        array(
  14.                         'get_access_token'  =>  array('cacheKey'=>"get_access_token",'expire'=>6000),
  15.         ),       
  16. /*
  17.          * 是否允许分享
  18.          */
  19.         public function allowshare($openid){
  20.                 $Cache = Cache::getInstance('Redis');
  21.                 $key = "get_share_count_".$openid ;
  22.        
  23.                 $times = $Cache->get($key);
  24.                 if (empty($times)){
  25.                         $Cache->set($key,1);
  26.                         return true;
  27.                 }elseif ( $times>4) {
  28.                         return false;
  29.                 }else{
  30.                         $Cache->set($key, $times+1);
  31.                         return true;
  32.                 }
  33.         }
复制代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn