【问题标题】:Cache library not loading缓存库未加载
【发布时间】:2013-01-21 10:57:15
【问题描述】:

在 codeigniter(2.1.3) 中加载缓存库时出错。 它的意思是这样的:

遇到错误

无法加载请求的类:缓存

我的代码是这样的

if (!$data['foo'] = $this->cache->file->get('details')) {
        $data['foo'] = $this->foo->getdetails();
        $this->cache->file->save('details', $data['foo'], 600);
    }

我的自动加载文件是这样的:

$autoload['libraries'] = array('database','form_validation','session','driver','cache');

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    大家好,我得到了这个问题的答案。

    最后我创建了一个自定义库并在我的自动加载文件中调用它。它解决了我的问题。

    代码就在这里

    class CallCache  {
    
    public function __construct($config = array())
    {
                $ci = &get_instance();
                $ci->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file')); 
    }
    }       
    

    最后感谢上帝

    【讨论】:

      【解决方案2】:

      确保你没有错过 CI 的加载库函数...看起来你没有加载类..

      在您的任何控制器函数中,您可以使用以下标准初始化您的类:$this->load->library('someclass');

      试试这个

      $this->load->library('cache');  //library name  // put it on your controller..
      

      这里是useguide

      【讨论】:

      • 已经这样做了。在我的本地但在服务器上工作正常。
      【解决方案3】:

      我认为您需要预先加载缓存库。你可以这样做:

      $this->load->library('cache');
      

      或者你可以把缓存库放在你的autoload.php中

      【讨论】:

      • $autoload['libraries'] = array('database','form_validation','session','driver','cache');
      • 大家好,我得到了这个问题的答案。
      【解决方案4】:

      我的解决方案是将系统文件夹中的文件夹名称从:“libraries/cache”重命名为“libraries/Cache”:)

      Loader 使用 ucfirst() 将文件夹名称的首字母大写并在其中搜索以找到驱动程序。

      【讨论】:

        【解决方案5】:

        您如何比较本地和服务器中的 php 版本。我在 charset utf-8 方面做了一段时间,结果发现如果您的 php 版本低于 5.4 或本国的。您必须在您的 cpanel 或您的服务器使用的任何东西中升级它。干杯!

        【讨论】:

        • 在您的服务器上将您的 php 升级到 5.5 版
        【解决方案6】:

        你真的可以这样做

        $autoload['drivers'] = array('cache');
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2022-08-06
          • 2018-12-10
          • 2016-12-16
          • 1970-01-01
          • 2023-03-15
          • 1970-01-01
          • 2018-02-18
          相关资源
          最近更新 更多