Ezequiel Villarreal
Ezequiel Villarreal

Reputation: 97

Set default group to Cache in kohana 3.3

After upgrade Kohana framework from 3.2 to 3.3, Cache ask me to put an default group to it.

config/cache.php

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

Before, I used to do like this without the group name:

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

Now, that sends an Exception: Failed to load Kohana Cache group: file.

But, when I set the name group all woks perfect.

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

How can I set now in 3.3 a default group without type it always whatever I want to use it? Maybe is a new upgrade, but, I checked the new features of kohana 3.3 and I don't see any of that.

Hope you can help me.

Upvotes: 2

Views: 1829

Answers (1)

wesside
wesside

Reputation: 5740

Alright so, here's the deal. Without the cache group supplied, it defaults to file. So if you -dare- change that, be my guest. But just set the static instance in bootstrap.php, answer at the bottom.

-- This is from the base cache class. --

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;
    }

So in your bootstrap.php set this, though I would name it to APC in your config:

Cache::$default = 'default';

Upvotes: 4

Related Questions