Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
With the version 8.x-1.0-rc2 there is the file README.md and within a lot of @todo stuff. For example the "Flush mode" and "Default lifetime for permanent items" etc. Could someone tell me how $conf['redis_perm_ttl'] = "1 year";
is written correctly for Drupal 8?
Thanks for helping.
Comment | File | Size | Author |
---|---|---|---|
#10 | redis-default_permanent_ttl-2944938.patch | 2.51 KB | Apnc |
#7 | redis-default-permanent-lifetime-2944938-7.patch | 3.03 KB | trebormc |
#6 | redis-default-permanent-lifetime-2944938-6.patch | 3.18 KB | trebormc |
#5 | 2944938-wrong-property-for-days.patch | 751 bytes | Breuls |
#5 | redis-default-permanent-lifetime-2944938-3.patch | 2.8 KB | Breuls |
Comments
Comment #2
kasperg CreditAttribution: kasperg at Reload commentedThe documentation is not written correctly.
$conf['redis_perm_ttl'] = "1 year";
does not work for Drupal 8.The current version only supports a lifetime for permanent items for specific cache bins e.g.
$settings['redis.settings']['perm_ttl_cache_field'] = "3 months";
I have added a patch which adds support for a default lifetime for all permanent items across bins.
Comment #3
achtonComment #4
zaporylieI agree with the approach in #2. The only thing IMHO is if, for consistency with Drupal's bin naming, name for the fallback, default ttl for all the bins should be
perm_ttl
orperm_ttl_default
? I have no strong opinions, and with good documentation, which was also provided in #2, both options looks fine.One last thing I spotted just before posting a comment above - ternary operator `??` was added in php 7 but the module doesn't set minimal php requirements neither via composer.json nor redis.info.yml, hence back to "Needs work".
Comment #5
Breuls CreditAttribution: Breuls commentedThe patch seems to work quite well; I'm able to configure a TTL for my cache entries when I use it. However, one bug remains; in the part just below what the patch changes, there's a call to
DateInterval::createFromDateString()
followed by a calculation of the number of seconds. In this, the variable$iv->days
is used, which, according to the PHP docs, is only given a value "If the DateInterval object was created by DateTime::diff()". if not, it will be false.Changing it into
$iv->d
makes it work: I ran into this because I used the string "1 day", which I've now changed to 86400 to circumvent the bug.I've created a patch that fixes this. I'm new to this system (I'm used to using GitHub), so I wasn't sure whether my patch needed to include the previous one or not, so I made two.
Comment #6
trebormcNew patch with # 5 but eliminating the ?? who complains in # 4
Comment #7
trebormcI upload # 6 again with the correct path to the module so that the patch is applied correctly
Comment #8
neclimdulI see the php 7 comment earlier which is annoying. That would have been a lot cleaner.
The first time I read this I thought this was fine and the mix of isset and empty was just awkward to read. I think its actually wrong though. If I'm noodling this correctly, using empty in the outside if statement means you can't set the perm_ttl to 0 which is actually documented in the README as a feature so you can make perm truely non-volatile again.
Just an observation because its not part of your changes but its weird this isn't written in a more clear way like:
Maybe left over from more complicated logic or the author just didn't like elseif :-D
Comment #9
lusitaniae CreditAttribution: lusitaniae commentedAny updates?
This is not really clear
Comment #10
Apnc CreditAttribution: Apnc as a volunteer commentedI've updated #7 for the current version and changed the empty() check to isset() as pointed out by #8
Comment #11
Apnc CreditAttribution: Apnc as a volunteer commentedComment #12
NickGee CreditAttribution: NickGee at Ontario Digital Service commentedHi, just realized that this is still in NR.
We have been applying #10 to two products for over a year now and it appears to be working as intended. Hope this helps move things along!
Comment #13
BerdirPretty sure this is a duplicate of #3179757: TTL handling broken, always permanent?
Comment #14
andrew.wang CreditAttribution: andrew.wang at Ontario Digital Service commentedI second #12 - the patch has been applied to the site I'm working on for 2 years and it's been working great on a high volume website.
(Disclaimer: Nick and I work at the same organization but a different site ;-P)
Comment #15
Alina Basarabeanu CreditAttribution: Alina Basarabeanu at Cyber-Duck commentedWe have been using the patch from #10 for the last 2 years.
The calculation from issue 3179757 is the same as the one done in this issue.
Would be good to have one of them merged into a stable version.
Currently, we are using 7 patches to make this module work.
Comment #16
rcodina CreditAttribution: rcodina at Seidor commented@Alina Basarabeanu Could you please share the list of patches you use?
Comment #17
Alina Basarabeanu CreditAttribution: Alina Basarabeanu at Cyber-Duck commentedComment #18
rcodina CreditAttribution: rcodina at Seidor commented@Alina Basarabeanu Thanks! In my case, apart from current #2944938: Default lifetime for permanent items for Drupal 8, I'm using patch on #3216874: Unsupported operand types in CacheTagsChecksumTrait.php.