We are looking for strong, experienced Senior PHP Developer/Symfony. We expect him/her to participate in improving and extending a system built using microservice architecture by means of modern technologies.

Adapters For Interoperability between PSR-6 and PSR-16 Cache

Sometimes, you may have a Cache object that implements the PSR-16
standard, but need to pass it to an object that expects a PSR-6
cache adapter. Or, you might have the opposite situation. The cache component contains
two classes for bidirectional interoperability between PSR-6 and PSR-16 caches.

Suppose you want to work with a class that requires a PSR-6 Cache pool object. For
example:

1
2
3
4
5
6
7
8
9
10
11
12
13

usePsr\Cache\CacheItemPoolInterface;// just a made-up class for the exampleclassGitHubApiClient{// ...// this requires a PSR-6 cache objectpublicfunction__construct(CacheItemPoolInterface$cachePool){// ...}}

But, you already have a PSR-16 cache object, and you'd like to pass this to the class
instead. No problem! The Cache component provides the
SimpleCacheAdapter class for exactly
this use-case:

1
2
3
4
5
6
7
8
9
10
11

useSymfony\Component\Cache\Simple\FilesystemCache;useSymfony\Component\Cache\Adapter\SimpleCacheAdapter// the PSR-16 cache object that you want to use$psr16Cache=newFilesystemCache();// a PSR-6 cache that uses your cache internally!$psr6Cache=newSimpleCacheAdapter($psr16Cache);// now use this wherever you want$githubApiClient=newGitHubApiClient($psr6Cache);

Suppose you want to work with a class that requires a PSR-16 Cache object. For
example:

1
2
3
4
5
6
7
8
9
10
11
12
13

usePsr\SimpleCache\CacheInterface;// just a made-up class for the exampleclassGitHubApiClient{// ...// this requires a PSR-16 cache objectpublicfunction__construct(CacheInterface$cache){// ...}}

But, you already have a PSR-6 cache pool object, and you'd like to pass this to
the class instead. No problem! The Cache component provides the
Psr6Cache class for exactly
this use-case:

1
2
3
4
5
6
7
8
9
10
11

useSymfony\Component\Cache\Adapter\FilesystemAdapter;useSymfony\Component\Cache\Simple\Psr6Cache;// the PSR-6 cache object that you want to use$psr6Cache=newFilesystemAdapter();// a PSR-16 cache that uses your cache internally!$psr16Cache=newPsr6Cache($psr6Cache);// now use this wherever you want$githubApiClient=newGitHubApiClient($psr16Cache);