index/src/Cache/ICacheBackend.php
2024-04-10 22:23:34 +00:00

37 lines
1.2 KiB
PHP

<?php
// ICacheBackend.php
// Created: 2024-04-10
// Updated: 2024-04-10
namespace Index\Cache;
/**
* Information about a cache provider. Should not have any external dependencies.
*/
interface ICacheBackend {
/**
* Checks whether the driver is available and a provider can be made.
*
* @return bool If true a provider can be made, if false a required extension is missing.
*/
function isAvailable(): bool;
/**
* Creates the cache provider described in the argument.
*
* @param ICacheProviderInfo $providerInfo Object that describes the desired provider.
* @throws \InvalidArgumentException An invalid implementation of ICacheProviderInfo was provided.
* @throws \RuntimeException If you ignored the output of isAvailable and tried to create an instance anyway.
* @return ICacheProvider The provider described in the provider info.
*/
function createProvider(ICacheProviderInfo $providerInfo): ICacheProvider;
/**
* Constructs a cache info instance from a dsn.
*
* @param string|array $dsn DSN with provider information.
* @return ICacheProviderInfo Provider info based on the dsn.
*/
function parseDsn(string|array $dsn): ICacheProviderInfo;
}