ImageCacheInterface

External cache used to persist processed image data across Import instances and PHP processes.

Table of contents

Namespace: Com\Tecnick\Pdf\Image

interface ImageCacheInterface

Source: src/ImageCacheInterface.php:52

External cache used to persist processed image data across Import instances and PHP processes.

Implementations bridge to any backend (filesystem, APCu, Redis, a PSR-16 cache, …). They store and retrieve plain arrays; (de)serialization and eviction are the backend’s responsibility.

The cached value is the import-time snapshot of an image and never contains PDF object numbers, which are assigned per document at output time. Both methods MUST be best-effort and MUST NOT throw on a miss or on a backend failure.

Security: the cache store is a trust boundary. The stored arrays (image data, palette and ICC bytes) are embedded verbatim into generated PDFs. Use a store only the application can write to, and when an implementation deserializes data it MUST disable object restoration (e.g. unserialize($s, [‘allowed_classes’ => false])).

Methods

get()

Retrieve a previously stored image data array.

public get(string $key): ImageRawData|null

Parameters:

  • $key (string): Image cache key.

Returns: ImageRawData|null: Stored image data array, or null on a miss.

Source: src/ImageCacheInterface.php:61

set()

Store an image data array.

public set(string $key, ImageRawData $data): void

Parameters:

  • $key (string): Image cache key.
  • $data (ImageRawData): Image data array to store.

Source: src/ImageCacheInterface.php:69