4 ms·
Y U NO USE your cache like that: $data = $cache->get('key',function() { // do the stuff if cache misses return $some_value_to_be_cached; }); ? It'
by shepik 15y ago
Y U NO USE your cache like that:
$data = $cache->get('key',function() {
// do the stuff if cache misses
return $some_value_to_be_cached;
});
? It's quite handy and it forces you to separate actual logic to get the value, which is good by itself.
- antihero 15y agoThat's a cool idea, but I wouldn't want to lose the scope as you would with a closure. I will look into seeing if it's possible, though.
- shepik 15y agoYep, but i you can call "loosing the scope" as "specifying data dependencies explicitly" :) It all depends on a use case, though.
- gordonslondon 15y agoThat not just a cool idea, that's essential to a cache system. What if you want store FALSE in your cache? You will get a miss everytime your cache key is accessed.