Cache Expiration doesn't follow Drupal conventions

Created on 12 May 2017, almost 8 years ago
Updated 20 January 2025, 3 months ago

Drupal 8 convention for $expiration on set() is based on unix_timestamp() but this module expects expiration in TTL form like Redis (e.g. seconds till live)

CacheBackendInterface outlines:
* @param int $expire
* One of the following values:
* - CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should
* not be removed unless it is deleted explicitly.
* - A Unix timestamp: Indicates that the item will be considered invalid
* after this time, i.e. it will not be returned by get() unless
* $allow_invalid has been set to TRUE. When the item has expired, it may
* be permanently deleted by the garbage collector at any time.

However the calculation in redis/src/Cache/CacheBase will always return the permTtl if you pass in a unix_timestamp() per spec because unix timestamp will always be larger than TTL based on time difference from time().
1 if ($expire == Cache::PERMANENT || $expire > $this->permTtl) {

πŸ› Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States craigmc

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024