Exemple #1
0
 /**
  * @constructor mdb_base
  * @param object mdb_config $config OPTIONAL override default config
  */
 public function __construct(mdb_config $config = null)
 {
     parent::__construct();
     if ($config) {
         foreach ($config as $key => $value) {
             $this->{$key} = $value;
         }
     }
     $this->logger = new imdb_logger($this->debug);
     $this->cache = new imdb_cache($this, $this->logger);
     if ($this->storecache && $this->cache_expire > 0) {
         $this->cache->purge();
     }
 }
Exemple #2
0
 public function test_purge()
 {
     $path = realpath(dirname(__FILE__) . '/cache') . '/purge';
     @mkdir($path);
     $config = new mdb_config();
     $config->usezip = false;
     $config->cachedir = $path . '/';
     $config->cache_expire = 1000;
     $cache = new imdb_cache($config, new imdb_logger());
     touch("{$path}/test-old", time() - 1002);
     touch("{$path}/test-new");
     $cache->purge();
     $this->assertTrue(file_exists("{$path}/test-new"));
     $this->assertFalse(file_exists("{$path}/test-old"));
     unlink("{$path}/test-new");
     rmdir($path);
 }