tp5.1缓存方法报错

浏览:5057 发布日期:2018/10/16 分类:求助交流 关键字: 缓存 没有静态方法
Non-static method think\Cache::store() should not be called statically


使用的是5.19版本

/**配置代码**/return [
    'type'  =>  'complex',
    // 默认使用的缓存
    'default'   =>  [
        // 驱动方式
        'type'   => 'file',
        // 缓存保存目录
        'path'   => '../runtime/default',
    ],

    // redis缓存
    'redis'   =>  [
        // 驱动方式
        'type'   => 'redis',
        // 服务器地址
        'host'       => '127.0.0.1',
        // 端口
        'port'       => '6379',
        // 缓存保存目录
        'path'   => '../runtime/cache',
        // 全局缓存有效期(0为永久有效)
          'expire'=>  0, 
    ],
];
/**测试代码**/<?php
namespace app\index\controller;
use think\Cache;
class Index
{

    public function test()
    {
        Cache::store('default')->set('name','value');
        Cache::store('default')->get('name');
        return 'test';
    }

}
tp5.02测试没问题,redis也能用,同样配置环境wamp集成,php7.2
最佳答案
评论( 相关
后面还有条评论,点击查看>>