34. The Second Level Cache

Note

ノート

The second level cache functionality is marked as experimental for now. It is a very complex feature and we cannot guarantee yet that it works stable in all cases.

2 番目のレベルのキャッシュ機能は、現時点では実験的なものとしてマークされています。これは非常に複雑な機能であり、すべてのケースで安定して動作することをまだ保証できません。

The Second Level Cache is designed to reduce the amount of necessary database access. It sits between your application and the database to avoid the number of database hits as much as possible.

セカンド レベル キャッシュは、必要なデータベース アクセスの量を減らすように設計されています。データベース ヒット数をできる限り回避するために、アプリケーションとデータベースの間に配置されます。

When turned on, entities will be first searched in cache and if they are not found, a database query will be fired and then the entity result will be stored in a cache provider.

オンにすると、最初にエンティティがキャッシュで検索され、見つからない場合はデータベース クエリが実行され、エンティティの結果がキャッシュ プロバイダーに格納されます。

There are some flavors of caching available, but is better to cache read-only data.

利用可能なキャッシュにはいくつかのフレーバーがありますが、読み取り専用データをキャッシュする方が適しています。

Be aware that caches are not aware of changes made to the persistent store by another application. They can, however, be configured to regularly expire cached data.

キャッシュは、別のアプリケーションによって永続ストアに加えられた変更を認識しないことに注意してください。ただし、キャッシュされたデータを定期的に期限切れにするように構成できます。

34.1. Caching Regions

Second level cache does not store instances of an entity, instead it caches only entity identifier and values. Each entity class, collection association and query has its region, where values of each instance are stored.

第 2 レベル キャッシュはエンティティのインスタンスを格納せず、代わりにエンティティ識別子と値のみをキャッシュします。各エンティティ クラス、コレクションの関連付け、およびクエリには、各インスタンスの値が格納される領域があります。

Caching Regions are specific region into the cache provider that might store entities, collection or queries. Each cache region resides in a specific cache namespace and has its own lifetime configuration.

キャッシュ領域は、エンティティ、コレクション、またはクエリを格納する可能性があるキャッシュ プロバイダーへの特定の領域です。各キャッシュ領域は、特定のキャッシュ名前空間に存在し、独自の有効期間構成を持ちます。

Notice that when caching collection and queries only identifiers are stored. The entity values will be stored in its own region

コレクションとクエリをキャッシュする場合、識別子のみが保存されることに注意してください。エンティティ値は独自のリージョンに保存されます。

Something like below for an entity region:

エンティティ領域については以下のようなもの:

<?php
[
  'region_name:entity_1_hash' => ['id' => 1, 'name' => 'FooBar', 'associationName' => null],
  'region_name:entity_2_hash' => ['id' => 2, 'name' => 'Foo', 'associationName' => ['id' => 11]],
  'region_name:entity_3_hash' => ['id' => 3, 'name' => 'Bar', 'associationName' => ['id' => 22]]
];

If the entity holds a collection that also needs to be cached. An collection region could look something like:

エンティティが、キャッシュも必要なコレクションを保持している場合、コレクション領域は次のようになります。

<?php
[
  'region_name:entity_1_coll_assoc_name_hash' => ['ownerId' => 1, 'list' => [1, 2, 3]],
  'region_name:entity_2_coll_assoc_name_hash' => ['ownerId' => 2, 'list' => [2, 3]],
  'region_name:entity_3_coll_assoc_name_hash' => ['ownerId' => 3, 'list' => [2, 4]]
];

A query region might be something like:

クエリ領域は次のようになります。

<?php
[
  'region_name:query_1_hash' => ['list' => [1, 2, 3]],
  'region_name:query_2_hash' => ['list' => [2, 3]],
  'region_name:query_3_hash' => ['list' => [2, 4]]
];

Note

ノート

The following data structures represents now the cache will looks like, this is not actual cached data.

次のデータ構造は、キャッシュが次のようになることを表していますが、これは実際にキャッシュされたデータではありません。

34.2. Cache Regions

Doctrine\ORM\Cache\Region\DefaultRegion is the default implementation.

