php:cache.php
<?php
/*
[Destoon B2B System] Copyright (c) 2008-2011 Destoon.COM
This is NOT a freeware, use is subject to license.txt
*/
defined('IN_IXDCW') or exit('Access Denied');
/**
* apc的缓存类
*/
class cache {
var $pre;
/**
* constructor
*/
function __construct() {
//
}
function get($key) {
$key = $this->pre.$key;
return apc_fetch($key);
}
function set($key, $val, $ttl = 600) {
$key = $this->pre.$key;
return apc_store($key, $val, $ttl);
}
function rm($key) {
$key = $this->pre.$key;
return apc_delete($key);
}
function clear() {
return apc_clear_cache();
}
function expire() {
//
}
}
?>
<?php
/*
[Destoon B2B System] Copyright (c) 2008-2011 Destoon.COM
This is NOT a freeware, use is subject to license.txt
*/
defined('IN_IXDCW') or exit('Access Denied');
class cache {
var $pre;
/**
* eaccelerator 缓存类
*/
function __construct() {
//
}
function get($key) {
$key = $this->pre.$key;
return eaccelerator_get($key);
}
function set($key, $val, $ttl = 600) {
$key = $this->pre.$key;
eaccelerator_lock($key);
return eaccelerator_put($key, $val, $ttl);
}
function rm($key) {
$key = $this->pre.$key;
return eaccelerator_rm($key);
}
function clear() {
return eaccelerator_gc();
}
function expire() {
//
}
}
?>
<?php
/*
[Destoon B2B System] Copyright (c) 2008-2011 Destoon.COM
This is NOT a freeware, use is subject to license.txt
*/
defined('IN_IXDCW') or exit('Access Denied');
class cache {
var $pre;
var $memcache;
/**
* constructor
*/
function __construct() {
$this->memcache = &new Memcache;
include DT_ROOT.'/file/config/memcache.inc.php';
$num = count($MemServer);
if($num == 1) {
$key = 0;
} else {
$key = Cookie::get('memcache');
if($key == -1) {
$key = 0;
} else if(!isset($MemServer[$key])) {
$key = array_rand($MemServer);
Cookie::set('memcache', $key ? $key : -1);
}
}
$this->memcache->connect($MemServer[$key]['host'], $MemServer[$key]['port'], 2);
}
function get($key) {
$key = $this->pre.$key;
return $this->memcache->get($key);
}
function set($key, $val, $ttl = 600) {
$key = $this->pre.$key;
return $this->memcache->set($key, $val, 0, $ttl);
}
function rm($key) {
$key = $this->pre.$key;
return $this->memcache->delete($key);
}
function clear() {
return $this->memcache->flush();
}
function expire() {
//
}
}
?>
<?php
/*
[Destoon B2B System] Copyright (c) 2008-2011 Destoon.COM
This is NOT a freeware, use is subject to license.txt
*/
defined('IN_IXDCW') or exit('Access Denied');
class dcache {
var $pre;
var $shmop_key;
var $shmop_id;
/**
* constructor
*/
function __construct() {
//
}
function get($key) {
$key = $this->pre.$key;
$this->shmop_key = ftok($key);//Linux/Unix Only
$this->shmop_id = shmop_open($this->shmop_key, 'c', 0644, 0);
if($this->shmop_id === false) return false;
$data = shmop_read($this->shmop_id, 0, shmop_size($this->shmop_id));
shmop_close($this->shmop_id);
return function_exists('gzuncompress') ? gzuncompress($data) : $data;
}
function set($key, $val, $ttl = 600) {
$key = $this->pre.$key;
if(function_exists('gzcompress')) $val = gzcompress($val, 3);
$this->shmop_key = ftok($key);
$this->shmop_id = shmop_open($this->shmop_key, 'c', 0644, strlen($val));
$result = shmop_write($this->shmop_id, $val, 0);
shmop_close($this->shmop_id);
return $result;
}
function rm($key) {
$key = $this->pre.$key;
$this->shmop_key = ftok($key);
$this->shmop_id = shmop_open($this->shmop_key, 'c', 0644, 0);
$result = shmop_delete($this->shmop_id);
shmop_close($this->shmop_id);
return $result;
}
function clear() {
//
}
function expire() {
//
}
}
?>