Skip to content

TaggablePsr6PoolAdapter

This adapter lets you make any PSR-6 cache pool taggable. If a pool is already taggable, it is simply returned by makeTaggable. Tags are stored either in the same cache pool, or a separate pool, and both of these approaches come with different caveats.

A general caveat is that using this adapter reserves any cache key starting with '__tag.'.

Using the same pool is precarious if your cache does LRU evictions of items even if they do not expire (as in e.g. memcached). If so, the tag item may be evicted without all the tagged items having been evicted first, causing items to lose their tags.

In order to mitigate this issue, you may use a separate, more persistent pool for your tag items. Do however note that if you are doing so, the entire pool is reserved for tags, as this pool is cleared whenever the main pool is cleared.

  • Full name: \Qubus\Cache\Psr6\TaggablePsr6PoolAdapter
  • This class is marked as final and can't be subclassed
  • This class implements: \Qubus\Cache\Psr6\TaggableCacheItemPool
  • This class is a Final class

Properties

cachePool

private \Psr\Cache\CacheItemPoolInterface $cachePool

tagStorePool

private ?\Psr\Cache\CacheItemPoolInterface $tagStorePool

Methods

__construct

private __construct(\Psr\Cache\CacheItemPoolInterface $cachePool, ?\Psr\Cache\CacheItemPoolInterface $tagStorePool = null): mixed

Parameters:

Parameter Type Description
$cachePool \Psr\Cache\CacheItemPoolInterface
$tagStorePool ?\Psr\Cache\CacheItemPoolInterface

makeTaggable

public static makeTaggable(\Psr\Cache\CacheItemPoolInterface $cachePool, \Psr\Cache\CacheItemPoolInterface|null $tagStorePool = null): \Qubus\Cache\Psr6\TaggableCacheItemPool
  • This method is static.

Parameters:

Parameter Type Description
$cachePool \Psr\Cache\CacheItemPoolInterface The pool to which to add tagging capabilities
$tagStorePool \Psr\Cache\CacheItemPoolInterface|null The pool to store tags in. If null is passed,
the main pool is used.

getItem

{@inheritdoc}

public getItem(mixed $key): \Qubus\Cache\Psr6\TaggableCacheItem

Parameters:

Parameter Type Description
$key mixed

getItems

{@inheritdoc}

public getItems(array $keys = []): iterable

Parameters:

Parameter Type Description
$keys array

hasItem

{@inheritdoc}

public hasItem(string $key): bool

Parameters:

Parameter Type Description
$key string

clear

{@inheritdoc}

public clear(): bool

deleteItem

{@inheritdoc}

public deleteItem(string $key): bool

Parameters:

Parameter Type Description
$key string

deleteItems

{@inheritdoc}

public deleteItems(array $keys): bool

Parameters:

Parameter Type Description
$keys array

save

{@inheritdoc}

public save(\Qubus\Cache\Psr6\TaggableCacheItem|\Psr\Cache\CacheItemInterface $item): bool

Parameters:

Parameter Type Description
$item \Qubus\Cache\Psr6\TaggableCacheItem|\Psr\Cache\CacheItemInterface

Throws:


saveDeferred

{@inheritdoc}

public saveDeferred(\Qubus\Cache\Psr6\TaggableCacheItem|\Psr\Cache\CacheItemInterface $item): bool

Parameters:

Parameter Type Description
$item \Qubus\Cache\Psr6\TaggableCacheItem|\Psr\Cache\CacheItemInterface

Throws:


commit

{@inheritdoc}

public commit(): bool

appendListItem

protected appendListItem(mixed $name, mixed $value): void

Parameters:

Parameter Type Description
$name mixed
$value mixed

Throws:


removeList

protected removeList(mixed $name): bool

Parameters:

Parameter Type Description
$name mixed

Throws:


removeListItem

protected removeListItem(mixed $name, mixed $key): void

Parameters:

Parameter Type Description
$name mixed
$key mixed

Throws:


getList

protected getList(mixed $name): mixed

Parameters:

Parameter Type Description
$name mixed

Throws:


getTagKey

protected getTagKey(string $tag): string

Parameters:

Parameter Type Description
$tag string

saveTags

private saveTags(\Qubus\Cache\Psr6\TaggablePsr6ItemAdapter $item): void

Parameters:

Parameter Type Description
$item \Qubus\Cache\Psr6\TaggablePsr6ItemAdapter

Throws:


invalidateTags

Invalidates cached items using tags.

public invalidateTags(array $tags): bool

Parameters:

Parameter Type Description
$tags array An array of tags to invalidate

Return Value:

True on success


invalidateTag

Invalidates cached items using a tag.

public invalidateTag(mixed $tag): bool

Parameters:

Parameter Type Description
$tag mixed The tag to invalidate

Return Value:

True on success


preRemoveItem

Removes the key form all tag lists.

private preRemoveItem(string $key): void

Parameters:

Parameter Type Description
$key string

Throws:


removeTagEntries

private removeTagEntries(\Qubus\Cache\Psr6\TaggableCacheItem $item): void

Parameters:

Parameter Type Description
$item \Qubus\Cache\Psr6\TaggableCacheItem

Throws:



Automatically generated on 2025-10-13