Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: set_ttl with second values or weeks not functioning correctly.

Status Resolved
Add-on / Version Speedy 1.8.0
Severity
EE Version 6.4.4

Patmos Inc

Jan 27, 2023

When trying to use the {speedy:set_ttl} with seconds or “2 days”, the ttl to live on the redis item does not get set correctly.

If I use:

{speedy:set_ttl}3600{/speedy:set_ttl}

then the item gets an infinite ttl which was shown by running the following:

127.0.0.1:6379> ttl speedy/redis/default_site/local/news/article/test-cool-stuff/article-test-cool-stuff
returns this value // (integer) -1

If I use:

{speedy:set_ttl}2 days{/speedy:set_ttl}

then the item gets a very large ttl:

127.0.0.1:6379> ttl speedy/redis/default_site/local/news/article/test-cool-stuff/article-test-cool-stuff
returns this value // (integer) 1675041231

Haven’t looked at the method enough to determine what’s wrong, but will on monday.

Here is the simplified version of the channel loop which has a limit of 1:

{exp:speedy:fragment key="article-{segment_3}" tags="news|news-articles" global="no" ttl="900"}
  {exp:channel:entries channel="news" limit="1" track_views="one" disable="pagination|category_fields"}
  	{if "{entry_date format='%F %Y'}" == "{current_time format='%F %Y'}"}
    	   {speedy:set_ttl}3600{/speedy:set_ttl}
       {/if}
{/exp:speedy:fragment}
#1

Patmos Inc

Looks like I left off the closing channel tag. This was a typo here. Not that way in my code. Here’s the actual code.

{exp:speedy:fragment key="article-{segment_3}" tags="news|news-articles" global="no" ttl="900"}
  {exp:channel:entries channel="news" limit="1" track_views="one" disable="pagination|category_fields"}
   {if "{entry_date format='%F %Y'}" == "{current_time format='%F %Y'}"}
        {speedy:set_ttl}3600{/speedy:set_ttl}
       {/if}
  {/exp:channel:entries}
{/exp:speedy:fragment}
#2

BoldMinded (Brian)

Thanks, due to my current schedule it’ll be a few days until I can look into this. Sorry.

#3

BoldMinded (Brian)

I think it’s setting the timestamp of when it should expire, not how many seconds it should live. I’ll take a look at fixing this soon.

#4

BoldMinded (Brian)

Actually try this. Line 418 of mod.speedy.php, add the - time() to the end of the line;

$this->dynamic_ttl = $date->getTimestamp() - time();

See if that fixes it.

#5

Patmos Inc

Sorry didn’t have time to check yet. Will check on monday.

#6

BoldMinded (Brian)

I’m going to go ahead and close this ticket assuming this fix worked for you. If you find otherwise please feel free to re-open it.

Login to reply