简体   繁体   English

TYPO3 Extbase存储库查询缓存

[英]TYPO3 Extbase Repository Query Cache

I have some questions about caching. 我有一些关于缓存的问题。 Some preconditions first: 一些先决条件首先:

// query 1
$data1 = $this->myRepository->findByPid($myPid);
// query 2
$data2 = $this->myRepository->findOneByUid($myUid);

My questions: 我的问题:

  1. If I execute query 2 several times in a script, the first call retrieves the data from the database, all other from the cache, without querying the database? 如果我在脚本中多次执行查询2,第一次调用将从数据库中检索数据,所有其他数据都从缓存中检索,而不查询数据库?
  2. If I execute query 2 again later (eg in a second script) the data is retrieved again from the database (there is no persistent query cache, except I use the caching framework to store the results of this query)? 如果我稍后再次执行查询2(例如在第二个脚本中),则会再次从数据库中检索数据(除了我使用缓存框架存储此查询的结果之外,没有持久查询缓存)?
  3. If I execute query 1 and then query 2 and query 1 contains the data for uid "$myUid", then the data for query 2 is retrieved from the cache? 如果我执行查询1然后查询2并且查询1包含uid“$ myUid”的数据,那么从缓存中检索查询2的数据?

The behavior is different for older and newer Typo3 versions. 对于较旧和较新的Typo3版本,行为是不同的。 Afaik from Typo3 7.x onwards the cache is always used if you use the default repository queries. 从Typo3 7.x开始,如果您使用默认存储库查询,则始终使用缓存。 After retrieving a dataset from the database it is mapped to a domain object by the property mapper and if the object is already present in the cache it is returned instead. 从数据库中检索数据集后,属性映射器将其映射到域对象,如果该对象已存在于缓存中,则返回该对象。

In Typo3 6.x you would get two different objects for the same uid if you select it with ->findByUid and for example as a controller argument 在Typo3 6.x中,如果使用->findByUid选择它,例如作为控制器参数,则会为同一个uid获取两个不同的对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM