1
votes

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. If I execute query 2 again later (e.g. 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)?
  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
You can check my answer to a different question, but with same logic: stackoverflow.com/a/40126426/2070270Viktor Livakivskyi

1 Answers

3
votes

The behavior is different for older and newer Typo3 versions. Afaik from Typo3 7.x onwards the cache is always used if you use the default repository queries. 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