ImageCacheInterface

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

Table of contents

Namespace: Com\Tecnick\Pdf\Image

File: ImageCacheInterface.php line 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])).

Tags

Methods

get()

File: ImageCacheInterface.php line 61

public get(string $key) : ImageRawData|null

Parameters

  • $key : string: Image cache key.

Return values

ImageRawData|null —

Stored image data array, or null on a miss.

set()

File: ImageCacheInterface.php line 69

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

Parameters

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