yii2mod / yii2-settings

Persistent settings in Yii2
MIT License
102 stars 33 forks source link

updating config values via UI module does not update cache #19

Closed ovaisbawany closed 7 years ago

ovaisbawany commented 7 years ago

When I update the config values via given UI module, it does not update the cache and returns old values on get calls. I tried calling method invalidateCache() via code and after that, values get updated. can anyone please suggest me that how can I update my cache whenever any create or update applied on the Settings from UI panel. thanks.

ihorchepurnyi commented 7 years ago

Method invalidateCache() automatically called in afterSave() function https://github.com/yii2mod/yii2-settings/blob/master/models/SettingModel.php#L107

ovaisbawany commented 7 years ago

you are right, its working, but now I have observed that its updating the back-end cache but not front-end cache as my UI module lies in back-end of yii2 advance structure. I used the common config for settings class. Please can you help me that how can I invalidateCache() both front-end and back-end cache on updating from back-end. TIA

ihorchepurnyi commented 7 years ago

Yii2 by default in the advanced template use one cache component for both applications https://github.com/yiisoft/yii2-app-advanced/blob/master/common/config/main.php#L9

ihorchepurnyi commented 7 years ago

You need to use one cache component for your application, or you need to override SettingModel and Settings component.

ovaisbawany commented 7 years ago

Resolved with your guidance, I was using the common cache but I never configured the cache path, so it was saving cache in different folders. This given line solved the problem 'cachePath' => '@common/runtime/cache',

Thank you for your support, your component is very valuable and useful.

ihorchepurnyi commented 7 years ago

Thanks :)