thomas Posted March 12, 2014 Share Posted March 12, 2014 Hello, I have a site that writes a lot of MarkupCache files. I use a hook after save() to delete only the ones for the changed ID. Since these are a lot of cache files (up to 20.000 right now) this process takes a long time so I need to make sure it only happens when neccessary. My idea was this: Whenever a page gets saved entirely ($page->save()) I clean the cache for it. When only parts are saved ($page->save(field)) I don't. So I'd like to know: - Is there a way to save several fields (have a $fields array) or do I have to $page->save($field) for every single one? - is there a way to find out in the hook if a field was given or the entire page is to be saved? Also on another note, has anyone got any great tips on how to delete (expire) seleted files from the MarkupCache directory? I use remove() from cacheFile which uses directoryIterator. This takes a long time! Thanks, thomas Link to comment Share on other sites More sharing options...
teppo Posted March 12, 2014 Share Posted March 12, 2014 - Is there a way to save several fields (have a $fields array) or do I have to $page->save($field) for every single one? None that I know of, but you can always do this: $fs = array("body", "title", "summary"); foreach ($fs as $f) $page->save($f); - is there a way to find out in the hook if a field was given or the entire page is to be saved? According to Page.php, for single field save you'll want to hook into Pages::saveField(). Also on another note, has anyone got any great tips on how to delete (expire) seleted files from the MarkupCache directory? I use remove() from cacheFile which uses directoryIterator. This takes a long time! Isn't this exactly the same question that Wanze answered quite a while ago, or am I missing something? If you still need those wildcards, then it could, of course, get more complicated 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now