【问题标题】:Cake 3.0 Cache Configuration for OPcache and APCuOPcache 和 APCu 的 Cake 3.0 缓存配置
【发布时间】:2015-02-19 03:22:26
【问题描述】:

在 cakephp 3.0 中,基于 cake 内置缓存引擎配置缓存的正确方法是什么?

我将 PHP 5.6 与 Zend OPcache 和 APCu 一起使用。

【问题讨论】:

    标签: cakephp cakephp-3.0


    【解决方案1】:

    Zend Opcache 是一个内置的操作码缓存,它不是您需要配置的东西,但是 APCu 需要针对您的网络服务器进行编译并启用 APC 仿真

    config/app.php你需要输入以下内容:

       // Using a fully namespaced name.
        'long' => [
            'className' => 'Cake\Cache\Engine\ApcEngine',
            'duration' => '+1 week',
            'probability' => 100,
            'path' => CACHE . 'long' . DS,
        ]
    

    您可以为不同的缓存时间创建不同的配置。

    那么你就简单地缓存一个对象:

    $data = Cache::remember('my_cache_key', function () {
        return Service::expensiveCall();
    });
    

    或者使用Cache::readCache::write函数

    【讨论】:

    • 感谢您的帮助!
    猜你喜欢
    • 2015-05-25
    • 1970-01-01
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 2017-10-01
    • 2014-10-23
    • 2016-10-15
    • 2014-06-29
    相关资源
    最近更新 更多