Codeigniter Database Cache Configuration

I cannot configure the database cache for my system. I tried every configuration available on the Internet. please help me.

$db['default'] = array(
'dsn'   => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '123',
'database' => 'test',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => TRUE,
'cachedir' => 'application/cache',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt'  => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
    'save_queries' => TRUE
);

Below is the error message that I am getting

An unrelated exception was found

Type: Exception

Message: The configured database connection has a cache. Aborting

File Name: C: \ wamp \ www \ test \ system \ libraries \ Session \ drivers \ Session_database_driver.php

+4
source share
1 answer

Caching is included in three steps:

1) Create a directory for recording on your server, where cache files can be stored.

2) Set the path to the cache folder in the application / config / database.php file. For instance:

$db['default']['hostname'] = 'XXXXX';
$db['default']['username'] = 'XXXXX';
$db['default']['password'] = 'XXXXX';
$db['default']['database'] = 'XXXXX';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = 'XXX';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = TRUE;
$db['default']['cachedir'] = 'application/cache';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

3) , application/config/database.php, / , .

 // Turn caching on
 $this->db->cache_on();

 // Turn caching off for this one query
 $this->db->cache_off();

, , ( Mac Linux)

sudo chmod 777 -R application/cache

, .

+1

Source: https://habr.com/ru/post/1652826/


All Articles