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

[5.4] insist on not considering false as cache miss #17476

Merged
merged 1 commit into from
Jan 22, 2017

Conversation

halaei
Copy link
Contributor

@halaei halaei commented Jan 22, 2017

I also note a minor bug: there is a difference in the way values are unserialized in RedisStore::get() and RedisStore::many().

This PR also fix that. I think I should send another PR for laravel 5.1 with the related tests if you give me a day.

@GrahamCampbell
Copy link
Member

Just keeping this on 5.4 is probably fine.

@taylorotwell taylorotwell merged commit d35e6b1 into laravel:5.4 Jan 22, 2017
@tillkruss
Copy link
Contributor

tillkruss commented Jan 22, 2017

This needs to be reverted.

@taylorotwell: Not checking for false in Cache/Repository::has() will lead to false-negatives when using PhpRedis. No matter if the cache key exists, it will always return true.

If you want to allow false as a cache value, #17196 needs to be merged.

@taylorotwell
Copy link
Member

Sigh. All this stuff is driving me batty :|

@halaei
Copy link
Contributor Author

halaei commented Jan 22, 2017

@tillkruss I don't get it! Sounds like you wrong! Please take a look at changes in RedisStore::get() and RedisStore::unserialize() first!

@tillkruss
Copy link
Contributor

@halaei Did you test your PR against Cache::has() using PhpRedis?

@halaei
Copy link
Contributor Author

halaei commented Jan 22, 2017

@tillkruss Ok. The communication between us is a little bit messed up, and I am really confused.

@tillkruss
Copy link
Contributor

tillkruss commented Jan 22, 2017

PhpRedis returns false if a cache key doesn't exists. Predis returns null. We need to support both cases. Taylor will probably merge #17196 to fix this issue.

@halaei
Copy link
Contributor Author

halaei commented Jan 22, 2017

    protected function unserialize($value)
    {
        if (! is_null($value) && $value !== false) {
            return is_numeric($value) ? $value : unserialize($value);
        }
    }

This was the trick!
@tillkruss

@halaei
Copy link
Contributor Author

halaei commented Jan 22, 2017

@tillkruss tests pass under phpredis

@tillkruss
Copy link
Contributor

Can you test it manually, I'm not sure if we have a test case for that yet.

@halaei
Copy link
Contributor Author

halaei commented Jan 22, 2017

I think you mean RedisCacheIntegrationTest::testRedisCacheAddTwice()` for example. That passes when I change InteractsWithRedis to use phpredis instead of predis.

:( My RIP PR is reverted by mistake ;)

@tillkruss
Copy link
Contributor

You're right. However it's nicer to solve this on the driver level with #17196.

@halaei
Copy link
Contributor Author

halaei commented Jan 23, 2017 via email

@tillkruss
Copy link
Contributor

That's not gonna be necessary anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants