1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Core\Schema\Result;
15:
16: use Nexus\Assert\Assert;
17: use Nexus\Mcp\Core\Schema\Enum\CacheScope;
18: use Nexus\Mcp\Core\Schema\MetaObject;
19: use Nexus\Mcp\Core\Schema\Result;
20:
21: /**
22: * A result that supports a time-to-live (TTL) hint for client-side caching.
23: *
24: * @template-covariant T of array<string, mixed>
25: *
26: * @extends Result<T>
27: *
28: * @see https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/draft/schema.ts
29: */
30: abstract readonly class CacheableResult extends Result
31: {
32: public function __construct(
33: public int $ttlMs,
34: public CacheScope $cacheScope,
35: MetaObject $meta = new MetaObject(),
36: ) {
37: Assert::that($this->ttlMs)->isNaturalInt('"result.ttlMs" must be a non-negative integer, {value} given.');
38:
39: parent::__construct(meta: $meta);
40: }
41: }
42: