【问题标题】:Set default group to Cache in kohana 3.3在 kohana 3.3 中将默认组设置为缓存
【发布时间】:2012-10-29 20:22:04
【问题描述】:

将 Kohana 框架从 3.2 升级到 3.3 后,Cache 要求我为其添加一个默认组。

config/cache.php

return array(
     'default' => array(                    // Driver group
         'driver'         => 'apc',         // using APC driver
         'default_expire' => 3600,          // life time
      ),
);

以前,我曾经这样做没有组名:

Cache::instance()->set('key', 'val');

现在,发送异常:无法加载 Kohana 缓存组:文件。

但是,当我设置名称组时,一切都完美了。

Cache::instance('default')->set('key', 'val');

我现在如何在 3.3 中设置一个默认组,而不总是输入我想使用的任何内容?也许是一个新的升级,但是,我检查了 kohana 3.3 的新功能,我没有看到任何这些。

希望你能帮助我。

【问题讨论】:

    标签: php caching kohana


    【解决方案1】:

    好吧,这就是交易。如果没有提供缓存组,则默认为文件。因此,如果您 - 敢 - 改变这一点,请成为我的客人。但是只要在bootstrap.php中设置静态实例,在底部回答即可。

    -- 这是来自基本缓存类。 --

    public static $default = 'file';
    
    public static function instance($group = NULL)
    {
        // If there is no group supplied
        if ($group === NULL)
        {
            // Use the default setting
            $group = Cache::$default;
        }
    

    所以在你的bootstrap.php 中设置这个,虽然我会在你的配置中将它命名为 APC:

    Cache::$default = 'default';
    

    【讨论】:

    • @EzequielVillarreal 我的荣幸
    猜你喜欢
    • 2017-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 2019-09-19
    • 2023-04-01
    • 1970-01-01
    • 2018-08-29
    相关资源
    最近更新 更多