Application caching (PSR-16)¶
The (app) caching is bolted-in and always on. The default cache library is Koded Simple Cache.
Application caching
The cache functionality is available in the user app by simply demanding an instance of PSR-16 Psr\SimpleCache\CacheInterface
instance. The DI container will inject the configured cache client.
<?php
...
public function something(CacheInterface $cache) {
// ...
}
...
Setup cache¶
Caching configuration is done in the application configuration for the App
instance.
<?php
return [
'caching' => [
//
]
];
<?php
new App(config: 'config.php');
Memory¶
Default cache is Memory
and does not require a special treatment. It will provide caching for the duration of the request which is useful for development and unit testing.
Memory (default)
No need to set anything in the configuration. This is the default caching client.