PHP code example of gjerokrsteski / php-dba-cache

1. Go to this page and download the library: Download gjerokrsteski/php-dba-cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gjerokrsteski / php-dba-cache example snippets


$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 (true === $cache->has($yourObjectIdentifier)) {
  $cache->delete($yourObjectIdentifier);
}

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

// than somewhere at your project.
$cache->get($yourObjectIdentifier);

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

// or clean all objects older than given expiration since now.
$sweep->old();

$string = "<?xml version='1.0'