zoukankan      html  css  js  c++  java
  • windows 下 YII2 配置 memcache

      环境:

          操作系统 :Windows 7;

          php: 5.6.8

          apche:2.4.12

    1、首先安装PHP  memcache 拓展,安装方法如下:

          1.1下载 memcache 拓展DLL:

               http://pecl.php.net/package/memcache/3.0.8/windows

          1.2 拷贝php_memcache.dll 到 php/ext目录

          1.3 调整php.ini,底部添加配置:

                 extension=php_memcache.dll 

    2、添加YII2配置:

         在项目config/web.php 文件中修改  

    components>=cache  配置  修改配置如下:

    调用方法 如下:

    <?php
    /**
     * Created by PhpStorm.
     * User: wangk
     * Date: 2015/4/27
     * Time: 10:34
     */
    namespace appcommon;
    
      use Yii;
    
      class CacheManage {
    
         // Cache前缀
          const  CACHE_PREFIX='myrhythmk_';
    
         private static function getKey($key)
         {
             return self::CACHE_PREFIX.$key;
         }
    
         public static function  get($key)
         {
             return Yii::$app->cache->get(self::getKey($key));
         }
    
         public  static  function  set($key, $value, $duration = 0, $dependency = null)
         {
             return Yii::$app->cache->set(self::getKey($key),$value,$duration,$dependency);
         }
    
         public  static  function  delete($key)
         {
             return Yii::$app->cache->delete(self::getKey($key));
         }
    
    }
    
    
    
    
    
  • 相关阅读:
    jquery mobile (一)
    jquery mobile 前言
    MD5Helper辅助类
    设计权限管理系统(十四)
    设计权限管理系统(十三)
    display:table-cell的min-height
    CORS跨域cookie传递
    性能优化-合成层
    textarea自适应高度
    仿今日头条按钮loading效果
  • 原文地址:https://www.cnblogs.com/rhythmK/p/4460083.html
Copyright © 2011-2022 走看看