Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


That'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.


Yep, but i you can call "loosing the scope" as "specifying data dependencies explicitly" :) It all depends on a use case, though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: