Open michaelgrosser opened 8 years ago
The problem is that if I intercept the false return value on the call to get(), then you won't be able to store the value false in redis as it would always return null.
The way I see it, there are two options: 1) A has() method is added to Illuminate\Contracts\Cache\Store. Then instead of comparing the return value of get() it would call has() (which would then call exists() on the redis connection). But that would invalidate all the implementations of cache stores, so this is not likely to happen... 2) On every call to get(), I can call exists() first, and if that returns false, then return null instead of calling get. But that would mean you have to call an extra command basically for each get() call.
Of course, 2 is the only viable option really because of the implications of 1. Do you think it would be a good idea even though it adds the call to exists() for each call to get()?
So, the problem comes down to the fact that php-redis' get() method returns either the cached item or BOOL (false) when the key is not set. The Laravel cache store and cache repsitory, however expect the cached item or NULL. When it gets false instead of NULL, it considers that a valid response and passes it up the chain, never triggering the callback in Repository::remember(). Because of this, nothing ever gets cached.
Let me know if you need any further detail.