A simplest cache region compatible with all doctrine-cache drivers but does not support locking.

すべての doctrine-cache ドライバーと互換性のある最も単純なキャッシュ領域ですが、ロックはサポートしていません。

Doctrine\ORM\Cache\Region and Doctrine\ORM\Cache\ConcurrentRegion define contracts that should be implemented by a cache provider.

Doctrine\ORM\Cache\Region および Doctrine\ORM\Cache\ConcurrentRegion は、キャッシュ プロバイダーによって実装される必要があるコントラクトを定義します。

It allows you to provide your own cache implementation that might take advantage of specific cache driver.

これにより、特定のキャッシュ ドライバーを利用できる独自のキャッシュ実装を提供できます。

If you want to support locking for READ_WRITE strategies you should implement ConcurrentRegion; CacheRegion otherwise.

READ_WRITE 戦略のロックをサポートしたい場合は、ConcurrentRegion を実装する必要があります。それ以外の場合は CacheRegion。

34.2.1. Cache region

Doctrine\ORM\Cache\Region defines a contract for accessing a particular cache region.

Doctrine\ORM\Cache\Region は、特定のキャッシュ領域にアクセスするための契約を定義します。

34.2.2. Concurrent cache region

A Doctrine\ORM\Cache\ConcurrentRegion is designed to store concurrently managed data region. By default, Doctrine provides a very simple implementation based on file locks Doctrine\ORM\Cache\Region\FileLockRegion.

Doctrine\ORM\Cache\ConcurrentRegion は、並行して管理されるデータ領域を格納するように設計されています。デフォルトでは、Doctrine はファイル ロック Doctrine\ORM\Cache\Region\FileLockRegion に基づく非常に単純な実装を提供します。

If you want to use an READ_WRITE cache, you should consider providing your own cache region.

READ_WRITE キャッシュを使用する場合は、独自のキャッシュ領域を提供することを検討する必要があります。

Doctrine\ORM\Cache\ConcurrentRegion defines a contract for concurrently managed data region.

Doctrine\ORM\Cache\ConcurrentRegion は、同時管理されるデータ リージョンのコントラクトを定義します。

34.2.3. Timestamp region

Doctrine\ORM\Cache\TimestampRegion

Doctrine\ORM\Cache\TimestampRegion

Tracks the timestamps of the most recent updates to particular entity.

特定のエンティティに対する最新の更新のタイムスタンプを追跡します。

34.3. Caching mode

  • READ_ONLY (DEFAULT)

    READ_ONLY (デフォルト)

    • Can do reads, inserts and deletes, cannot perform updates or employ any locks.

      読み取り、挿入、および削除を実行できますが、更新を実行したり、ロックを使用したりすることはできません。

    • Useful for data that is read frequently but never updated.

      頻繁に読み取られるが更新されないデータに役立ちます。

    • Best performer.

      最高のパフォーマー。

    • It is Simple.

      簡単です。

  • NONSTRICT_READ_WRITE

    NONSTRICT_READ_WRITE

    • Read Write Cache doesn’t employ any locks but can do reads, inserts, updates and deletes.

      読み取り書き込みキャッシュはロックを使用しませんが、読み取り、挿入、更新、および削除を実行できます。

    • Good if the application needs to update data rarely.

      アプリケーションがデータをめったに更新する必要がない場合に適しています。

  • READ_WRITE

    読み書き

    • Read Write cache employs locks before update/delete.

      読み取り書き込みキャッシュは、更新/削除の前にロックを使用します。

    • Use if data needs to be updated.

      データを更新する必要がある場合に使用します。

    • Slowest strategy.

      最も遅い戦略。

    • To use it a the cache region implementation must support locking.

      これを使用するには、キャッシュ領域の実装でロックがサポートされている必要があります。

34.3.1. Built-in cached persisters

Cached persisters are responsible to access cache regions.

キャッシュされた永続化は、キャッシュ領域へのアクセスを担当します。

Cache Usage

キャッシュの使用

Persister

持続する

READ_ONLY

READ_ONLY

Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister

Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister

READ_WRITE

読み書き

Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister

Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister

NONSTRICT_READ_WRITE

NONSTRICT_READ_WRITE

Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister

Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister

READ_ONLY

READ_ONLY

Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister

Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister

READ_WRITE

読み書き

Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister

Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister

NONSTRICT_READ_WRITE

NONSTRICT_READ_WRITE

Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister

Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister

34.4. Configuration

Doctrine allows you to specify configurations and some points of extension for the second-level-cache

Doctrine を使用すると、二次キャッシュの構成といくつかの拡張ポイントを指定できます

34.4.1. Enable Second Level Cache

To enable the second-level-cache, you should provide a cache factory. Doctrine\ORM\Cache\DefaultCacheFactory is the default implementation.

第 2 レベルのキャッシュを有効にするには、キャッシュ ファクトリを提供する必要があります。Doctrine\ORM\Cache\DefaultCacheFactory がデフォルトの実装です。

<?php
/** @var \Doctrine\ORM\Cache\RegionsConfiguration $cacheConfig */
/** @var \Psr\Cache\CacheItemPoolInterface $cache */
/** @var \Doctrine\ORM\Configuration $config */

$factory = new \Doctrine\ORM\Cache\DefaultCacheFactory($cacheConfig, $cache);

// Enable second-level-cache
$config->setSecondLevelCacheEnabled();

// Cache factory
$config->getSecondLevelCacheConfiguration()
    ->setCacheFactory($factory);

34.4.2. Cache Factory

Cache Factory is the main point of extension.

Cache Factory は、拡張の主要なポイントです。

It allows you to provide a specific implementation of the following components:

これにより、次のコンポーネントの特定の実装を提供できます。

QueryCache

stores and retrieves query cache results.

クエリ キャッシュの結果を格納および取得します。

CachedEntityPersister

stores and retrieves entity results.

エンティティの結果を保存および取得します。

CachedCollectionPersister

stores and retrieves query results.

クエリ結果を保存および取得します。

EntityHydrator

transforms entities into a cache entries and cache entries into entities

エンティティをキャッシュ エントリに変換し、キャッシュ エントリをエンティティに変換します

CollectionHydrator

transforms collections into cache entries and cache entries into collections

コレクションをキャッシュ エントリに変換し、キャッシュ エントリをコレクションに変換します

34.4.3. Region Lifetime

To specify a default lifetime for all regions or specify a different lifetime for a specific region.

すべてのリージョンにデフォルトの有効期間を指定するか、特定のリージョンに別の有効期間を指定します。

<?php
/** @var \Doctrine\ORM\Configuration $config */
/** @var \Doctrine\ORM\Cache\CacheConfiguration $cacheConfig */
/** @var \Doctrine\ORM\Cache\RegionsConfiguration $regionConfig */
$cacheConfig  =  $config->getSecondLevelCacheConfiguration();
$regionConfig =  $cacheConfig->getRegionsConfiguration();

// Cache Region lifetime
$regionConfig->setLifetime('my_entity_region', 3600);   // Time to live for a specific region (in seconds)
$regionConfig->setDefaultLifetime(7200);                // Default time to live (in seconds)

34.4.4. Cache Log

By providing a cache logger you should be able to get information about all cache operations such as hits, misses and puts.

キャッシュロガーを提供することで、ヒット、ミス、プットなどのすべてのキャッシュ操作に関する情報を取得できるはずです。

Doctrine\ORM\Cache\Logging\StatisticsCacheLogger is a built-in implementation that provides basic statistics.

Doctrine\ORM\Cache\Logging\StatisticsCacheLogger は、基本的な統計を提供する組み込みの実装です。

<?php
/** @var \Doctrine\ORM\Configuration $config */
$logger = new \Doctrine\ORM\Cache\Logging\StatisticsCacheLogger();

// Cache logger
$config->setSecondLevelCacheEnabled(true);
$config->getSecondLevelCacheConfiguration()
    ->setCacheLogger($logger);


// Collect cache statistics

// Get the number of entries successfully retrieved from a specific region.
$logger->getRegionHitCount('my_entity_region');

// Get the number of cached entries *not* found in a specific region.
$logger->getRegionMissCount('my_entity_region');

