This repository was archived by the owner on Aug 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +55
-1
lines changed
Expand file tree Collapse file tree 3 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ protected function runCommand($command) {
112112 $ args = array_slice ($ this ->cli_args ['_DEFAULT ' ], 2 );
113113 $ method = new ReflectionMethod (get_class ($ this ), $ command );
114114
115- //check number of required arguments
115+ //check number of required arguments
116116 if ($ method ->getNumberOfRequiredParameters () !== count ($ args )) {
117117 throw new InvalidArgumentException ('Wrong number of arguments ' );
118118 }
@@ -177,6 +177,20 @@ public function cacheClearpagecacheCommand() {
177177 $ this ->outputLine ('Page cache cleared ' );
178178 }
179179
180+ /**
181+ * Clear all caches except the page cache.
182+ * This is especially useful on big sites when you can't just drop the page cache
183+ *
184+ * @example ./cli_dispatch.phpsh coreapi cache:clearallexceptpagecache
185+ * @return void
186+ */
187+ public function clearAllExceptPageCacheCommand () {
188+ $ cacheApiService = $ this ->getCacheApiService ();
189+ $ clearedCaches = $ cacheApiService ->clearAllExceptPageCache ();
190+
191+ $ this ->outputLine ('Cleared caches: ' . implode (', ' , $ clearedCaches ));
192+ }
193+
180194 /**
181195 * Database compare
182196 *
Original file line number Diff line number Diff line change @@ -68,6 +68,20 @@ public function clearPageCacheCommand() {
6868
6969 $ this ->outputLine ('Page cache has been cleared. ' );
7070 }
71+
72+ /**
73+ * Clear all caches except the page cache.
74+ * This is especially useful on big sites when you can't just drop the page cache
75+ *
76+ * @return void
77+ */
78+ public function clearAllExceptPageCacheCommand () {
79+ /** @var $service Tx_Coreapi_Service_CacheApiService */
80+ $ service = $ this ->objectManager ->get ('Tx_Coreapi_Service_CacheApiService ' );
81+ $ clearedCaches = $ service ->clearAllExceptPageCache ();
82+
83+ $ this ->outputLine ('Cleared caches: ' . implode (', ' , $ clearedCaches ));
84+ }
7185}
7286
7387?>
Original file line number Diff line number Diff line change @@ -77,6 +77,32 @@ public function clearConfigurationCache() {
7777 }
7878 $ this ->tce ->clear_cacheCmd ('temp_cached ' );
7979 }
80+
81+ /**
82+ * Clear all caches except the page cache.
83+ * This is especially useful on big sites when you can't just drop the page cache
84+ *
85+ * @return array with list of cleared caches
86+ */
87+ public function clearAllExceptPageCache () {
88+ $ out = array ();
89+ $ cacheKeys = array_keys ($ GLOBALS ['TYPO3_CONF_VARS ' ]['SYS ' ]['caching ' ]['cacheConfigurations ' ]);
90+ $ ignoredCaches = array ('cache_pages ' , 'cache_pagesection ' );
91+
92+ $ toBeFlushed = array_diff ($ cacheKeys , $ ignoredCaches );
93+
94+ /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
95+ $ cacheManager = $ GLOBALS ['typo3CacheManager ' ];
96+ foreach ($ cacheKeys as $ cacheKey ) {
97+ if ($ cacheManager ->hasCache ($ cacheKey )) {
98+ $ out [] = $ cacheKey ;
99+ $ singleCache = $ cacheManager ->getCache ($ cacheKey );
100+ $ singleCache ->flush ();
101+ }
102+ }
103+
104+ return $ toBeFlushed ;
105+ }
80106}
81107
82108?>
You can’t perform that action at this time.
0 commit comments