[cache]
cache.shared
Sets the network store that Core\Cache::shared uses, where every server process and every machine sees the same values.
url is the address of the store. It has no default. A server that sets no url has no shared cache. The other keys say how the server connects. password is the password, or password_file names a file that contains it. database is the database in the store that the values use. timeout limits the connect and each command, so a store that stops responding cannot block a request.
A rediss:// address uses TLS, and the store's certificate is checked. Three keys make that check less strict, and each needs the host in a list under [capabilities.tls]. tls_pin needs pin. tls_verify_host needs any_name. tls_verify needs insecure. Without that entry, the server does not start.
If a TLS connection fails, the error names the cause and the fix (TLS connections).
A program also needs the capability cache.shared before it can use the store.
Good to know: you can change this block while the server runs. The next request uses the new store, and so does the next scheduled job with scope = "fleet".
Only nvs.toml sets this key. A request may not change it.
A change in the file takes effect a few seconds after you save it. The server does not restart.
The examples below run with this configuration file.
# The shared cache is the Redis server on this computer at port 16379.[cache.shared]url = "redis://127.0.0.1:16379"The store a whole fleet shares
<?nvs// Shows the settings of the network store that every server process and every machine shares.// The server running this program has this block://// [cache.shared]// url = "redis://127.0.0.1:16379"//// The address has no default. A server that sets no `url` has no shared cache.
echo 'store: ', Core\Config::get('cache.shared.url') ?? '(no shared cache)', "\n";
// The other keys have defaults. `database` is the database in the store// that the values use.echo 'database: ', Core\Config::get('cache.shared.database') ?? '(the one the store opens on)', "\n";
// `timeout` limits the connect and each command. This file does not set it,// so the result is the default, `5s`. A store that stops answering cannot block a request.echo 'timeout: ', Core\Config::get('cache.shared.timeout') ?? '(no value)', "\n";
// Set the password with `password`, or with `password_file`. Write only one of the two.// `password_file` names a file that contains the password, which is how a container passes one in.
// Only the person who runs the server chooses the store.// A program cannot move it or shorten its timeout.string $url = 'cache.shared.url';string $timeout = 'cache.shared.timeout';echo 'move: ', Core\Config::set($url, 'redis://elsewhere:6379') ? 'yes' : 'no', "\n";echo 'hurry: ', Core\Config::set($timeout, '5ms') ? 'yes' : 'no', "\n";
// The person who runs the server can change this block while it runs.// The next request then uses the new store. No restart is needed.store: redis://127.0.0.1:16379database: (the one the store opens on)timeout: 5smove: nohurry: noChangelog
| Version | Change |
|---|---|
0.0.6 | A failed TLS connection names its cause, who can fix it and how, as TLS connection errors explains. For an expired certificate, the message gives the date it expired and the time on this host's clock. For a wrong pin, it gives the sha256// hash of the server's public key. |
0.0.6 | The page of each setting says whether a request may change it with Core\Config::set. A page for a block lists the settings in it that a request may change. |
cache.memory
Sets the size limit and the wait time of the memory cache, the one Core\Cache::memory uses.
The memory cache is one store in this server process. Every core of the server uses the same store. max_size is how much memory all its values may use together. The default is 32M. When a new value does not fit, the value written longest ago is forgotten.
fill_wait is for a value that is missing. Several requests may need the same missing secret at the same time. One request fetches it, and the others wait up to fill_wait for that value. The default is 5s. A request that is still waiting after that time gets a TimeoutError.
Good to know: only the person who runs the server may set these two values. A fill_wait of zero is not allowed, and the server does not start with one.
Only nvs.toml sets this key. A request may not change it.
A change in the file takes effect a few seconds after you save it. The server does not restart.
The examples below run with this configuration file.
# The memory cache may use 32M. A request waits up to 5 seconds for another request to fill a key.[cache.memory]max_size = "32M"fill_wait = "5s"One cache for the whole server
<?nvs// Shows the two settings of the memory cache, and that a program cannot change them.// The server running this program has these settings://// [cache.memory]// max_size = "32M"// fill_wait = "5s"
var $cache = Core\Cache::memory();
// Every core of this server reads the same store. This prints `0.92`.$cache->put('rates:eur', '0.92');echo 'eur rate: ', $cache->get('rates:eur') ?? '(fetch it)', "\n";
// `max_size` is the most memory all values in the store may use together.echo 'cap: ', Core\Config::get('cache.memory.max_size') ?? '(no value)', "\n";
// Several requests may call `getSecret` for the same missing value. One fetches it, and the others// wait up to `fill_wait` for that result. After that time, `getSecret` throws a `TimeoutError`.echo 'wait: ', Core\Config::get('cache.memory.fill_wait') ?? '(no value)', "\n";
// Only the person who runs the server may change these settings.// `Core\Config::set` returns `false` both times, so both lines print `no`.string $maxSize = 'cache.memory.max_size';string $fillWait = 'cache.memory.fill_wait';echo 'raise: ', Core\Config::set($maxSize, '1G') ? 'yes' : 'no', "\n";echo 'hurry: ', Core\Config::set($fillWait, '1s') ? 'yes' : 'no', "\n";eur rate: 0.92cap: 32Mwait: 5sraise: nohurry: noChangelog
| Version | Change |
|---|---|
0.0.6 | The page of each setting says whether a request may change it with Core\Config::set. A page for a block lists the settings in it that a request may change. |
