Destroying config_text entry cache

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Ger
Recognised Extension Developer
Posts: 1792
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Destroying config_text entry cache

Post by Ger » Mon Sep 03, 2018 7:58 am

I use a config_text value ger_magicogp_blacklist in one of my extensions. Since config_text doesn't have a is_dynamic column, all values are cached. Several users have pointed out that this is confusing; they update their blacklist yet this isn't effectuated immediately.

I've tried to find a way to destroy that specific entry from the cache, but to no avail. The only thing that seems to work is purging the entire cache with
$cache->purge();

That seems a bit rough though. Is there a way to invalidate that one specific config_text item?
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3391
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Destroying config_text entry cache

Post by kasimi » Mon Sep 03, 2018 9:08 am

There is no way to clear cached results of a single query. If you use the $config_text->get() or $config_text->get_array() methods to fetch your data there shouldn't be any caching, see here and here.

User avatar
Ger
Recognised Extension Developer
Posts: 1792
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Destroying config_text entry cache

Post by Ger » Mon Sep 03, 2018 9:39 am

kasimi wrote:
Mon Sep 03, 2018 9:08 am
If you use the $config_text->get() or $config_text->get_array() methods to fetch your data there shouldn't be any caching, see here and here.
Well, it seems like it is cached.

In my ACP module class, I set the value like this:

Code: Select all

$config_text->set('ger_magicogp_blacklist', $request->variable('ger_magicogp_blacklist', '', true));
Next, I retrieve the value with

Code: Select all

$blacklist = explode(PHP_EOL, $this->config_text->get('ger_magicogp_blacklist'));
I didn't expect any caching to happen, but multiple users pointed out to me that changes weren't applied. I could reproduce that, and after purging the cache changes were applied.

Come to think of it though: the result is injected into the text formatter filterchain. Could there be a cache there?

Edit:
Yep, it was the text formatter. I now have

Code: Select all

$phpbb_container->get('text_formatter.cache')->invalidate();
And that works.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
3Di
Registered User
Posts: 13149
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Destroying config_text entry cache

Post by 3Di » Mon Sep 03, 2018 7:31 pm

I am using Json arrays with config_text and I have no issues at all with cache, FWIW.
:game_die: The new Dice Roller extension for phpBB 3.2 is out! :game_die:

Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
Ger
Recognised Extension Developer
Posts: 1792
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Destroying config_text entry cache

Post by Ger » Tue Sep 04, 2018 7:47 am

Yeah, like I wrote: it was the text formatter cache not the config_text cache.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
3Di
Registered User
Posts: 13149
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Destroying config_text entry cache

Post by 3Di » Wed Sep 05, 2018 3:07 am

I know. I read it. :)
Moreover, I went to the repo for that ext to watch your acp module's code to begin with.

Again, in my ACP I am using Json arrays and I don't have to worry about cache.
:game_die: The new Dice Roller extension for phpBB 3.2 is out! :game_die:

Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 9 guests