zoukankan      html  css  js  c++  java
  • TP5中用redis缓存

    在config.php配置文件下找到缓存设置,将原来的文件缓存修改为redis缓存,也可以改为多种类型的缓存:

        // +----------------------------------------------------------------------
        // | 缓存设置
        // +----------------------------------------------------------------------
    
    
    /*    'cache'                  => [
            // 驱动方式
            'type'   => 'File',
            // 缓存保存目录
            'path'   => CACHE_PATH,
            // 缓存前缀
            'prefix' => '',
            // 缓存有效期 0表示永久缓存
            'expire' => 0,
        ],*/
    
        'cache' => [
            // 使用复合缓存类型
            'type' => 'complex',
            // 默认使用的缓存
            'default' => [
                // 驱动方式
                'type' => 'File',
                // 缓存保存目录
                'path' => CACHE_PATH,
            ],
            // 文件缓存
            'file' => [
                // 驱动方式
                'type' => 'file',
                // 设置不同的缓存保存目录
                'path' => RUNTIME_PATH . 'file/',
            ],
            // redis缓存
            'redis' => [
                // 驱动方式
                'type' => 'redis',
                // 服务器地址
                'host' => '127.0.0.1', // 本地环境先开启redis服务端 redis-service.exe
                'port' => '6379',
            ],
        ],

    这样就可以使用redis来缓存数据了。用法如下:

    	hinkCache::store('redis')->handler()->hMSet('test', array('k1'=>123));

    其实就是因为  hinkCache::store('redis')->handler()  这一步返回是redis实例化对象,所以通过这个对象可以操作其他redis数据结构方法

        /**
         * 返回句柄对象,可执行其它高级方法
         *
         * @access public
         * @return object
         */
        public function handler()
        {
            return $this->handler;
        }

    注意: 不过在window下测试redis, 还要开启它服务端才行 redis-service.exe

  • 相关阅读:
    cityscapes和Mapillary Vistas两种不同分割数据集的label映射
    探究Z-Order
    Java ——对Swing、AWT和SWT的认识 原创
    UOJ-581 NOIP2020 字符串匹配
    UOJ-618 JOISC2021 聚会 2
    Codeforces Round #740 (Div. 1, based on VK Cup 2021
    PipeCAD
    第三次全国国土调查相关信息记录
    统计研究区内Landsat影像数量
    GEE数据导出注意事项
  • 原文地址:https://www.cnblogs.com/pyspang/p/11185759.html
Copyright © 2011-2022 走看看