Proxy Cache Adapter

This adapter wraps a PSR-6 compliant cache item pool interface. It is used to integrate your application's cache item pool implementation with the Symfony Cache Component by consuming any implementation of Psr\Cache\CacheItemPoolInterface.

このアダプターは、PSR-6 準拠のキャッシュ項目プール インターフェイスをラップします。これは、Psr\Cache\CacheItemPoolInterface の実装を消費することにより、アプリケーションのキャッシュ アイテム プールの実装を Symfony キャッシュ コンポーネントと統合するために使用されます。

It can also be used to prefix all keys automatically before storing items in the decorated pool, effectively allowing the creation of several namespaced pools out of a single one.

また、装飾されたプールに項目を格納する前に、すべてのキーに自動的にプレフィックスを付けるために使用することもできます。これにより、単一のプールから複数の名前空間付きプールを効果的に作成できます。

This adapter expects a Psr\Cache\CacheItemPoolInterface instance as its first parameter, and optionally a namespace and default cache lifetime as its second and third parameters:

このアダプターは、最初のパラメーターとして Psr\Cache\CacheItemPoolInterface インスタンスを想定し、オプションで、2 番目と 3 番目のパラメーターとして名前空間と既定のキャッシュの有効期間を想定しています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ProxyAdapter;

// create your own cache pool instance that implements
// the PSR-6 CacheItemPoolInterface
$psr6CachePool = ...

$cache = new ProxyAdapter(

    // a cache pool instance
    CacheItemPoolInterface $psr6CachePool,

    // a string prefixed to the keys of the items stored in this cache
    $namespace = '',

    // the default lifetime (in seconds) for cache items that do not define their
    // own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
    // until the cache is cleared)
    $defaultLifetime = 0
);