元缓存或Codeigniter缓存 [英] Meta Cache or Codeigniter Cache
本文介绍了元缓存或Codeigniter缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该使用哪个缓存减少页面的加载时间 - Meta Cache或Codeigniter Caching。
Which cache should i make use to reduce the loading time of a page - Meta Cache or Codeigniter Caching.
请建议。
推荐答案
藏; http://code.google.com/p/stash/ ,在工作,这是伟大的。它使用一个层次化的关键字结构,这对于缓存相关的项目是非常有用的。
I recently used Stash; http://code.google.com/p/stash/, at work and it's great. It uses a hierarchical key structure which is really useful for caching related items.
我使用这个库文件将其作为第三方软件包进行集成。我去了。
I used this library file to integrate it as a third party package and away I went.
<?php
class Stash {
private $_pool;
public function __construct($options)
{
include_once APPPATH . '/third_party/Stash/autoload.php';
if (isset($options['stash']) && isset($options['stash']['path'])) {
if (substr($options['stash']['path'], 0, 1) != '/') {
$options['stash']['path'] = getcwd() . '/' . $options['stash']['path'];
}
}
$handler = new Stash\Handler\FileSystem(@$options['stash']);
$this->_pool = new Stash\Pool;
$this->_pool->setHandler($handler);
}
public function getCache($path)
{
return $this->_pool->getCache($path);
}
}
?>
只需使用这个简单的配置文件:
Just use this simple config file:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| Stash Cache settings
| -------------------------------------------------------------------
|
*/
$config['stash'] = array('path' => APPPATH .'/cache');
然后你可以这样使用:
$this->load->library('Stash');
$cache = $this->stash->getCache(array('key1','subkey1','subkey2'));
$cache->set('foo', 'bar', 30);
这篇关于元缓存或Codeigniter缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文