trait RequiresHashFieldExpiration

Skips tests when the environment doesn't support Redis hash field expiration.

Hash field expiration requires:

  • phpredis >= 6.3.0 (HSETEX command)
  • Redis >= 8.0.0 or Valkey >= 9.0.0 (HEXPIRE command)

Expects InteractsWithRedis on the same class — uses redisClient() to probe the server version. The support check is memoized per process.

Constants

private PHPREDIS_MIN_VERSION

Minimum phpredis version required for hash field expiration.

private REDIS_MIN_VERSION

Minimum Redis version required for hash field expiration.

private VALKEY_MIN_VERSION

Minimum Valkey version required for hash field expiration.

Methods

void
skipIfHashFieldExpirationUnsupported()

Skip the current test if hash field expiration requirements are not met.

string
detectedPhpredisVersion()

Detect the installed phpredis version. Overridable for tests.

array
detectedServerInfo()

Detect the Redis/Valkey server info. Overridable for tests.

static void
flushHashFieldExpirationState()

Flush the memoized hash field expiration support check.

Details

at line 51
protected void skipIfHashFieldExpirationUnsupported()

Skip the current test if hash field expiration requirements are not met.

The check runs once per process and is then cached for all subsequent calls.

Return Value

void

at line 100
protected string detectedPhpredisVersion()

Detect the installed phpredis version. Overridable for tests.

Return Value

string

at line 110
protected array detectedServerInfo()

Detect the Redis/Valkey server info. Overridable for tests.

Return Value

array

at line 120
static void flushHashFieldExpirationState()

Flush the memoized hash field expiration support check.

Tests only. Resets the capability result shared by tests in this class.

Return Value

void