Redis创建实例
- 'REDIS_HOST' => '',
- 'REDIS_PORT' => 6379,
- //缓存
- 'DATA_CACHE_TYPE' => 'Redis', // 数据缓存类型,
- 'DATA_CACHE_TIME' => 36000,
-
- 'REDIS_IP' =>array (
- 'host' => '',
- 'port' => 6379,
- 'timeout' => false,
- 'persistent' => false,
- ),
-
- 'CACHETABLE'=> array(
- 'get_access_token' => array('cacheKey'=>"get_access_token",'expire'=>6000),
-
- ),
- /*
- * 是否允许分享
- */
- public function allowshare($openid){
- $Cache = Cache::getInstance('Redis');
- $key = "get_share_count_".$openid ;
-
- $times = $Cache->get($key);
- if (empty($times)){
- $Cache->set($key,1);
- return true;
- }elseif ( $times>4) {
- return false;
- }else{
- $Cache->set($key, $times 1);
- return true;
- }
- }
复制代码
|