Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PSR Cache version 3.0 #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"php": ">=7.4",
"cache/adapter-common": "^1.0",
"cache/hierarchical-cache": "^1.0",
"psr/cache": "^1.0 || ^2.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/simple-cache": "^1.0"
},
"require-dev": {
Expand All @@ -41,11 +41,13 @@
"prefer-stable": true,
"autoload": {
"psr-4": {
"Cache\\Adapter\\PHPArray\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
"Cache\\Adapter\\PHPArray\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Cache\\Adapter\\PHPArray\\Tests\\": "Tests"
}
},
"extra": {
"branch-alias": {
Expand Down
16 changes: 8 additions & 8 deletions ArrayCachePool.php → src/ArrayCachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function getItemWithoutGenerateCacheKey($key)
/**
* {@inheritdoc}
*/
protected function fetchObjectFromCache($key)
protected function fetchObjectFromCache(string $key): array
{
$keys = $this->getHierarchyKey($key);

Expand All @@ -96,7 +96,7 @@ protected function fetchObjectFromCache($key)
/**
* {@inheritdoc}
*/
protected function clearAllObjectsFromCache()
protected function clearAllObjectsFromCache(): bool
{
$this->cache = [];

Expand All @@ -106,7 +106,7 @@ protected function clearAllObjectsFromCache()
/**
* {@inheritdoc}
*/
protected function clearOneObjectFromCache($key)
protected function clearOneObjectFromCache(string $key): bool
{
$this->commit();
$keys = $this->getHierarchyKey($key);
Expand All @@ -120,7 +120,7 @@ protected function clearOneObjectFromCache($key)
/**
* {@inheritdoc}
*/
protected function storeItemInCache(PhpCacheItem $item, $ttl)
protected function storeItemInCache(PhpCacheItem $item, null|int|\DateInterval $ttl): bool
{
$keys = $this->getHierarchyKey($item->getKey());
$value = $item->get();
Expand Down Expand Up @@ -158,7 +158,7 @@ protected function getDirectValue($key)
/**
* {@inheritdoc}
*/
protected function getList($name)
protected function getList(string $name): iterable
{
if (!isset($this->cache[$name])) {
$this->cache[$name] = [];
Expand All @@ -170,7 +170,7 @@ protected function getList($name)
/**
* {@inheritdoc}
*/
protected function removeList($name)
protected function removeList(string $name): bool
{
unset($this->cache[$name]);

Expand All @@ -180,15 +180,15 @@ protected function removeList($name)
/**
* {@inheritdoc}
*/
protected function appendListItem($name, $key)
protected function appendListItem(string $name, string $key)
{
$this->cache[$name][] = $key;
}

/**
* {@inheritdoc}
*/
protected function removeListItem($name, $key)
protected function removeListItem(string $name, string $key)
{
if (isset($this->cache[$name])) {
foreach ($this->cache[$name] as $i => $item) {
Expand Down