CodeIgniter Forums
enabling cache in database.php, a question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: enabling cache in database.php, a question (/showthread.php?tid=77315)



enabling cache in database.php, a question - zoldos - 08-15-2020

I'm brand new to CI 4 and just installed it.  I setup database.php to match my settings and I enabled cache (cahceON=true) and set the cache folder to simply "cache" and created that folder under public.  Is this correct?  And does this setting cache the site, or just the DB?

Any tips would be most appreciated! Big Grin


RE: enabling cache in database.php, a question - jreklund - 08-16-2020

No, you need an absolute path. And don't store it in the public folder, you should store it in your writable folder for an example.
https://codeigniter.com/user_guide/database/configuration.html#explanation-of-values

It's only caching database objects.

Complete website: https://codeigniter.com/user_guide/general/caching.html
Caching objects: https://codeigniter.com/user_guide/libraries/caching.html

The best tip I can give you are reading the User Guide from top to bottom, and then start coding so you have a grasp on where to look.


RE: enabling cache in database.php, a question - zoldos - 08-16-2020

(08-16-2020, 12:33 AM)jreklund Wrote: No, you need an absolute path. And don't store it in the public folder, you should store it in your writable folder for an example.
https://codeigniter.com/user_guide/database/configuration.html#explanation-of-values

It's only caching database objects.

Complete website: https://codeigniter.com/user_guide/general/caching.html
Caching objects: https://codeigniter.com/user_guide/libraries/caching.html

The best tip I can give you are reading the User Guide from top to bottom, and then start coding so you have a grasp on where to look.

Great, thanks so much!! Big Grin


RE: enabling cache in database.php, a question - zoldos - 10-26-2020

(08-16-2020, 12:33 AM)jreklund Wrote: No, you need an absolute path. And don't store it in the public folder, you should store it in your writable folder for an example.
https://codeigniter.com/user_guide/database/configuration.html#explanation-of-values

Okay, I did this in app/Config/Cache.php:

Code:
/var/www/vhosts/schismdream.com/writable/cache/

and set the cache method to "files". Then

Code:
$this->cachePage(30);

in the Home.php controller for testing purposes. It doesn't work and I get the "whoops" error page. Sad

All folders under Writeable are chmodded 777. Thanks!


RE: enabling cache in database.php, a question - paulbalandan - 10-26-2020

I'm sorry to be the bearer of bad news but database caching is not supported for CI4. This has been removed in latest develop.

Issue: https://github.com/codeigniter4/CodeIgniter4/issues/3597
PR: https://github.com/codeigniter4/CodeIgniter4/pull/3608

You have to use the generic caching used by the Cache library. But expect to not have caching specific to databases.


RE: enabling cache in database.php, a question - zoldos - 10-26-2020

(10-26-2020, 09:17 AM)paulbalandan Wrote: I'm sorry to be the bearer of bad news but database caching is not supported for CI4. This has been removed in latest develop.

Issue: https://github.com/codeigniter4/CodeIgniter4/issues/3597
PR: https://github.com/codeigniter4/CodeIgniter4/pull/3608

You have to use the generic caching used by the Cache library. But expect to not have caching specific to databases.

I mainly just want "regular" caching, not DB caching, if there is a difference. Cool  Thanks!


RE: enabling cache in database.php, a question - paulbalandan - 10-27-2020

Ok. But your post is titled cache in database.php. That's why.


RE: enabling cache in database.php, a question - zoldos - 10-27-2020

(10-27-2020, 01:18 AM)paulbalandan Wrote: Ok. But your post is titled cache in database.php. That's why.

Ah yes. Big Grin  My bad.