// Get the number of cacheable entries put in cache.
$logger->getRegionPutCount('my_entity_region');

// Get the total number of put in all regions.
$logger->getPutCount();

// Get the total number of entries successfully retrieved from all regions.
$logger->getHitCount();

// Get the total number of cached entries *not* found in all regions.
$logger->getMissCount();

If you want to get more information you should implement Doctrine\ORM\Cache\Logging\CacheLogger and collect all the information you want.

より多くの情報を取得したい場合は、Doctrine\ORM\Cache\Logging\CacheLogger を実装して、必要な情報をすべて収集する必要があります。

34.5. Entity cache definition

  • Entity cache configuration allows you to define the caching strategy and region for an entity.

    エンティティ キャッシュ構成を使用すると、エンティティのキ​​ャッシュ戦略とリージョンを定義できます。

    • usage specifies the caching strategy: READ_ONLY,

      usage はキャッシュ戦略を指定します: READ_ONLY、

NONSTRICT_READ_WRITE, READ_WRITE. See Caching mode.

NONSTRICT_READ_WRITE、READ_WRITE。キャッシング モードを参照してください。

  • region is an optional value that specifies the name of the second

    region は、秒の名前を指定するオプションの値です

level cache region.

レベル キャッシュ領域。

34.6. Association cache definition

The most common use case is to cache entities. But we can also cache relationships. It caches the primary keys of association and cache each element will be cached into its region.

最も一般的な使用例は、エンティティをキャッシュすることです。しかし、関係をキャッシュすることもできます。関連付けの主キーをキャッシュし、各要素をその領域にキャッシュします。

Note

ノート

for this to work, the target entity must also be marked as cacheable.

これが機能するには、ターゲット エンティティもキャッシュ可能としてマークされている必要があります。

34.6.1. Cache usage

Basic entity cache

基本エンティティ キャッシュ

<?php
$em->persist(new Country($name));
$em->flush();                         // Hit database to insert the row and put into cache

$em->clear();                         // Clear entity manager

$country1  = $em->find('Country', 1); // Retrieve item from cache

$country1->setName('New Name');

$em->flush();                         // Hit database to update the row and update cache

$em->clear();                         // Clear entity manager

$country2  = $em->find('Country', 1); // Retrieve item from cache
                                      // Notice that $country1 and $country2 are not the same instance.

Association cache

関連キャッシュ

<?php
// Hit database to insert the row and put into cache
$em->persist(new State($name, $country));
$em->flush();

// Clear entity manager
$em->clear();

// Retrieve item from cache
$state = $em->find('State', 1);

// Hit database to update the row and update cache entry
$state->setName('New Name');
$em->persist($state);
$em->flush();

// Create a new collection item
$city = new City($name, $state);
$state->addCity($city);

// Hit database to insert new collection item,
// put entity and collection cache into cache.
$em->persist($city);
$em->persist($state);
$em->flush();

// Clear entity manager
$em->clear();

// Retrieve item from cache
$state = $em->find('State', 1);

// Retrieve association from cache
$country = $state->getCountry();

// Retrieve collection from cache
$cities = $state->getCities();

echo $country->getName();
echo $state->getName();

// Retrieve each collection item from cache
foreach ($cities as $city) {
    echo $city->getName();
}

Note

ノート

Notice that all entities should be marked as cacheable.

すべてのエンティティをキャッシュ可能としてマークする必要があることに注意してください。

34.7. Using the query cache

The second level cache stores the entities, associations and collections. The query cache stores the results of the query but as identifiers, entity values are actually stored in the 2nd level cache.

第 2 レベルのキャッシュには、エンティティ、関連付け、およびコレクションが格納されます。クエリ キャッシュにはクエリの結果が格納されますが、エンティティの値は実際には識別子として第 2 レベルのキャッシュに格納されます。

Note

ノート

Query cache should always be used in conjunction with the second-level-cache for those entities which should be cached.

クエリ キャッシュは、キャッシュする必要があるエンティティに対して、常に第 2 レベル キャッシュと組み合わせて使用​​する必要があります。

