Skip to content

Add cache expiration support (TTL) #29

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 2 commits into from
Jun 8, 2018
Merged

Add cache expiration support (TTL) #29

merged 2 commits into from
Jun 8, 2018

Conversation

clue
Copy link
Member

@clue clue commented Jun 8, 2018

This PR adds support for cache expiry (TTL). This is a new feature for most consumers, but this is also a BC break because it adds a new parameter to the CacheInterface::set($name, $value, $ttl = null) signature.

As its name implies, the ArrayCache uses an array to store the optional TTL and will yield a cache miss when a cache item is expired.

Builds on top of #28, thank you @WyriHaximus for the initial version! I've squashed the original version to a single commit to preserve authorship. Unlike the initial version, this updated version uses an array for significantly faster operation (heavily inspired by reactphp/event-loop#164).

Supersedes / closes #28
Resolves / closes #11

@clue clue added this to the v0.5.0 milestone Jun 8, 2018
@WyriHaximus WyriHaximus requested review from jsor and WyriHaximus June 8, 2018 11:54
README.md Outdated
@@ -55,15 +57,25 @@ This example fetches the value of the key `foo` and passes it to the

#### set()

The `set(string $key, mixed $value, ?float $ttl = null): PromiseInterface` method can be used to
stores an item in the cache.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stores -> store

README.md Outdated
The `set(string $key, mixed $value, ?float $ttl = null): PromiseInterface` method can be used to
stores an item in the cache.

This method will resolve with a true on success or false when an error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a true

Copy link
Member

@WyriHaximus WyriHaximus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@clue
Copy link
Member Author

clue commented Jun 8, 2018

@jsor Good catch, updated! :shipit:

@clue clue merged commit 6136d21 into reactphp:master Jun 8, 2018
@clue clue deleted the ttl branch June 8, 2018 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Support TTL
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy