dongyingtang3803 2015-01-12 06:19
浏览 194
已采纳

使用Redis Engine配置Cakephp 2.6.0

I am trying to configure cakephp ver 2.6.0 to use redis engine by default. but somehow i am not able to make it work. any help will be highly appreciated.

Things Which i have tried so far..

Configured app/config folder 2 files , core.php and bootstrap.php. , according to the guidelines provided here in this blog configure cake with redis and this blog too Another cake-redis config setup

but i keep on getting errors like.

Fatal error: Uncaught exception 'CacheException' with message 'Cache engine session is not properly configured.' in C:\wamp\www\project\cakephp\cakephp_2.6.0\lib\Cake\Cache\Cache.php on line 181

CacheException: Cache engine session is not properly configured. in C:\wamp\www\project\cakephp\cakephp_2.6.0\lib\Cake\Cache\Cache.php on line 181

Any help will be highly appreciated.

  • 写回答

1条回答 默认 最新

  • dounuo8797 2015-01-15 10:52
    关注

    I was having the same exact issue today while trying to setup CakePHP to use Redis as the cache engine.

    Coincidentally, I also read the same setup instructions from the two blogs you linked to.

    The reason was that I had copied pasted the Configure::write(...) code block from the Another cake-redis config setup blog post as it is and pasted it into the file without first commenting out the Configure::write(...) code block that was already in the core.php file.

    I'm assuming that you have already successfully setup Redis on Windows and have installed the PHPRedis extension without any issues.

    I am using the instructions from Another cake-redis config setup here.

    In your app/Config/core.php file, comment out the following block: (this was starting at line 218 in my core.php)

        Configure::write('Session', array(
        'defaults' => 'php'
    ));
    

    Instead, you can put this in: (You can change the values to suit your particular needs)

    Configure::write('Session', array(
    'defaults' => 'cache',
    'timeout' => 100,
    'start' => true,
    'checkAgent' => false,
    'handler' => array(
        'config' => 'session'
        )
    ));
    

    After this, change the value of $engine to 'Redis', so it becomes:

    $engine = 'Redis';
    

    And then, put this code in, I put this in at the very end of the file: (Again, your values can be different depending on what your setup is)

        Cache::config ('session', array (
        'Engine' => $engine,
        'Prefix' => $prefix . 'cake_session_',
        'Duration' => $duration
    ));
    

    And that's it. You're done! No need to change anything else.

    To make sure that Redis is working properly with CakePHP, I ran the RedisEngine Test Suite that comes with CakePHP. You need to have PHPUnit installed for this to work.

    It can be accessed via http://your-cakephp-project/test.php

    Click on 'Tests' under Core and then click on 'Cache/Engine/RedisEngine' If everything is working successfully, you should see all the tests pass.

    Alternatively, you can use redis-cli at the command prompt to confirm that Redis is storing keys properly.

    Once you have logged in by typing redis-cli, type KEYS * This should give you a list of keys related to your CakePHP setup.

    An example would be the "myapp_cake_core_object_map" key.

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码