Source of file DriverInterface.php

Size: 1,769 Bytes - Last Modified: 2020-05-08T12:23:11-04:00

../src/Driver/DriverInterface.php

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
<?php declare(strict_types=1);
/**
 * Banker
 *
 * A Caching library implementing psr/cache (PSR 6) and psr/simple-cache (PSR 16)
 *
 * PHP version 7.4
 *
 * @package     Banker
 * @author      Timothy J. Warren <tim@timshomepage.net>
 * @copyright   2016 - 2020  Timothy J. Warren
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
 * @version     3.1.0
 * @link        https://git.timshomepage.net/timw4mail/banker
 */
namespace Aviat\Banker\Driver;

/**
 * Interface for different cache backends
 */
interface DriverInterface {

	/**
	 * See if a key exists in the cache
	 *
	 * @param string $key
	 * @return bool
	 */
	public function exists(string $key): bool;

	/**
	 * Set a cached value
	 *
	 * @param string $key
	 * @param mixed $value
	 * @param int $expires
	 * @return bool
	 */
	public function set(string $key, $value, ?int $expires = 0): bool;

	/**
	 * Get the value for the selected cache key
	 *
	 * @param string $key
	 * @return mixed
	 */
	public function get(string $key);

	/**
	 * Retrieve a set of values by their cache key
	 *
	 * @param string[] $keys
	 * @return array
	 */
	public function getMultiple(array $keys = []): array;

	/**
	 * Remove an item from the cache
	 *
	 * @param string $key
	 * @return boolean
	 */
	public function delete(string $key): bool;

	/**
	 * Remove multiple items from the cache
	 *
	 * @param string[] $keys
	 * @return boolean
	 */
	public function deleteMultiple(array $keys = []): bool;

	/**
	 * Empty the cache
	 *
	 * @return boolean
	 */
	public function flush(): bool;

	/**
	 * Set the specified key to expire at the given time
	 *
	 * @param string $key
	 * @param int $expires
	 * @return boolean
	 */
	public function expiresAt(string $key, int $expires): bool;
}