Search code examples
cakephpcakephp-2.x

Extend RedisEngine in CakePHP


I have some custom methods created in Cake's RedisEngine file to do things like Redis spop...etc. I know that editing the actual RedisEngine file itself within the Cake Lib is not ideal, but am unsure exactly how to extend it so that I can add my own methods. Or more specifically, if I do extend it, how to I tell Cake to use MyRedisEngine instead of the default one?


Solution

  • Per this page in the CakePHP Book, you can extend CacheEngine by specifying the config like this in Config/bootstrap.php:

    Cache::config('custom', array(
        'engine' => 'MyCustomCacheEngine', // if this doesn't work, try without the 'Engine'
        // ...
    ));
    

    and adding a MyCustomCacheEngine.php file in the app/Lib/Cache/Engine/ directory.