By default, Typhoon Reflection uses in-memory LRU cache which should be enough for the majority of use cases.
However, if you need persistent cache, you can use any PSR-16 implementation. We highly recommend Typhoon OPcache. It stores values as opcacheable php files.
use Typhoon\Reflection\TyphoonReflector;
use Typhoon\OPcache\TyphoonOPcache;
$reflector = TyphoonReflector::build(
cache: new TyphoonOPcache('path/to/cache/dir'),
);
To detect file changes during development, decorate your cache with FreshCache.
use Typhoon\Reflection\TyphoonReflector;
use Typhoon\Reflection\Cache\FreshCache;
use Typhoon\OPcache\TyphoonOPcache;
$reflector = TyphoonReflector::build(
cache: new FreshCache(new TyphoonOPcache('path/to/cache/dir')),
);