When does the SDK hit the network
PHP-FPM per-request model
In PHP-FPM, each HTTP request boots a fresh PHP process. The in-memory cache is empty at the start of every request and
NexusClient::create makes a blocking network call on every request. The TTL has no effect across requests because there is no shared memory.Recommendation: register the client in a DI container with request scope (the default in Symfony/Laravel) so the cache is built once per request and all service classes share it within that request.ETag / 304 protocol
Every successful sync stores the server’sETag header. The next sync sends If-None-Match: <etag>. If nothing has changed:
Background sync errors
Background TTL syncs never throw exceptions to the caller. If the network call fails:- The error is logged via the configured PSR-3 logger at the
errorlevel. - The existing cache continues to be served.
- The next read after the TTL elapses retries automatically.
Error-never-clears-cache rule
The SDK never empties the cache on a sync failure. Even aNexusBillingException or NexusRateLimitedException leaves the last-known-good snapshot intact. This is intentional: it is safer to serve potentially stale config values than to serve nothing.
Cache lifetime
The cache lives for the lifetime of theNexusClient object.
- FPM/HTTP workers - cache lives for one request (PHP process is recycled after the response).
- CLI daemons / queue workers - cache lives for the lifetime of the process.
File-type secrets
Secrets withtype = 'file' are materialised to a temp file on every sync:
0600.
Temp files are deleted when the NexusClient object is garbage-collected (__destruct). In FPM, this happens at the end of each request.
