问题
I note there is a cache.psr6 container alias but if I use:
new Cache
As the instance, I get an error that getItems isn't available, which, I assume, means I am not passing a PSR-6 compliant cache instance. I'm using Redis if that changes the config in any way.
Is there an additional configuration to be done or am I passing this the wrong way?
The library I am using is: https://github.com/AlexaCRM/dynamics-webapi-toolkit/wiki/Tutorial
And the tutorial states:
You can optionally supply a PSR-6 compliant cache adapter.
$settings->cachePool = $cacheAdapter;
My question is, what is $cacheAdapter?
回答1:
The adapter would be a Psr16Adapter over a cache driver which is how cache.psr6
is bound in the default CacheServiceProvider.
If you have redis configured as your default cache driver you would only need to set your cache pool to cache.psr6
.
$settings->cachePool = app('cache.psr6');
However you may run into a Class 'Symfony\Component\Cache\Adapter\Psr16Adapter' not found
error since symfony/cache
is only a dev dependency in laravel/framework
. You can resolve this by requiring it in your application.
composer require symfony/cache
来源:https://stackoverflow.com/questions/59198899/how-to-pass-a-psr-6-compliant-cache-adapter-in-laravel-6-x