44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
// ArrayCacheBackend.php
|
|
// Created: 2024-04-10
|
|
// Updated: 2024-04-10
|
|
|
|
namespace Index\Cache\ArrayCache;
|
|
|
|
use InvalidArgumentException;
|
|
use Index\Cache\{ICacheBackend,ICacheProvider,ICacheProviderInfo};
|
|
|
|
/**
|
|
* Information about the dummy cache backend.
|
|
*/
|
|
class ArrayCacheBackend implements ICacheBackend {
|
|
public function isAvailable(): bool {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Creates a dummy cache provider.
|
|
*
|
|
* @param ArrayCacheProviderInfo $providerInfo Dummy provider info.
|
|
* @return ArrayCacheProvider Dummy provider instance.
|
|
*/
|
|
public function createProvider(ICacheProviderInfo $providerInfo): ICacheProvider {
|
|
if(!($providerInfo instanceof ArrayCacheProviderInfo))
|
|
throw new InvalidArgumentException('$providerInfo must by of type ArrayCacheProviderInfo');
|
|
|
|
return new ArrayCacheProvider;
|
|
}
|
|
|
|
/**
|
|
* Constructs a cache info instance from a dsn.
|
|
*
|
|
* ArrayCache has no parameters that can be controlled using the DSN.
|
|
*
|
|
* @param string|array $dsn DSN with provider information.
|
|
* @return ArrayCacheProviderInfo Dummy provider info instance.
|
|
*/
|
|
public function parseDsn(string|array $dsn): ICacheProviderInfo {
|
|
return new ArrayCacheProviderInfo;
|
|
}
|
|
}
|