<?php
/** @var \Doctrine\ORM\EntityManager $em */

// Execute database query, store query cache and entity cache
$result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
    ->setCacheable(true)
    ->getResult();

$em->clear();

// Check if query result is valid and load entities from cache
$result2 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
    ->setCacheable(true)
    ->getResult();

34.7.1. Cache mode

The Cache Mode controls how a particular query interacts with the second-level cache:

キャッシュ モードは、特定のクエリが二次キャッシュとどのように相互作用するかを制御します。

  • Cache::MODE_GET - May read items from the cache, but will not add items.

    Cache::MODE_GET - キャッシュから項目を読み取ることができますが、項目を追加しません。

  • Cache::MODE_PUT - Will never read items from the cache, but will add items to the cache as it reads them from the database.

    Cache::MODE_PUT - キャッシュからアイテムを読み取ることはありませんが、データベースからアイテムを読み取るときにアイテムをキャッシュに追加します。

  • Cache::MODE_NORMAL - May read items from the cache, and add items to the cache.

    Cache::MODE_NORMAL - キャッシュから項目を読み取り、キャッシュに項目を追加できます。

  • Cache::MODE_REFRESH - The query will never read items from the cache, but will refresh items to the cache as it reads them from the database.

    Cache::MODE_REFRESH - クエリはキャッシュからアイテムを読み取ることはありませんが、データベースからアイテムを読み取るときにアイテムをキャッシュに更新します。

<?php
/** @var \Doctrine\ORM\EntityManager $em */
// Will refresh the query cache and all entities the cache as it reads from the database.
$result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
    ->setCacheMode(\Doctrine\ORM\Cache::MODE_GET)
    ->setCacheable(true)
    ->getResult();

Note

ノート

The default query cache mode is `Cache::MODE_NORMAL`

デフォルトのクエリ キャッシュ モードは `Cache::MODE_NORMAL` です

34.7.2. DELETE / UPDATE queries

DQL UPDATE / DELETE statements are ported directly into a database and bypass the second-level cache. Entities that are already cached will NOT be invalidated. However the cached data could be evicted using the cache API or an special query hint.

DQL UPDATE / DELETE ステートメントはデータベースに直接移植され、第 2 レベルのキャッシュをバイパスします。既にキャッシュされているエンティティは無効になりません。ただし、キャッシュされたデータは、キャッシュ API または特別なクエリ ヒントを使用して削除できます。

Execute the UPDATE and invalidate all cache entries using Query::HINT_CACHE_EVICT

UPDATE を実行し、Query::HINT_CACHE_EVICT を使用してすべてのキャッシュ エントリを無効にします。

<?php
// Execute and invalidate
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
    ->setHint(\Doctrine\ORM\Query::HINT_CACHE_EVICT, true)
    ->execute();

Execute the UPDATE and invalidate all cache entries using the cache API

UPDATE を実行し、キャッシュ API を使用してすべてのキャッシュ エントリを無効にします。

<?php
// Execute
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
    ->execute();
// Invoke Cache API
$em->getCache()->evictEntityRegion('Entity\Country');

Execute the UPDATE and invalidate a specific cache entry using the cache API

UPDATE を実行し、キャッシュ API を使用して特定のキャッシュ エントリを無効化する

<?php
// Execute
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
    ->execute();
// Invoke Cache API
$em->getCache()->evictEntity('Entity\Country', 1);

34.8. Using the repository query cache

As well as Query Cache all persister queries store only identifier values for an individual query. All persisters use a single timestamp cache region to keep track of the last update for each persister, When a query is loaded from cache, the timestamp region is checked for the last update for that persister. Using the last update timestamps as part of the query key invalidate the cache key when an update occurs.

クエリ キャッシュと同様に、すべての永続化クエリは、個々のクエリの識別子の値のみを格納します。すべての永続化では、単一のタイムスタンプ キャッシュ領域を使用して、各永続化の最終更新を追跡します。クエリがキャッシュから読み込まれると、タイムスタンプ領域がチェックされます。最終更新のタイムスタンプをクエリ キーの一部として使用すると、更新が発生したときにキャッシュ キーが無効になります。

