Exemplo n.º 1
0
 public function set($key, $value, $expire = '')
 {
     $freeSpace = disk_free_space($this->config['path']);
     $freeSpaceMB = $freeSpace ? floor($freeSpace / 1024 / 1024) : 0;
     if ($freeSpaceMB < 10) {
         Axion_log::getinstance()->newMessage('磁盘容量过小,无法存储数据缓存文件', AXION_LOG::WARNING);
         return false;
     }
     $hash = md5($key);
     $expire = $expire ? $expire : $this->config['expire'];
     $expire = sprintf('%09d', $expire);
     $data = serialize($value);
     self::$_data[$hash] = $data;
     if (!is_dir($this->config['path'])) {
         if (!AXION_UTIL_FILE::mkdir($this->config['path'])) {
             throw new AXION_EXCEPTION('无法创建Cache文件目录:' . $this->config['path']);
         }
     }
     $fileName = $this->genFileName($key);
     if (IS_SHM && function_exists('gzcompress')) {
         $data = gzcompress($data, 4);
     }
     $data = $expire . $data;
     $result = file_put_contents($fileName, $data);
     if ($result) {
         clearstatcache();
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public function failure($host, $port)
 {
     Axion_log::getinstance()->newMessage("MEMCACHED服务器{$host}:{$port发生故障}", Axion_log::WARNING);
 }