Ocasional error warning when CakePHP is writing to the cache

前端 未结 4 1339
野的像风
野的像风 2021-01-05 12:42

I\'m developing a CakePHP 2.2 site locally with MAMP. Every so often, I get one or more warnings similar to this, about not being able to write to one or more cache files:

4条回答
  •  长发绾君心
    2021-01-05 13:02

    This happens probably when a process different from Apache create files in the cache. This can be the case for instance when you run shell commands as you probably do it as a different user than apache.

    By default the File cache creates files with permissions allowing only the user that has created the files to modify them, but this can be fixed by setting a mask in the Cache config in core.php:

    Cache::config('_cake_core_', array(
        'engine' => $engine,
        'prefix' => 'cake_core_',
        'path' => CACHE . 'persistent' . DS,
        'serialize' => ($engine === 'File'),
        'duration' => $duration,
        'mask' => 0666
    ));
    
    Cache::config('_cake_model_', array(
        'engine' => $engine,
        'prefix' => 'cake_model_',
        'path' => CACHE . 'models' . DS,
        'serialize' => ($engine === 'File'),
        'duration' => $duration,
        'mask' => 0666
    ));
    

提交回复
热议问题