Meta Cache or Codeigniter Cache

寵の児 提交于 2019-12-25 05:03:25

问题


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

Please suggest.


回答1:


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




回答2:


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!




回答3:


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


来源:https://stackoverflow.com/questions/10395235/meta-cache-or-codeigniter-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!