♻️ Refactor cache flushing to clear entire groups

This commit is contained in:
Philipp Stracker 2025-03-26 17:55:11 +01:00
parent c89c602776
commit 37532fa0dd
No known key found for this signature in database

View file

@ -113,23 +113,16 @@ class ApiModule implements ServiceModule, ExtendingModule, ExecutableModule {
'woocommerce_paypal_payments_flush_api_cache', 'woocommerce_paypal_payments_flush_api_cache',
static function () use ( $c ) { static function () use ( $c ) {
$caches = array( $caches = array(
'api.paypal-bearer-cache' => array( 'api.paypal-bearer-cache',
PayPalBearer::CACHE_KEY, 'api.client-credentials-cache',
), 'settings.service.signup-link-cache',
'api.client-credentials-cache' => array(
SdkClientToken::CACHE_KEY,
),
); );
foreach ( $caches as $cache_id => $keys ) { foreach ( $caches as $cache_id ) {
$cache = $c->get( $cache_id ); $cache = $c->get( $cache_id );
assert( $cache instanceof Cache ); assert( $cache instanceof Cache );
foreach ( $keys as $key ) { $cache->flush();
if ( $cache->has( $key ) ) {
$cache->delete( $key );
}
}
} }
} }
); );