-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@jsor Good catch, updated! |
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