A
A
Anton2015-09-28 18:00:40
Kohana
Anton, 2015-09-28 18:00:40

Cache in kohan, how to use caching in kohan?

Hello, how to enable or connect the cache in Kohan?
Kohana version 3.1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Belyaev, 2015-09-28
@ib2

1. Include the module in bootstrap.php
2. Initialization $cache = Cache::instance();
3. Add something to the cache $cache->set('foo', 'bar', 1800)(add bar to the cache for 1800 sec.)
4. Get something from the cache $cache->get('foo')
kohanaframework.org/3.3/guide/cache/usage SQl
caching -requests (we cache the result for 1800 seconds):
Route caching:

if ( ! Route::cache())
{
    // Роуты

    if (Kohana::$environment === Kohana::PRODUCTION)
        Route::cache(true);
}

A
Anton, 2015-09-29
Websaytovsky @ws17

Added caching of routes, it seems to work, it does not write errors.

if ( ! Route::cache())
{
    // Роуты

    if (Kohana::$environment === Kohana::PRODUCTION)
        Route::cache(true);
}

I completed the first and second points, but 3 and 4 I don’t understand where to do this, where to add that.
3. Add something to the cache $cache->set('foo', 'bar', 1800)(add bar to the cache for 1800 sec.)
4. Get something from the cache $cache->get('foo')
SQl query caching (caching the result for 1800 seconds):
in the bootstrap at the very bottom I found something else, though I don’t understand what it is.
$version = 'new';
if (UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "MSIE")){
    if(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "MSIE 5")) $version = 'UPDATE';
    elseif(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "MSIE 6.0")) $version = 'UPDATE';
    elseif(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "MSIE 7.0")) $version = 'ie';
    elseif(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "MSIE 8.0")) $version = 'ie';
}
elseif (UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Firefox")){
    if (UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Firefox/1")) $version = 'UPDATE';
    elseif (UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Firefox/2")) $version = 'UPDATE';
    elseif (UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Firefox/3")) $version = 'old';
}
elseif (UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Safari")){
    if(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Version/2")) $version = 'UPDATE';
    elseif(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Version/3")) $version = 'UPDATE';
    elseif(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Version/4")) $version = 'old';
}
elseif (UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Presto")){
    if(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Version/9")) $version = 'UPDATE';
    elseif(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Version/10")) $version = 'old';
    elseif(UTF8::stristr($_SERVER["HTTP_USER_AGENT"], "Version/11")) $version = 'old';
}
define('BROWSER', $version);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question