cxzlr 发表于 2013-2-4 16:49:55

如何扩展cache 类

如何扩展cache 类
system/cache/drivers/*
system/cache/cache.php

cxzlr 发表于 2013-2-5 09:17:40

自己顶,为何没人回应。

jeongee 发表于 2013-2-5 10:04:40

创建新的driver就可以了
格式参考已存在的driver

cxzlr 发表于 2013-2-5 10:27:45

如果在 application/libraries 下创建如下目录结构
Cache
    drivers
       MY_Cache_file.php
       class MY_Cache_file extends CI_Cache_file{

       }

以上的方法,在调用 $this->cache->file->save(); 方法时就根本没有执行 MY_Cache_file.php 中的save
执行的还是system/libraries/Cache/drivers/cache_file.php中的 save 方法

如果直接用覆盖来处理处理如下
application/libraries
   Cache
      drivers
             Cache_file.php
      Cache.php
如果这样的话, 在执行 $this->cache->file->save 方法时就会提示出错
$this->load->driver('cache');
$this->cache->file->save('xxx',123);
Fatal error: Cannot redeclare class CI_Cache_file in E:\xampp\htdocs\testa\system\libraries\Cache\drivers\Cache_file.php on line 191
高手看看,如何解决这一问题。

cxzlr 发表于 2013-2-5 10:54:44

自己顶,高手给回个罢 。

婷_镏 发表于 2016-6-28 13:24:46

cxzlr 发表于 2013-2-5 10:27
如果在 application/libraries 下创建如下目录结构
Cache
    drivers


$this->cache->file->save(); 方法有什么作用啊里边的参数不能随意改变么
页: [1]
查看完整版本: 如何扩展cache 类