We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Db Caching Issue

Development and Programming

elcasolutions's avatar
elcasolutions
1 posts
15 years ago
elcasolutions's avatar elcasolutions

I have been developing an EE2.0 module that makes use of several custom tables in the EE database. After upgrading from the beta to 2.1, settings that I change from my module’s control panel aren’t reflected on the module’s frontend pages until I clear the DB cache using the CP tool, even though the CP pages are updated just fine. Perhaps I didn’t use to have DB caching on and the issue isn’t related to 2.1, but I feel like I must not be doing something right. The docs mention the db cache being cleared when a table gets updated, but does this happen automatically? Does anybody have any idea what I could be doing wrong?

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
15 years ago
John Henry Donovan's avatar John Henry Donovan

elcasolutions,

Welcome to the forums 😊

I am going to move this thread to the Development and Programming forum as it is more appropriate there.

       
Yorick Peterse's avatar
Yorick Peterse
537 posts
15 years ago
Yorick Peterse's avatar Yorick Peterse
I have been developing an EE2.0 module that makes use of several custom tables in the EE database. After upgrading from the beta to 2.1, settings that I change from my module’s control panel aren’t reflected on the module’s frontend pages until I clear the DB cache using the CP tool, even though the CP pages are updated just fine. Perhaps I didn’t use to have DB caching on and the issue isn’t related to 2.1, but I feel like I must not be doing something right. The docs mention the db cache being cleared when a table gets updated, but does this happen automatically? Does anybody have any idea what I could be doing wrong?

I assume EE only does this for standard tables and that you have to do this yourself in case your module is using custom tables.

       
midrange's avatar
midrange
2 posts
15 years ago
midrange's avatar midrange

Has anybody else been dealing with similar issues?

I’m developing a module with custom tables, and the only way I can get changes to show up on the front end of the site is to disable database caching. Does anyone know if there’s a way I can fine tune my queries so that they’re never cached, and as a result, I could keep database caching turned on in the site? Or am I doomed to require database caching to be turned off?

The only related thing I’ve come across is the caching feature in the db class, but that seems to be utilized only if you explicitly call the caching functions, which I’ve made sure not to do.

       
midrange's avatar
midrange
2 posts
15 years ago
midrange's avatar midrange

I’ve found a workaround for this, if anyone’s wondering. If you check out the code under:

EE_Functions->clear_caching

you can see how the cache is cleared (it’s a simple directory deletion). If you look at the db cache folder, you can see that it’s organized nicely by folders named like “module+function” (this is wrong, read the edit below). So, to clear cache for a very specific thing, you just need to delete the directory that represents your function’s method. Here’s what I’m going to try:

$cache_sub_folder = "your_module+your_function";

$this->EE->functions->delete_directory(APPPATH.'cache/db_cache_'.
     $this->EE->config->item('site_id')."/".$cache_sub_folder);

EDIT:

It turns out the cache sub folder isn’t “your_module+your_function”; it’s actually “template_group+template”. You could still clear the cache sub folder for “segment1+segment2” in your mod file, but that doesn’t cover the scenario where you’re getting data from an ACT=x page (which is what I still need to figure out :shut: )

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.