Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter database cache configuration

I'm unable to configure database cache to my system. I've tried every configuration that available in internet . please help me out.

$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'm getting

An uncaught Exception was encountered

Type: Exception

Message: Configured database connection has cache enabled. Aborting.

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

like image 737
Shahmee Avatar asked Aug 29 '16 09:08

Shahmee


1 Answers

Caching is enabled in three steps:

1) Create a writable directory on your server where the cache files can be stored.

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

$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) Enable the caching feature, either globally by setting the preference in your application/config/database.php file, or Manually enables/disables caching as described below.

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

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

Also, make sure your directory is writable (if you are on Mac or Linux)

sudo chmod 777 -R application/cache

I hope it will work for you.

like image 149
Jay Kareliya Avatar answered Sep 18 '22 10:09

Jay Kareliya