mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
♻️ Refactor cache flushing to clear entire groups
This commit is contained in:
parent
c89c602776
commit
37532fa0dd
1 changed files with 5 additions and 12 deletions
|
@ -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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue