-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Cache] Implement psr/cache 3 #41290
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,10 +97,8 @@ public function delete(string $key): bool | |
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return bool | ||
*/ | ||
public function hasItem($key) | ||
public function hasItem($key): bool | ||
{ | ||
if (\is_string($key) && isset($this->expiries[$key]) && $this->expiries[$key] > microtime(true)) { | ||
if ($this->maxItems) { | ||
|
@@ -120,7 +118,7 @@ public function hasItem($key) | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getItem($key) | ||
public function getItem($key): CacheItem | ||
{ | ||
if (!$isHit = $this->hasItem($key)) { | ||
$value = null; | ||
|
@@ -139,7 +137,7 @@ public function getItem($key) | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getItems(array $keys = []) | ||
public function getItems(array $keys = []): iterable | ||
{ | ||
\assert(self::validateKeys($keys)); | ||
|
||
|
@@ -148,10 +146,8 @@ public function getItems(array $keys = []) | |
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return bool | ||
*/ | ||
public function deleteItem($key) | ||
public function deleteItem($key): bool | ||
{ | ||
\assert('' !== CacheItem::validateKey($key)); | ||
unset($this->values[$key], $this->expiries[$key]); | ||
|
@@ -161,10 +157,8 @@ public function deleteItem($key) | |
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return bool | ||
*/ | ||
public function deleteItems(array $keys) | ||
public function deleteItems(array $keys): bool | ||
{ | ||
foreach ($keys as $key) { | ||
$this->deleteItem($key); | ||
|
@@ -175,10 +169,8 @@ public function deleteItems(array $keys) | |
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return bool | ||
*/ | ||
public function save(CacheItemInterface $item) | ||
public function save(CacheItemInterface $item): bool | ||
{ | ||
if (!$item instanceof CacheItem) { | ||
return false; | ||
|
@@ -230,30 +222,24 @@ public function save(CacheItemInterface $item) | |
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return bool | ||
*/ | ||
public function saveDeferred(CacheItemInterface $item) | ||
public function saveDeferred(CacheItemInterface $item): bool | ||
{ | ||
return $this->save($item); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return bool | ||
*/ | ||
public function commit() | ||
public function commit(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return bool | ||
*/ | ||
public function clear(string $prefix = '') | ||
public function clear(string $prefix = ''): bool | ||
{ | ||
if ('' !== $prefix) { | ||
$now = microtime(true); | ||
|
@@ -276,10 +262,8 @@ public function clear(string $prefix = '') | |
|
||
/** | ||
* Returns all cached values, with cache miss as null. | ||
* | ||
* @return array | ||
*/ | ||
public function getValues() | ||
public function getValues(): array | ||
{ | ||
if (!$this->storeSerialized) { | ||
return $this->values; | ||
|
@@ -306,7 +290,7 @@ public function reset() | |
$this->clear(); | ||
} | ||
|
||
private function generateItems(array $keys, $now, $f) | ||
private function generateItems(array $keys, $now, $f): \Generator | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all additions to private (and final if any) methods should be split on a lower branch |
||
{ | ||
foreach ($keys as $i => $key) { | ||
if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > $now || !$this->deleteItem($key))) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.