Problem/Motivation

Currently, all cache items get a TTL, if none is set then for 1 year. This allows to separate them from cache tags and avoid them from expiring when using a volatile-* eviction policy.

Some cache bins have a fixed max size and will not really grow beyond that, such as config, bootstrap and discovery. I think it's useful to not have those items expire at all. While redis should be pretty good at keeping them around with something like volatile-lfu, this should help with that.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork redis-3570205

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

berdir created an issue. See original summary.

shank115’s picture

Currently, the Redis module assigns a TTL to all CACHE_PERMANENT items (default ~1 year), even for bins that are effectively bounded in size and rarely updated, such as config, bootstrap, and discovery.

I suggest we explicitly support setting the TTL to 0 (or a negative value) to skip the EXPIRE call entirely for these bins, in settings.php:

$settings['redis_perm_ttl_config'] = 0;
$settings['redis_perm_ttl_bootstrap'] = 0;
$settings['redis_perm_ttl_discovery'] = 0;

This approach reduces unnecessary TTL operations while keeping the intended permanent nature of bounded cache bins.

drupalite1411’s picture

We also haven't set these ttl values in our settings.php.
We are getting RedisException in our dblog randomly.
We are using pantheon and they are reporting that the main reason that the error RedisException: read error on connection to 10.73.8.170:11034 in Redis->hGetAll() (line 60 of /code/docroot/modules/contrib/redis/src/Cache/PhpRedis.php) is happening is due to the amount of Object Cache that is still in the memory and is causing it to reach the limit of its memory.
Although we are not still convinced that setting ttl will resolve this error.
Not able to understand the cause of it.
These are the recommended values:
$settings['redis.settings']['perm_ttl'] = 2630000; // 30 days
$settings['redis.settings']['perm_ttl_config'] = 43200;
$settings['redis.settings']['perm_ttl_data'] = 43200;
$settings['redis.settings']['perm_ttl_default'] = 43200;
$settings['redis.settings']['perm_ttl_entity'] = 172800;
Also they are using the maxmemory policy is allkeys-lru evict keys by trying to remove the less recently used (LRU) keys first, in order to make space for the new data added.

berdir’s picture

Status: Active » Needs review

@drupalite1411: That has nothing to do with that issue. My recommendation is in the docs and it's to not customize the perm ttl like that and rely on eviction, preferably volatile eviction only. I don't know anything about pantheon though. https://project.pages.drupalcode.org/redis/#expiration-of-cache-items

Implemented this using -1 and also unified with the existing relay specific setting to apply this by default.

  • berdir committed 79627978 on 2.x
    feat: #3570205 Allow to set no TTL on items in certain bins
    
    By: berdir
    
berdir’s picture

Status: Needs review » Fixed

Merging this.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.