Update Simple Cache

This commit is contained in:
Visman 2023-09-16 18:51:06 +07:00
parent 59dbdd47b1
commit 128692b4c7
8 changed files with 48 additions and 48 deletions

View file

@ -47,7 +47,7 @@ class FileCache implements CacheInterface
/**
* Получает данные из кэша по ключу
*/
public function get($key, $default = null)
public function get(string $key, mixed $default = null): mixed
{
$file = $this->path($key);
@ -71,7 +71,7 @@ class FileCache implements CacheInterface
/**
* Устанавливает данные в кэш по ключу
*/
public function set($key, $value, $ttl = null)
public function set(string $key, mixed $value, null|int|DateInterval $ttl = null): bool
{
$file = $this->path($key);
@ -96,7 +96,7 @@ class FileCache implements CacheInterface
/**
* Удаляет данные по ключу
*/
public function delete($key)
public function delete(string $key): bool
{
$file = $this->path($key);
@ -115,7 +115,7 @@ class FileCache implements CacheInterface
/**
* Очищает папку кэша от php файлов (рекурсивно)
*/
public function clear()
public function clear(): bool
{
$dir = new RecursiveDirectoryIterator($this->cacheDir, RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new RecursiveIteratorIterator($dir);
@ -132,7 +132,7 @@ class FileCache implements CacheInterface
/**
* Получает данные по списку ключей
*/
public function getMultiple($keys, $default = null)
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
$this->validateIterable($keys);
@ -147,7 +147,7 @@ class FileCache implements CacheInterface
/**
* Устанавливает данные в кэш по списку ключ => значение
*/
public function setMultiple($values, $ttl = null)
public function setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool
{
$this->validateIterable($keys);
@ -162,7 +162,7 @@ class FileCache implements CacheInterface
/**
* Удаляет данные по списку ключей
*/
public function deleteMultiple($keys)
public function deleteMultiple(iterable $keys): bool
{
$this->validateIterable($keys);
@ -177,7 +177,7 @@ class FileCache implements CacheInterface
/**
* Проверяет кеш на наличие ключа
*/
public function has($key)
public function has(string $key): bool
{
$file = $this->path($key);

View file

@ -25,7 +25,7 @@
"ext-pdo": "*",
"miovisman/parserus": "^1.2.1",
"miovisman/normemail": "^1.0.0",
"psr/simple-cache": "^1.0.1",
"psr/simple-cache": "^3",
"psr/log": "^1.1.3",
"miovisman/jevix": "^2.2.0"
},

20
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "fc088b2693e7c23a32d1a94bf397e0d5",
"content-hash": "bca6e4c5d1ef3c85d9a4fc1d5d356c2f",
"packages": [
{
"name": "miovisman/jevix",
@ -212,25 +212,25 @@
},
{
"name": "psr/simple-cache",
"version": "1.0.1",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"php": ">=8.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "3.0.x-dev"
}
},
"autoload": {
@ -245,7 +245,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interfaces for simple caching",
@ -257,9 +257,9 @@
"simple-cache"
],
"support": {
"source": "https://github.com/php-fig/simple-cache/tree/master"
"source": "https://github.com/php-fig/simple-cache/tree/3.0.0"
},
"time": "2017-10-23T01:57:42+00:00"
"time": "2021-10-29T13:26:27+00:00"
}
],
"packages-dev": [],

View file

@ -218,27 +218,27 @@
},
{
"name": "psr/simple-cache",
"version": "1.0.1",
"version_normalized": "1.0.1.0",
"version": "3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865",
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"php": ">=8.0.0"
},
"time": "2017-10-23T01:57:42+00:00",
"time": "2021-10-29T13:26:27+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "3.0.x-dev"
}
},
"installation-source": "dist",
@ -254,7 +254,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interfaces for simple caching",
@ -266,7 +266,7 @@
"simple-cache"
],
"support": {
"source": "https://github.com/php-fig/simple-cache/tree/master"
"source": "https://github.com/php-fig/simple-cache/tree/3.0.0"
},
"install-path": "../psr/simple-cache"
}

View file

@ -56,12 +56,12 @@
'dev_requirement' => false,
),
'psr/simple-cache' => array(
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/simple-cache',
'aliases' => array(),
'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865',
'dev_requirement' => false,
),
),

View file

@ -6,11 +6,11 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"require": {
"php": ">=5.3.0"
"php": ">=8.0.0"
},
"autoload": {
"psr-4": {
@ -19,7 +19,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "3.0.x-dev"
}
}
}

View file

@ -5,6 +5,6 @@ namespace Psr\SimpleCache;
/**
* Interface used for all types of exceptions thrown by the implementing library.
*/
interface CacheException
interface CacheException extends \Throwable
{
}

View file

@ -15,7 +15,7 @@ interface CacheInterface
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function get($key, $default = null);
public function get(string $key, mixed $default = null): mixed;
/**
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
@ -31,7 +31,7 @@ interface CacheInterface
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function set($key, $value, $ttl = null);
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool;
/**
* Delete an item from the cache by its unique key.
@ -43,28 +43,28 @@ interface CacheInterface
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function delete($key);
public function delete(string $key): bool;
/**
* Wipes clean the entire cache's keys.
*
* @return bool True on success and false on failure.
*/
public function clear();
public function clear(): bool;
/**
* Obtains multiple cache items by their unique keys.
*
* @param iterable $keys A list of keys that can obtained in a single operation.
* @param mixed $default Default value to return for keys that do not exist.
* @param iterable<string> $keys A list of keys that can be obtained in a single operation.
* @param mixed $default Default value to return for keys that do not exist.
*
* @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
* @return iterable<string, mixed> A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
*
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if $keys is neither an array nor a Traversable,
* or if any of the $keys are not a legal value.
*/
public function getMultiple($keys, $default = null);
public function getMultiple(iterable $keys, mixed $default = null): iterable;
/**
* Persists a set of key => value pairs in the cache, with an optional TTL.
@ -80,12 +80,12 @@ interface CacheInterface
* MUST be thrown if $values is neither an array nor a Traversable,
* or if any of the $values are not a legal value.
*/
public function setMultiple($values, $ttl = null);
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool;
/**
* Deletes multiple cache items in a single operation.
*
* @param iterable $keys A list of string-based keys to be deleted.
* @param iterable<string> $keys A list of string-based keys to be deleted.
*
* @return bool True if the items were successfully removed. False if there was an error.
*
@ -93,7 +93,7 @@ interface CacheInterface
* MUST be thrown if $keys is neither an array nor a Traversable,
* or if any of the $keys are not a legal value.
*/
public function deleteMultiple($keys);
public function deleteMultiple(iterable $keys): bool;
/**
* Determines whether an item is present in the cache.
@ -110,5 +110,5 @@ interface CacheInterface
* @throws \Psr\SimpleCache\InvalidArgumentException
* MUST be thrown if the $key string is not a legal value.
*/
public function has($key);
public function has(string $key): bool;
}