Storing Null In Cache #52449
Unanswered
kellerjmrtn
asked this question in
General
Replies: 1 comment
-
|
I'd go with Cache:;get('key')?:null. I completely agree with you... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
According to PSR-16 (which
Illuminate\Cache\Repositoryimplements)If a
nullvalue is fundamentally indistinguishable from simply not setting the value at all, is there any reason to set anullvalue? For example (using Redis store, for example)Despite the key physically being set in Redis, it's seemingly indistinguishable from a key that was never set:
Therefore, does it even make sense to set a
nullvalue in cache in the first place? Admittedly I don't know implementation specifics, so it's possible not doing so could cause some undesired behavior somewhere that I'm unaware of. But it seems like avoiding settingnullcould potentially have a few (minor) performance benefits:put,remember, etcSuggested Change
Since
Illuminate\Cache\Repositorydoes set a real key/value pair in cache when the value isnull, I'm suggesting/wondering whether it makes sense to update that implementation to simply not set the key/value pair at allBeta Was this translation helpful? Give feedback.
All reactions