Table of contents
Namespace: Com\Tecnick\Pdf\Cache
interface CacheInterface
Source: src/Cache/CacheInterface.php:56
Optional external cache that tc-lib-pdf reuses across the sub-libraries that support caching (font subsets and processed images).
A single implementation of this contract can be passed to the Tcpdf constructor and is internally adapted to each sub-library’s own cache interface, so the same backend (filesystem, APCu, Redis, a PSR-16 cache, …) serves every cacheable subsystem with one connection and one configuration.
No concrete implementation is shipped: the backend, its (de)serialization, expiration and size limits are the application’s responsibility. Implementations MUST be best-effort and MUST NOT throw on a miss or a transient backend failure.
Keys are already namespaced and schema-versioned by each sub-library (e.g. “tc-lib-pdf-font:subset:v2:…” and “tc-lib-pdf-image:v2:…”), so a single shared store is collision-safe.
Security: the cache store is a trust boundary. Cached values are embedded verbatim into generated PDFs, so anyone able to write to the backend can influence document output. Use a store only your application can write to, and when an implementation deserializes data it MUST disable object restoration (e.g. unserialize($s, [‘allowed_classes’ => false])).
Constants
TYPE_FONT
Cacheable subsystem type: TrueType font subset programs.
public const TYPE_FONT = 'font'
Source: src/Cache/CacheInterface.php:61
TYPE_IMAGE
Cacheable subsystem type: processed image data.
public const TYPE_IMAGE = 'image'
Source: src/Cache/CacheInterface.php:66
Methods
get()
Retrieve a previously stored value, or null on a miss.
public get(string $key): mixed
Parameters:
$key(string): Cache key.
Returns: mixed: Stored value, or null when absent.
Source: src/Cache/CacheInterface.php:75
set()
Store a value.
public set(string $key, mixed $value): void
Parameters:
$key(string): Cache key.$value(mixed): Value to store.
Source: src/Cache/CacheInterface.php:83