Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
插入或删除后我不希望删除视图缓存,但蛋糕会自动执行。保存、删除功能后如何禁用清除缓存?
我的尝试,但还是一样:
if($this->User->save($data, array('callbacks' => false)))
谢谢
如果我对您的理解正确,您希望将其添加到您的模型或 AppModel 中。
public function afterSave($created) { Cache::clear(); parent::afterSave($created); }
删除parent::afterSave($created);模型本身中的 if。
parent::afterSave($created);
如果您不想完全清空缓存,可以通过Cache::delete($key)或按组定位:Cache::clearGroup($groupname);
Cache::delete($key)
Cache::clearGroup($groupname);