Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#91 2024-07-20 18:25:28

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: etc_cache: cache trying hard to be smart

I’m trying to create a dynamic cache with a filter, but the filter attribute value does not show up in the plugin UI.

OK I found the issue, in the plugin code there is a need to add the filter to the extract part inside the etc_cache function, as so:

change this:

    extract(lAtts(array(
        'id'    => empty($atts['form']) ? null : $atts['form'],
        'url'   => false,
        'form'  => '',
        'reset' => $reset,
        'time'  => true
    ), $atts));

to this:

    extract(lAtts(array(
        'id'    => empty($atts['form']) ? null : $atts['form'],
        'url'   => false,
        'form'  => '',
        'reset' => $reset,
        'filter' => $filter,
        'time'  => true
    ), $atts));

Another thing is that in the zipped version the “Cached at” column in the plugin UI doesn’t shows the time but only the date, in the TXT version (0.3) it does much better by showing the full date and time.

And about this issue, I found out it is because you simplified your code to just use the archive_dateformat from the txp preferences, so I went to my site preferences and added %S to the archive date format and now it does shows the seconds. (can use any strftime values I guess)

———————————————-

Now I’m facing an other issue, it is with the article_posted event not working but only the article_saved does, I’m also do not know how to properly chain the events in the reset and filter attributes.

This code works (with article_saved event):

<txp:etc_cache id="schedule" reset="article_saved" filter='"article_saved": {"Section": "schedule"}'>extremly heavy code goes here...</txp:etc_cache>

But these aren’t (with article_posted event):

<txp:etc_cache id="schedule" reset="article_posted" filter='"article_posted": {"Section": "schedule"}'>extremly heavy code goes here...</txp:etc_cache>
<txp:etc_cache id="schedule" reset="article_posted,article_saved" filter='"article_posted": {"Section": "schedule"},"article_saved": {"Section": "schedule"}'>extremly heavy code goes here...</txp:etc_cache>
<txp:etc_cache id="schedule" reset="article_posted,article_saved" filter='"{article_posted": {"Section": "schedule"},"article_saved": {"Section": "schedule"}}'>extremly heavy code goes here...</txp:etc_cache>@

If possible I would also like to know the full list of txp events that are available to use please.
Once again, I’m using the zipped 0.6 version on TXP 4.8.8.

Offline

#92 2024-07-22 09:20:18

etc
Developer
Registered: 2010-11-11
Posts: 5,681
Website GitHub

Re: etc_cache: cache trying hard to be smart

Sorry for the delayed reply, and thank you for the hints. I will take a look at it when time allows.

Offline

#93 2024-12-07 10:10:17

etc
Developer
Registered: 2010-11-11
Posts: 5,681
Website GitHub

Re: etc_cache: cache trying hard to be smart

THE BLUE DRAGON wrote #337420:

Here’s my code:
<txp:etc_cache id="schedule" reset="article_saved" filter='{"article_saved":{"Section":"schedule"}}'>my extremely heavy code</txp:etc_cache>

I want the cache to update only when there is any change to articles in my “schedule” section please.

Revisiting this, filter is not exposed as attribute, but you can (try to) set it this way:

<txp:etc_cache>
"article_saved":{"Section":"schedule"}
</txp:etc_cache>

All remaining etc_cache blocks should then inherit this filter. To unset it, call just <txp:etc_cache />.

Offline

#94 2025-06-08 18:56:53

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: etc_cache: cache trying hard to be smart

Thank you,
I still need to make the reset to work using both the “article_saved” and “article_posted” events, for a specific section please, currently only the “saved” event works but not the “posted”.

Offline

Board footer

Powered by FluxBB