Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting TTL in Redis #27

Open
sddaniels opened this issue Jan 28, 2019 · 4 comments
Open

Setting TTL in Redis #27

sddaniels opened this issue Jan 28, 2019 · 4 comments

Comments

@sddaniels
Copy link

sddaniels commented Jan 28, 2019

It looks like there's a TTL setting available for this plugin, but it's only used for internal calculations. There is no TTL passed to Redis, so each page is cached indefinitely. That seems to be why the allkeys-lru eviction policy is recommended.

With our current automation, we're not able to easily change this eviction strategy from the default, which does not evict any keys that do not have a TTL set. Is there any reason that this plugin couldn't optionally set the TTL in Redis?

@wkhayrattee
Copy link

hey @sddaniels this ticket is dated, but curious to follow along.

Did you try this:


// Change the cache time-to-live to 10 minutes
$redis_page_cache_config['ttl'] = 600;

Or what did you end up doing?

@soulseekah
Copy link
Contributor

https://github.com/pressjitsu/pj-page-cache-red/blob/master/advanced-cache.php#L642 we actually do perform a setTimeout (which is deprected as of PHP 7.2, we need to change that to expire instead). This sets the TTL for all entries being added upon shutdown.

Can we have a confirmation on this, please?

@soulseekah
Copy link
Contributor

so each page is cached indefinitely

I just checked and this is true, unfortunately. We are keeping these keys indefinitely.
We'll need to discuss why this is happening.

@AndPicc
Copy link

AndPicc commented Aug 7, 2023

Hello @soulseekah and thanks for this very useful drop-in.

We've been using it for a while but I just recently realised that the keys are never expired automatically, as it's mentioned in this thread. The cache is only expired and refreshed if you visit the page again, but old pages that are never visited again are lingering in the database forever...

I've been testing and trying to figure out why, but unfortunately I couldn't make it work...
could you have a look and give me a hand please?

one thing I was wondering is why are you not passing the expiration directly when setting the cache value?
somewhere like here:

$redis->set( sprintf( 'pjc-%s', self::$request_hash ), $data );

thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants