Fork me on GitHub
Subscribe 2

Ticket #657 (fixed enhancement)

Simpler cache accessor

  • Created: 2012-04-11 11:18:09
  • Reported by: Franz
  • Assigned to: Franz
  • Milestone: 2.0-alpha1
  • Component: caching
  • Priority: normal

There's quite a lot of boilerplate code required for everything that's cached.

Since we require PHP 5.3, we can provide lambda functions to the Cache retrieval function that will only be executed if the requested item does not exist.

Like so:

$value = \fluxbb\cache\Cache::remember('key', function() {
    return 'something to be cached';

For reference, I shamelessly stole this code from the Laravel PHP framework:


Franz 2012-04-11 12:01:56

Implemented (not sure why the commit does not show up).

Now for actually making use of this in the v2.0 core...

arw 2012-04-11 12:32:04

tracker must only catch fluxbb/fluxbb

Franz 2012-04-11 14:25:59

It should also get the commits on the library repos (just look at some other tickets or the timeline).

Well, I'll investigate...

Franz 2012-04-11 14:48:41

  • Summary changed from Simpler cache accessors to Simpler cache accessor.

Franz 2012-04-11 21:34:04

Commit f56bc04 to fluxbb fluxbb-2.0

#657: Use new remember() function for more compact code where cache is used.

Franz 2012-04-12 09:11:09

  • Status changed from open to fixed.

Done, I think.