Skip to content

Do not force update expiry with WP_REDIS_MAXTTL if set #594

@shivapoudel

Description

@shivapoudel

Description

If wp_cache_set has set the expiry time, then do not update with WP_REDIX_MAXTTL config.

Expected Behavior

If a certain cache is set to expire within an hour, it should not use WP_REDIX_MAXTTL expiration value.

Actual Behavior

If a certain cache is set to expire within an hour, and WP_REDIS_MAXTTL is set to expire the whole cache within 24 hr. Then the previous cache set for an hour to expire is also updated to 24 hours.

Possible Fix

This might help if the expiry is just 0, then respect WP_REDIS_MAXTTL, but if that is set, do not modify.

Ref: https://github.com/pantheon-systems/wp-redis/blob/412dadbeb80d8bef9239d4f073531bb7e34d1ea5/object-cache.php#L233

Steps to Reproduce

  1. Define WP_REDIS_MAXTTL with 86,400 for a day.
  2. Set up two caches with expiry and non-expiry time.
  3. Check the expiry set cache, it should be using the WP_REDIS_MAXTTL value.
  4. Kudos, you must replicate the steps to reproduce.

Additional context

I need to expire certain cached areas, but it is not letting me do with WP_REDIS_MAXTTL overriding.

Environment

  • Plugin version: 2.7
  • PHP version: 8.3
  • WordPress version: 6.8.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions