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

Constants

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.

Properties

$namespace  : string
$redisEvictionPolicy  : string
detected eviction policy used on Redis server.

Methods

__construct()  : mixed
doDeleteTagRelations()  : bool
doDeleteYieldTags()  : iterable<string|int, mixed>
doInvalidate()  : bool
doSave()  : array<string|int, mixed>
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

detected eviction policy used on Redis server.

private string $redisEvictionPolicy

Methods

__construct()

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

doDeleteTagRelations()

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

doDeleteYieldTags()

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

doInvalidate()

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

doSave()

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

        
On this page

Search results