Meta Cache or Codeigniter Cache

2019-09-06 02:01发布

Which cache should i make use to reduce the loading time of a page - Meta Cache or Codeigniter Caching.

Please suggest.

3条回答
劫难
2楼-- · 2019-09-06 02:31

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');

Then you can use it like this:

$this->load->library('Stash');
$cache = $this->stash->getCache(array('key1','subkey1','subkey2'));
$cache->set('foo', 'bar', 30);
查看更多
女痞
3楼-- · 2019-09-06 02:37

Depends what are your needs.

If you don't need some more specific and it's no problem with caching the entire page, you should to use Web Page Caching. This is very very simple and will suit you.

If it's something more specific, maybe you should try a look in the Caching Driver, wich permits you to use a variety of diferent types of cache (including memcache). The most advantage is you can cache specific chunks of code (very useful to projects with diferent page modules needs).

And, if you want to try some third-part stuff, I highly recomend the Phil Sturgeon CodeIgniter Cache Library, wich also works with codes chunks and it's very easy to use, generating quickly text-based caches.

Regards!

查看更多
Explosion°爆炸
4楼-- · 2019-09-06 02:46

for me i tried CI Cache and it was good ... most of the people will say that this is your own choice and you have to decide based on your project requirement ..

but for sure the best answer is to try this and try that then chose the best for your case

查看更多
登录 后发表回答