Beispiel #1
0
    function cachedir()
    {
        $system =& $GLOBALS['system'];
        $this->db =& $system->database();
        $this->totalBytes = 15 << 20;
        $row = $this->db->selectrow('select sum(cache_size) as size from sdb_cachedir');
        if (false === $row) {
            $this->db->exec('drop table if exists sdb_cachedir', 1, 1);
            $sql = <<<EOF
create table sdb_cachedir
(
   cache_file                     varchar(32)                    not null,
   cache_size                     mediumint unsigned             not null,
   last_update                    int unsigned                   not null,
   primary key (cache_file)
)type = MyISAM
EOF;
            $this->db->exec($sql, 1, 1);
        } else {
            $this->curBytes = $row['size'];
            if ($row['size'] > $this->totalBytes) {
                $this->_free(10, $row['size'] - $this->totalBytes);
            }
        }
        parent::cachemgr();
    }
Beispiel #2
0
 function memcached()
 {
     if (!class_exists('Memcache')) {
         trigger_error('Missing php_memcache module', E_USER_ERROR);
     }
     $this->obj = new Memcache();
     if (!$this->obj->connect(MEMCACHED_HOST, MEMCACHED_PORT)) {
         trigger_error('Can\'t connect memcached server', E_USER_ERROR);
     }
     parent::cachemgr();
 }
Beispiel #3
0
 function cache_memcache()
 {
     if (!class_exists('Memcache')) {
         trigger_error('Missing php_memcache module', E_USER_ERROR);
     }
     $this->obj = new Memcache();
     $ports = explode(',', MEMCACHED_PORT);
     foreach (explode(',', MEMCACHED_HOST) as $i => $h) {
         if (!$this->obj->addServer($h, $ports[0])) {
             trigger_error('Can\'t connect memcached server', E_USER_ERROR);
         }
     }
     $this->obj->pconnect();
     parent::cachemgr();
 }