use transient to store auth token

This commit is contained in:
David Remer 2020-04-09 12:27:08 +03:00
parent 38e105b00c
commit d554fafab9

View file

@ -20,8 +20,7 @@ class Bearer
public function bearer() : string
{
//ToDo: Do not store with wp_cache_get but as transient.
$bearer = wp_cache_get(self::CACHE_KEY);
$bearer = get_transient(self::CACHE_KEY);
if (! $bearer) {
return $this->newBearer();
}
@ -50,7 +49,7 @@ class Bearer
throw new RuntimeException(__('Could not find token.', 'woocommerce-paypal-commerce-gateway'));
}
$token = (string) $json->access_token;
wp_cache_set(self::CACHE_KEY, $token, $json->expires_in);
set_transient(self::CACHE_KEY, $token, $json->expires_in);
return $token;
}
}