Documentation

RedisTagAwareAdapter extends AbstractTagAwareAdapter
in package
Uses RedisTrait

Stores tag id <> cache id relationship as a Redis Set.

Set (tag relation info) is stored without expiry (non-volatile), while cache always gets an expiry (volatile) even if not set by caller. Thus if you configure redis with the right eviction policy you can be safe this tag <> cache relationship survives eviction (cache cleanup when Redis runs out of memory).

Redis server 2.8+ with any volatile-* eviction policy, OR noeviction if you're sure memory will NEVER fill up

Design limitations:

  • Max 4 billion cache keys per cache tag as limited by Redis Set datatype. E.g. If you use a "all" items tag for expiry instead of clear(), that limits you to 4 billion cache items also.
Tags
see
https://redis.io/topics/lru-cache#eviction-policies

Documentation for Redis eviction policies.

see
https://redis.io/topics/data-types#sets

Documentation for Redis Set datatype.

author

Nicolas Grekas p@tchwork.com

author

André Rømcke andre.romcke+symfony@gmail.com

Table of Contents

DEFAULT_CACHE_TTL  = 8640000
On cache items without a lifetime set, we set it to 100 days. This is to make sure cache items are preferred to be evicted over tag Sets, if eviction policy is configured according to requirements.
$namespace  : mixed
$redisEvictionPolicy  : string|null
__construct()  : mixed
doDeleteTagRelations()  : bool
{@inheritdoc}
doDeleteYieldTags()  : iteratable<string|int, mixed>
{@inheritdoc}
doInvalidate()  : bool
{@inheritdoc}
doSave()  : array<string|int, mixed>
{@inheritdoc}
getRedisEvictionPolicy()  : string

Constants

DEFAULT_CACHE_TTL

On cache items without a lifetime set, we set it to 100 days. This is to make sure cache items are preferred to be evicted over tag Sets, if eviction policy is configured according to requirements.

private mixed DEFAULT_CACHE_TTL = 8640000

Properties

$redisEvictionPolicy

private string|null $redisEvictionPolicy

detected eviction policy used on Redis server

Methods

__construct()

public __construct(Redis|RedisArray|RedisCluster|ClientInterface|RedisProxy|RedisClusterProxy $redis[, string $namespace = '' ], int $defaultLifetime[, MarshallerInterface|null $marshaller = null ]) : mixed
Parameters
$redis : Redis|RedisArray|RedisCluster|ClientInterface|RedisProxy|RedisClusterProxy

The redis client

$namespace : string = ''

The default namespace

$defaultLifetime : int

The default lifetime

$marshaller : MarshallerInterface|null = null
Return values
mixed

doDeleteTagRelations()

{@inheritdoc}

protected doDeleteTagRelations(array<string|int, mixed> $tagData) : bool
Parameters
$tagData : array<string|int, mixed>
Return values
bool

doDeleteYieldTags()

{@inheritdoc}

protected doDeleteYieldTags(array<string|int, mixed> $ids) : iteratable<string|int, mixed>
Parameters
$ids : array<string|int, mixed>
Return values
iteratable<string|int, mixed>

doInvalidate()

{@inheritdoc}

protected doInvalidate(array<string|int, mixed> $tagIds) : bool
Parameters
$tagIds : array<string|int, mixed>
Return values
bool

doSave()

{@inheritdoc}

protected doSave(array<string|int, mixed> $values, int $lifetime[, array<string|int, mixed> $addTagData = [] ][, array<string|int, mixed> $delTagData = [] ]) : array<string|int, mixed>
Parameters
$values : array<string|int, mixed>
$lifetime : int
$addTagData : array<string|int, mixed> = []
$delTagData : array<string|int, mixed> = []
Return values
array<string|int, mixed>

getRedisEvictionPolicy()

private getRedisEvictionPolicy() : string
Return values
string

Search results