Documentation

CacheKeyGenerator
in package

Generates unique cache keys for HTTP requests.

Creates cache keys that include the request method, URL, query parameters, and a hash of the authorization header to prevent cross-tenant pollution.

Table of Contents

Properties

$prefix  : string

Methods

__construct()  : mixed
Constructor.
generate()  : string
Generate a cache key for a request.
getAuthHash()  : string
Get a hash of the authorization header.
getOptionsHash()  : string
Get a hash of cache-affecting options.
normalizeUrl()  : string
Normalize the URL for consistent cache keys.

Properties

Methods

__construct()

Constructor.

public __construct([string $prefix = 'canvas' ]) : mixed
Parameters
$prefix : string = 'canvas'

The cache key prefix (default: 'canvas')

generate()

Generate a cache key for a request.

public generate(RequestInterface $request[, array<string, mixed> $options = [] ]) : string
Parameters
$request : RequestInterface

The HTTP request

$options : array<string, mixed> = []

Request options

Return values
string

The generated cache key

getAuthHash()

Get a hash of the authorization header.

private getAuthHash(RequestInterface $request) : string
Parameters
$request : RequestInterface

The request

Return values
string

The auth hash (first 8 characters)

getOptionsHash()

Get a hash of cache-affecting options.

private getOptionsHash(array<string, mixed> $options) : string
Parameters
$options : array<string, mixed>

Request options

Return values
string

The options hash

normalizeUrl()

Normalize the URL for consistent cache keys.

private normalizeUrl(RequestInterface $request) : string
Parameters
$request : RequestInterface

The request

Return values
string

The normalized URL


        
On this page

Search results