[BUGFIX] Flush all cache tags in bulk when deleting records 37/50537/24
authorClaus Due <claus@namelesscoder.net>
Mon, 7 Nov 2016 16:09:35 +0000 (17:09 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 6 Dec 2016 08:26:09 +0000 (09:26 +0100)
commitb8621ebfe2b65826d25e80519209e5420df436a8
tree6a1581acfce27d2f0f6fc15f9c6ea81778a49000
parente664996d6eb096555496774658093bf220566933
[BUGFIX] Flush all cache tags in bulk when deleting records

This patch makes the TYPO3 DB cache backend capable of
flushing tags using an array of tag names that is then turned
into a CSV list and used in an `IN` query. It limits the number
of cache flushes from $numRecords to ceil($numRecords/100).

NB: the desired behavior is introduced by reviving the
flushByTags() method as API for cache frontends and backends.
The method was previously present but was dropped in order to
keep sync with Flow - which then later added the method exactly
because of performance concerns.

TYPO3 however did not revive this method and obviously the sync
with Flow is no longer a concern. So this patch restores the
full API required to flush tags in bulk, adds an implementation
for the TYPO3 DB cache backend and adds delegation to the old
flushByTag method for backends not covered by this patch.

It will be possible to improve other backends as well but this
patch focuses exclusively on the DB cache backend for *NIX,
which is where the bad performance was observed in the wild.

Change-Id: I99d4dd8d0881c3bf9f6240e84b083b72b1831779
Resolves: #78596
Releases: master
Reviewed-on: https://review.typo3.org/50537
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
21 files changed:
typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php
typo3/sysext/core/Classes/Cache/Backend/TaggableBackendInterface.php
typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php
typo3/sysext/core/Classes/Cache/CacheManager.php
typo3/sysext/core/Classes/Cache/Frontend/AbstractFrontend.php
typo3/sysext/core/Classes/Cache/Frontend/FrontendInterface.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Tests/Unit/Cache/Backend/ApcBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/ApcuBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/MemcachedBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/PdoBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/TransientMemoryBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/Typo3DatabaseBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/WincacheBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/CacheManagerTest.php
typo3/sysext/core/Tests/Unit/Cache/Fixtures/FrontendFixture.php
typo3/sysext/core/Tests/Unit/Cache/Frontend/AbstractFrontendTest.php
typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php
typo3/sysext/extbase/Classes/Service/CacheService.php
typo3/sysext/extbase/Tests/Unit/Service/CacheServiceTest.php