store = $store; } /** * Read the cached {@see ProviderHealthStatus}, or null on * miss / expired / malformed envelope. * * @param string $key Cache key. */ public function get( string $key ): ?ProviderHealthStatus { $entry = $this->store->getRaw( $key ); if ( null === $entry ) { return null; } $value = $entry->value(); if ( ! $value instanceof ProviderHealthStatus ) { // Defensive: a non-ProviderHealthStatus value would only // occur if the underlying transient envelope were // tampered with; treat it as a miss rather than // surfacing a typed payload that violates the // ProviderHealthCache::get() contract. return null; } return $value; } /** * Write the {@see ProviderHealthStatus} with the given TTL in * seconds. Delegates TTL validation to * {@see TransientsCacheStore::putRaw()}. * * @param string $key Cache key. * @param ProviderHealthStatus $status Health snapshot to store. * @param int $ttlSeconds TTL in seconds; must be > 0. */ public function put( string $key, ProviderHealthStatus $status, int $ttlSeconds ): void { $this->store->putRaw( $key, $status, $ttlSeconds ); } /** * Remove the entry stored under `$key`. Idempotent. * * @param string $key Cache key. */ public function forget( string $key ): void { $this->store->forget( $key ); } /** * Phase-9-MVP no-op (delegates to * {@see TransientsCacheStore::flush()}, which documents why * Transients cannot be enumerated without a `$wpdb`-backed * sweep that this slice does not introduce). */ public function flush(): void { $this->store->flush(); } }