4

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?

Colin
  • 675
  • 1
  • 11
  • 32

1 Answers1

9

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
caasig
  • 106
  • 3
  • Wonderful! Thank you for taking the time to explain the reasoning behind it and the dependency. – Colin Dec 06 '19 at 14:36
  • 2
    You're welcome. It just so happens I was also trying to set the cache pool and your question helped me to figure it out so I thought I'd share my findings – caasig Dec 12 '19 at 05:10