Fileキャッシュ

1.2RC2から1.2RC3に変更してFileベースのキャッシュが効かなくなったので、調べてみると /cake/libs/cache/file.php FileEngine::read()の期限切れ判定が変更されていた。

  • 1.2RC2 if ($cachetime !== false && intval($cachetime) < time()) {
  • 1.2RC3 if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {

durationも適宜設定しないとまずいみたい。

Cache::write($key, $value, $config) でキャッシュを書き込むが、$configは以下の4パターンの設定ができる。

  • 設定名(core.phpで設定)
  • 有効時間(数字、単位:秒)
  • 有効期限(strtotimeで変換できる文字列、先頭2文字が数字)
  • 設定配列

/app/config/core.phpでデフォルト設定だと、duration=3600。月の頭にはキャッシュを再作成するつもりで、
Cach::write('hoge',$data,date('Y-m-t 23:59:59')) とすると、
1.2RC2「月末 < 現時刻で消去」だったものが、1.2RC3「月末 < 現時刻、もしくは現時刻 + 3600秒 < 月末で消去」となる。

素直に、有効時間で設定するべきか。