<?php
// load from database and store cache query key hashing the query + parameters + last timestamp cache region..
$entities   = $em->getRepository('Entity\Country')->findAll();

// load from query and entities from cache..
$entities   = $em->getRepository('Entity\Country')->findAll();

// update the timestamp cache region for Country
$em->persist(new Country('zombieland'));
$em->flush();
$em->clear();

// Reload from database.
// At this point the query cache key is no longer valid, the select goes straight to the database
$entities   = $em->getRepository('Entity\Country')->findAll();

34.9. Cache API

Caches are not aware of changes made by another application. However, you can use the cache API to check / invalidate cache entries.

キャッシュは、別のアプリケーションによって行われた変更を認識しません。ただし、キャッシュ API を使用して、キャッシュ エントリをチェック/無効化できます。

<?php
/** @var \Doctrine\ORM\Cache $cache */
$cache = $em->getCache();

$cache->containsEntity('Entity\State', 1)      // Check if the cache exists
$cache->evictEntity('Entity\State', 1);        // Remove an entity from cache
$cache->evictEntityRegion('Entity\State');     // Remove all entities from cache

$cache->containsCollection('Entity\State', 'cities', 1);   // Check if the cache exists
$cache->evictCollection('Entity\State', 'cities', 1);      // Remove an entity collection from cache
$cache->evictCollectionRegion('Entity\State', 'cities');   // Remove all collections from cache

34.10. Limitations

34.10.1. Composite primary key

Composite primary key are supported by second level cache, however when one of the keys is an association the cached entity should always be retrieved using the association identifier. For performance reasons the cache API does not extract from composite primary key.

複合主キーは第 2 レベルのキャッシュでサポートされていますが、キーの 1 つが関連付けである場合、キャッシュされたエンティティは常に関連付け ID を使用して取得する必要があります。パフォーマンス上の理由から、キャッシュ API は複合主キーから抽出しません。

<?php

#[Entity]
class Reference
{
    #[Id]
    #[ManyToOne(targetEntity: Article::class, inversedBy: 'references')]
    #[JoinColumn(name: 'source_id', referencedColumnName: 'article_id')]
    private Article|null $source = null;

    #[Id]
    #[ManyToOne(targetEntity: Article::class, inversedBy: 'references')]
    #[JoinColumn(name: 'target_id', referencedColumnName: 'article_id')]
    private $target;
}

// Supported
/** @var Article $article */
$article = $em->find('Article', 1);

// Supported
/** @var Article $article */
$article = $em->find('Article', $article);

// Supported
$id        = ['source' => 1, 'target' => 2];
$reference = $em->find('Reference', $id);

// NOT Supported
$id        = ['source' => new Article(1), 'target' => new Article(2)];
$reference = $em->find('Reference', $id);

34.10.2. Distributed environments

Some cache driver are not meant to be used in a distributed environment. Load-balancer for distributing workloads across multiple computing resources should be used in conjunction with distributed caching system such as memcached, redis, riak …

一部のキャッシュ ドライバーは、分散環境での使用を意図していません。複数のコンピューティング リソースにワークロードを分散するためのロード バランサーは、memcached、redis、riak などの分散キャッシュ システムと組み合わせて使用​​する必要があります。

Caches should be used with care when using a load-balancer if you don’t share the cache. While using APC or any file based cache update occurred in a specific machine would not reflect to the cache in other machines.

キャッシュを共有しない場合、ロード バランサーを使用する場合はキャッシュを慎重に使用する必要があります。

34.10.3. Paginator

Count queries generated by Doctrine\ORM\Tools\Pagination\Paginator are not cached by second-level cache. Although entities and query result are cached, count queries will hit the database every time.

Doctrine\ORM\Tools\Pagination\Paginator によって生成されたカウント クエリは、2 次キャッシュによってキャッシュされません。エンティティとクエリ結果はキャッシュされますが、カウント クエリは毎回データベースにヒットします。

Table Of Contents

Previous topic

33. Advanced Configuration

33.高度な設定

Next topic

35. Security

35. セキュリティ

This Page

Fork me on GitHub