banker/src/Driver/DriverInterface.php

99 lines
2.0 KiB
PHP
Raw Normal View History

2016-10-19 09:57:06 -04:00
<?php declare(strict_types=1);
2016-08-31 12:18:46 -04:00
/**
2016-09-05 16:43:37 -04:00
* Banker
2016-08-31 12:18:46 -04:00
*
* A Caching library implementing psr/cache (PSR 6) and psr/simple-cache (PSR 16)
2016-08-31 12:18:46 -04:00
*
2021-11-30 11:56:15 -05:00
* PHP version 8+
2016-08-31 12:18:46 -04:00
*
2016-09-05 16:43:37 -04:00
* @package Banker
2016-08-31 12:18:46 -04:00
* @author Timothy J. Warren <tim@timshomepage.net>
2023-03-16 13:09:36 -04:00
* @copyright 2016 - 2023 Timothy J. Warren
2016-08-31 12:18:46 -04:00
* @license http://www.opensource.org/licenses/mit-license.html MIT License
2023-03-16 13:09:36 -04:00
* @version 4.1.0
2016-09-05 16:43:37 -04:00
* @link https://git.timshomepage.net/timw4mail/banker
2016-08-31 12:18:46 -04:00
*/
namespace Aviat\Banker\Driver;
use DateInterval;
2016-08-31 12:18:46 -04:00
/**
* Interface for different cache backends
*/
interface DriverInterface {
2016-09-05 16:43:37 -04:00
2016-08-31 12:18:46 -04:00
/**
2016-09-05 16:43:37 -04:00
* See if a key exists in the cache
2016-08-31 12:18:46 -04:00
*
2016-10-19 09:57:06 -04:00
* @param string $key
2016-09-05 16:43:37 -04:00
* @return bool
*/
2016-10-19 09:57:06 -04:00
public function exists(string $key): bool;
2016-09-05 16:43:37 -04:00
/**
* Set a cached value
2016-08-31 12:18:46 -04:00
*
* @param string $key
2016-09-05 16:43:37 -04:00
* @param mixed $value
* @param DateInterval|int|null $expires
2020-05-07 17:17:03 -04:00
* @return bool
2016-09-05 16:43:37 -04:00
*/
public function set(string $key, mixed $value, DateInterval|int|null $expires = NULL): bool;
2016-10-19 09:57:06 -04:00
2016-09-05 16:43:37 -04:00
/**
* Get the value for the selected cache key
2016-08-31 12:18:46 -04:00
*
2016-09-05 16:43:37 -04:00
* @param string $key
* @return mixed
*/
public function get(string $key): mixed;
2016-09-05 16:43:37 -04:00
/**
* Retrieve a set of values by their cache key
2016-08-31 12:18:46 -04:00
*
2016-09-05 16:43:37 -04:00
* @param string[] $keys
* @return array
2016-08-31 12:18:46 -04:00
*/
2016-10-19 09:57:06 -04:00
public function getMultiple(array $keys = []): array;
/**
* Set multiple cache values
*
* @param array $items
* @param int|null $expires
* @return bool
*/
public function setMultiple(array $items, ?int $expires = NULL): bool;
2016-09-05 16:43:37 -04:00
/**
* Remove an item from the cache
*
* @param string $key
* @return boolean
*/
2016-10-19 09:57:06 -04:00
public function delete(string $key): bool;
2016-09-05 16:43:37 -04:00
/**
* Remove multiple items from the cache
*
* @param string[] $keys
* @return boolean
*/
2016-10-19 09:57:06 -04:00
public function deleteMultiple(array $keys = []): bool;
2016-09-05 16:43:37 -04:00
/**
* Empty the cache
*
* @return boolean
*/
2016-10-19 09:57:06 -04:00
public function flush(): bool;
2016-09-06 17:03:43 -04:00
/**
* Set the specified key to expire at the given time
*
* @param string $key
* @param int $expires
* @return boolean
*/
2016-10-19 09:57:06 -04:00
public function expiresAt(string $key, int $expires): bool;
2016-08-31 12:18:46 -04:00
}