codeigniter 3 Configured database connection has cache enabled
The CodeIgniter framework allows you to configure a database connection with cache enabled. The following steps explain how to achieve this:
- Open the
config.php
file located in theapplication/config
directory of your CodeIgniter project. - Locate the
$config['cache_query_string']
parameter and set it toTRUE
. This enables the cache for database query strings. - Locate the
$config['cachedir']
parameter and set it to the desired cache directory path. CodeIgniter will use this directory to store the cached query strings. - Open the
database.php
file located in the sameapplication/config
directory. - Find the
db
array and locate thecachedir
parameter. Set it to the same cache directory path you specified in the previous step. - Locate the
cache_on
parameter within thedb
array and set it toTRUE
. This enables caching for the database connection. - Save both the
config.php
anddatabase.php
files.
Once you have completed these steps, your CodeIgniter application will have a database connection with cache enabled. This means that query strings will be cached, improving the performance of subsequent queries with the same string. The cache directory you specified will store these cached query strings.