-
Notifications
You must be signed in to change notification settings - Fork 1
Refresh Custom Cache Partitions
If you use getCache with custom cache partitions, and you want an easy way to manually refresh that cache from the manager, you can quickly add a custom Menu that does just that using the connector and processor that comes with getCache (since v1.1.0).
First, create a new Menu in the tree at System --> Actions in the MODX Manager. I recommend creating these custom Menus as children of the Site --> Clear Cache menu. Give it a unique Lexicon Key and Description, select No Action for the Action, you can reuse the images/icons/refresh.png for the Icon, and leave Parameters empty. In the Handler field, you can provide Javascript similar to the following example, which would be used to refresh a cache partition called global_cache:
var topic = '/getcache/cache/partition/refresh/global_cache/';
this.console = MODx.load({
xtype: 'modx-console'
,register: 'mgr'
,topic: topic
,show_filename: 0
});
this.console.show(Ext.getBody());
MODx.Ajax.request({
url: MODx.config.assets_url+'components/getcache/connector.php'
,params: { action: 'cache/partition/refresh', partitions: 'global_cache', register: 'mgr' , topic: topic }
,listeners: {
'success':{fn:function() {
this.console.fireEvent('complete');
this.console = null;
},scope:this}
}
});
return false;Just set a unique topic variable and change the partitions sent in the params object of the MODx.Ajax.request() call.
Finally, you can give the Menu a Permission (or comma-delimited list of Permissions) required to see the Menu. The processor itself requires the empty_cache Permission.