KMP PHP API Reference

TenantAwareCache
in package
implements TenantAwareCacheInterface

Prefixes cache keys by tenant while preserving single-tenant keys without context.

New tenant-scoped cache code should use this service instead of raw Cache:: calls. Use readPlatform()/writePlatform() only for data intentionally shared by all tenants.

Table of Contents

Interfaces

TenantAwareCacheInterface
Tenant-safe facade for application cache access.

Properties

$requireTenantContext  : bool

Methods

__construct()  : mixed
Constructor.
add()  : bool
Add to the active tenant scope when absent.
delete()  : bool
Delete from the active tenant scope.
deletePlatform()  : bool
Delete from the shared platform scope.
platformKey()  : string
Build a platform-scoped key shared across tenants.
platformScopedKey()  : string
Build a platform-scoped cache key shared across tenants.
read()  : mixed
Read from the active tenant scope.
readPlatform()  : mixed
Read from the shared platform scope.
remember()  : mixed
Read or compute a value in the active tenant scope.
tenantKey()  : string
Build a tenant-scoped key for the active tenant.
tenantScopedKey()  : string
Build a tenant-scoped cache key without requiring service construction.
write()  : bool
Write to the active tenant scope.
writePlatform()  : bool
Write to the shared platform scope.
clean()  : string
Sanitize tenant metadata for cache keys.

Properties

$requireTenantContext read-only

private bool $requireTenantContext = false

Methods

__construct()

Constructor.

public __construct([bool $requireTenantContext = false ]) : mixed
Parameters
$requireTenantContext : bool = false

add()

Add to the active tenant scope when absent.

public add(string $key, mixed $value[, string $config = 'default' ]) : bool
Parameters
$key : string
$value : mixed
$config : string = 'default'
Return values
bool

delete()

Delete from the active tenant scope.

public delete(string $key[, string $config = 'default' ]) : bool
Parameters
$key : string
$config : string = 'default'
Return values
bool

deletePlatform()

Delete from the shared platform scope.

public deletePlatform(string $key[, string $config = 'default' ]) : bool
Parameters
$key : string
$config : string = 'default'
Return values
bool

platformKey()

Build a platform-scoped key shared across tenants.

public platformKey(string $key) : string
Parameters
$key : string
Return values
string

platformScopedKey()

Build a platform-scoped cache key shared across tenants.

public static platformScopedKey(string $key) : string
Parameters
$key : string
Return values
string

read()

Read from the active tenant scope.

public read(string $key[, string $config = 'default' ]) : mixed
Parameters
$key : string
$config : string = 'default'

readPlatform()

Read from the shared platform scope.

public readPlatform(string $key[, string $config = 'default' ]) : mixed
Parameters
$key : string
$config : string = 'default'

remember()

Read or compute a value in the active tenant scope.

public remember(string $key, Closure $default[, string $config = 'default' ]) : mixed
Parameters
$key : string
$default : Closure
$config : string = 'default'

tenantKey()

Build a tenant-scoped key for the active tenant.

public tenantKey(string $key) : string
Parameters
$key : string
Return values
string

tenantScopedKey()

Build a tenant-scoped cache key without requiring service construction.

public static tenantScopedKey(string $key[, bool $requireTenantContext = false ]) : string
Parameters
$key : string
$requireTenantContext : bool = false
Return values
string

write()

Write to the active tenant scope.

public write(string $key, mixed $value[, string $config = 'default' ]) : bool
Parameters
$key : string
$value : mixed
$config : string = 'default'
Return values
bool

writePlatform()

Write to the shared platform scope.

public writePlatform(string $key, mixed $value[, string $config = 'default' ]) : bool
Parameters
$key : string
$value : mixed
$config : string = 'default'
Return values
bool

clean()

Sanitize tenant metadata for cache keys.

private static clean(string $value) : string
Parameters
$value : string
Return values
string
On this page

Search results