让PHPCms内容页支持JavaScript的修改方法,文件缓存封装实现代码

如果要让内容页支持JavaScript,则要做以下修改:

使用方法:
Memcached
复制代码 代码如下:
$cache = new Cache_MemCache();
$cache->addServer(‘www1’);
$cache->addServer(‘www2’,11211,20); // this server has double the
memory, and gets double the weight
$cache->addServer(‘www3’,11211);
// Store some data in the cache for 10 minutes
$cache->store(‘my_key’,’foobar’,600);
// Get it out of the cache again
echo($cache->fetch(‘my_key’));

  在文件..cachescaches_modelcaches_datacontent_input.class.php中找到函数:

文件缓存
复制代码 代码如下:
$cache = new Cache_File();
$key = ‘getUsers:selectAll’;
// check if the data is not in the cache already
if (!$data = $cache->fetch($key)) {
// assuming there is a database connection
$result = mysql_query(“SELECT * FROM users”);
$data = array();
// fetching all the data and putting it in an array
while($row = mysql_fetch_assoc($result)) { $data[] = $row; }
// Storing the data in the cache for 10 minutes
$cache->store($key,$data,600);
}

复制代码代码如下:function
get($data,$isimport = 0) {
$this->data = $data = trim_script($data);

下载: class_cache3.php
复制代码 代码如下:

修改为:

abstract class Cache_Abstract {
abstract function fetch($key);
abstract function store($key, $data, $ttl);
abstract function delete($key);
}

复制代码代码如下:function
get($data,$isimport = 0) {
$this->data = $data; //不调用过滤函数
  

class Cache_APC extends Cache_Abstract {

  Over!PHPCms内容页已支持JavaScript。

function fetch($key) {
return apc_fetch($key);
}

function store($key, $data, $ttl) {
return apc_store($key, $data, $ttl);
}

function delete($key) {
return apc_delete($key);
}

}

class Cache_MemCache extends Cache_Abstract {
public $connection;

function __construct() {
$this->connection = new MemCache;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注