MCP PHP SDK

CachePolicy

FinalYes

How long, and to whom, a server's answers may be cached (SEP-2549).

The default says "do not cache": ttlMs: 0 and private. That is the honest answer for a server nobody has told us about — public lets a shared proxy serve one caller's answer to another, which is a disclosure decision only the operator can make.

Granularity is per method, because that is what the caching hint describes: a tools/list is usually identical for everyone and worth a long public TTL, while a resources/read usually is not.

Tags
author

Christopher Hertel mail@christopher-hertel.de

Table of Contents

Properties

$perMethod  : array<string|int, mixed>
$scope  : CacheScope
$ttlMs  : int

Methods

default()  : self
none()  : self
The conservative default: nothing is fresh, nothing is shared.
scopeFor()  : CacheScope
ttlFor()  : int
withMethod()  : self
Overrides the policy for one method.
__construct()  : mixed

Properties

$perMethod read-only

private array<string|int, mixed> $perMethod = []

Methods

none()

The conservative default: nothing is fresh, nothing is shared.

public static none() : self
Return values
self

ttlFor()

public ttlFor(string $method) : int
Parameters
$method : string
Return values
int

withMethod()

Overrides the policy for one method.

public withMethod(string $method, int $ttlMs[, CacheScope $scope = CacheScope::Private ]) : self

Only the methods the specification makes cacheable are worth naming; any other is accepted and simply never consulted.

Parameters
$method : string
$ttlMs : int
$scope : CacheScope = CacheScope::Private
Return values
self

__construct()

private __construct(int $ttlMs, CacheScope $scope[, array<string, CacheScope}$perMethod = [] ]) : mixed
Parameters
$ttlMs : int
$scope : CacheScope
$perMethod : array<string, CacheScope}> = []
On this page

Search results