在 CakePHP 中扩展 RedisEngine

Extend RedisEngine in CakePHP

我在 Cake 的 RedisEngine 文件中创建了一些自定义方法来执行 Redis spop...等操作。我知道在 Cake Lib 中编辑实际的 RedisEngine 文件本身并不理想,但不确定如何扩展它以便我可以添加自己的方法。或者更具体地说,如果我确实扩展了它,我如何告诉 Cake 使用 MyRedisEngine 而不是默认的?

Per this page in the CakePHP Book, you can extend CacheEngine 通过在 Config/bootstrap.php 中指定这样的配置:

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

并在 app/Lib/Cache/Engine/ 目录中添加一个 MyCustomCacheEngine.php 文件。