Last Updated: February 25, 2016
· gjerokrsteski

Create PHP DBA cache using Oracle Berkeley DB 4 with persistent connection

$cache = new Cache(
  '/your/path/to/the/cahe-file/cache.db4', 'db4'

$yorObject            = new ObjectYouWantToPutInCache();
$yourObjectIdentifier = 'your:cool:object:identifier';

// check if your object is in the cache.
// you also can ignore it, and let the CacheDba do it for you.
if (false == $cache->has($yourObjectIdentifier)) {

$cache->put($yourObjectIdentifier, $yorObject);

// than somewhere at your project.

// for the garbage collection 
// you can create an cron-job starting once a day.
$sweeper = new Sweeper($cache);

// or clean all objects older than given expiration since now.

Read more

Say Thanks