When developing an extension, I'd like to cache some data to avoid the expense of re-calculating it. Is there a civicrm version of the Drupal's caching interface for developers?
I found the corresponding reference page here:
- Set a cache value with Civi::cache()->set('mykey', 'myvalue');
- Get a cached value with Civi::cache()->get('mykey');
- Delete a cached value with Civi::cache()->delete('mykey');
- Flush the entire cache with Civi::cache()->flush();
As far as I know, the civicrm caching schema is pretty simple, there's just one key/value table.
As an aside - I just discovered that Herb @ freeform has contributed a recent patch for using Redis as the cache backend. I'm a Redis fan also, so thanks Herb!