Class: MemcacheExt extends Memcache

Extends Memcache with a method that takes a key, timeout, and a function that will be called to produce the value if it is not found in the cache.

Based on Zane Ashby's idea posted here:


No properties.


public cache ($key, $timeout, $function)

Takes a callback function that generates the value if it's not found in the cache.

  • $key - Cache key
  • $timeout - Seconds to cache for
  • $function - Callback function to generate cache data

Returns the data from cache, or from the callback and caches the results for the next call.