Exemplo n.º 1
0
 /**
  * Force cache cleanup
  *
  * Force a check, if the cache currently exceeds its given size limit. If
  * this is the case this method will start cleaning up the cache.
  *
  * Depending on the used meta data storage and the size of the cache this
  * operation might take some time.
  *
  * @return void
  */
 public static function forceCleanup()
 {
     if (self::$path === null) {
         throw new vcsCacheNotInitializedException();
     }
     self::$metaDataHandler->cleanup(self::$size, self::$cleanupRate);
 }
 /**
  * Construct cache from cache storage root
  *
  * @param string $root
  * @return void
  */
 public function __construct($root)
 {
     parent::__construct($root);
     // Check for existance of meta data storage file
     if (!file_exists($storage = $this->root . '/cacheSize')) {
         file_put_contents($storage, '0');
     }
     $this->storage = $storage;
 }
Exemplo n.º 3
0
 /**
  * Construct cache from cache storage root
  * 
  * @param string $root 
  * @return void
  */
 public function __construct($root)
 {
     parent::__construct($root);
     // Check for existance of meta data storage file
     if (!file_exists($dbFile = $this->root . '/metadata.db')) {
         // Create cache directory, if not yet existing
         if (!is_dir($this->root)) {
             mkdir($this->root, 0750, true);
         }
         // Create the table with appropriate indexes, if the table does not
         // yet exist
         $db = new SQLite3($dbFile);
         $db->query('CREATE TABLE metadata (
             path TEXT PRIMARY KEY,
             size NUMERIC,
             accessed NUMERIC
         )');
         $db->query('CREATE INDEX size ON metadata ( size )');
         $db->query('CREATE INDEX accessed ON metadata ( accessed )');
     }
     $this->db = new SQLite3($dbFile);
 }