简体   繁体   中英

Custom Cache Engine Not Working in CakePhp 2.6

I'm trying to implement Zend Cache from ZF2 inside CakePhp to make use of it's tagging features, among others.

I created a class inside /app/Lib/Cache/Engine/ZendCacheEngine.php

class ZendCacheEngine extends CacheEngine {
   //All abstract functions from Cake's CacheEngine are 

    public function init($settings = array()){
        //Code here....
    }

    //Along with read, write, delete, etc...
}

For the time being, i only have a print "function name" inside these functions and a return. I did this in my efforts to debug what is going on.

Inside my bootstrap.php I set the config for my custom class:

Cache::config('custom_zend', array(
    'engine' => 'ZendCache',
    'duration' => '+1 hours',
    'probability' => 100,
));

When I try to use it inside my Controllers, the cache read and write functions are being ignored completely. (Function name not being printed in my case, except for the init function)

public function news($id, $something) {
        $result = Cache::read('news', 'custom_zend');
        if (!$result) {

            $result = $this->News->find('all'); // For the sake of simplicity here
            Cache::write('news', $result, 'custom_zend');
        }
        $this->set('news',$news);   
    }

Bottom line, I am assuming the file is in the correct place and the configuration is correct (since the init() function inside my custom class is being called).

I need to know why the actual read/write/etc... are not being called.

事实证明init()没有正确设置$ settings数组,这就是为什么未调用其他函数的原因。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM