Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Short helper method that can be used to update and invalidate a page from the server side cache when a related entity is updated or deleted.
public static void TouchPage(Guid id) {
// Update both the published and draft version in one go.
Piranha.Models.Page.Execute("UPDATE page SET page_last_modified=@0 WHERE page_id=@1",
null, DateTime.Now, id) ;
// Get the page, don't worry it's cached so it wont cause a database operation.
var page = Piranha.Models.Page.GetSingle(id) ;
// Invalidate the page from the server cache
page.InvalidateRecord(page) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment