23 lines
538 B
PHP
23 lines
538 B
PHP
<?php
|
|||
|
|
declare( strict_types=1 );
|
||
|
|
|
||
|
|
namespace StreamGoals\PayPal;
|
||
|
|
|
||
|
|
/** In-memory cache (tests, or a fallback). Ignores TTL expiry within a request. */
|
||
|
|
final class ArrayCache implements Cache {
|
||
|
|
|
||
|
|
/** @var array<string,mixed> */
|
||
|
|
private array $items = array();
|
||
|
|
|
||
|
|
public function get( string $key ): mixed {
|
||
|
|
return $this->items[ $key ] ?? false;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function set( string $key, mixed $value, int $ttl ): void {
|
||
|
|
$this->items[ $key ] = $value;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function delete( string $key ): void {
|
||
|
|
unset( $this->items[ $key ] );
|
||
|
|
}
|
||
|
|
}
|