mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
use transient to store auth token
This commit is contained in:
parent
38e105b00c
commit
d554fafab9
1 changed files with 2 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue