Cache miss resolves with null value by WyriHaximus · Pull Request #22 · reactphp/cache · GitHub
Skip to content

Cache miss resolves with null value#22

Merged
WyriHaximus merged 1 commit into
reactphp:masterfrom
WyriHaximus-labs:implement-13
Feb 15, 2018
Merged

Cache miss resolves with null value#22
WyriHaximus merged 1 commit into
reactphp:masterfrom
WyriHaximus-labs:implement-13

Conversation

@WyriHaximus

@WyriHaximus WyriHaximus commented Feb 5, 2018

Copy link
Copy Markdown
Member

As discussed in #13, a failing get should resolve with null instead of rejecting.

To do:

  • Updated interface
  • Updated ArrayCache
  • Updated Readme

Implements / closes #13

@WyriHaximus WyriHaximus added this to the v0.5.0 milestone Feb 5, 2018
@WyriHaximus WyriHaximus requested review from clue and jsor February 5, 2018 22:01
@WyriHaximus WyriHaximus changed the title [WIP] Failing get should resolve with null Failing get should resolve with null Feb 5, 2018
@WyriHaximus

WyriHaximus commented Feb 5, 2018

Copy link
Copy Markdown
Member Author

@clue clue added the BC break label Feb 6, 2018
Comment thread README.md Outdated
[promises](https://github.com/reactphp/promise).

If the key `foo` does not exist, the promise will be rejected.
If the key `foo` does not exist, the promise will be resolve with null as value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[…] the promise will resolve with null as value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'd be even more explicit:

[…] the promise will fulfill with null as value.

Comment thread README.md Outdated
exist in the cache.
First an attempt is made to retrieve the value of `foo`. A callback function is
registered that will call `getFooFromDb` when the resulting value is null.
`getFooFromDb` is afunction (can be any PHP callable) that will be called if the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

afunction -> a function

Comment thread README.md Outdated
->then(null, array($this, 'getAndCacheFooFromDb'))
->then(function ($result) {
if ($result === null) {
return $this->getFooFromDb();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Must be getAndCacheFooFromDb()

WyriHaximus added a commit to WyriHaximus-labs/cache that referenced this pull request Feb 7, 2018
WyriHaximus added a commit to WyriHaximus-labs/cache that referenced this pull request Feb 7, 2018
WyriHaximus added a commit to WyriHaximus-labs/cache that referenced this pull request Feb 7, 2018
Comment thread README.md Outdated
[promises](https://github.com/reactphp/promise).

If the key `foo` does not exist, the promise will be rejected.
If the key `foo` does not exist, the promise will fullfill with `null` as value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor typo fulfill, maybe even use will be fulfilled here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed 👍

WyriHaximus added a commit to WyriHaximus-labs/cache that referenced this pull request Feb 10, 2018
@clue clue changed the title Failing get should resolve with null Cache miss resolves with null value Feb 15, 2018

@clue clue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes LGTM, can you squash this to a reasonable number of commits before merging? :shipit: 👍

@WyriHaximus

Copy link
Copy Markdown
Member Author

@WyriHaximus WyriHaximus merged commit 3792eaf into reactphp:master Feb 15, 2018
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.

Semantics of get() on cache miss

3 participants