
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Rolling Back Object Changes
|
199
See Also
To use the built-in ASP.NET cache object independently of a web application, see
the following topics in MSDN:
• “Caching Application Data”
• “Adding Items to the Cache”
• “Retrieving Values of Cached Items”
• “Deleting Items from the Cache”
• “Notifying an Application When an Item Is Deleted from the Cache”
• “System.Web.Caching Namespace”
In addition, see the Datacache2 Sample under “.NET Samples—ASP.NET Caching”
in MSDN; see the sample links to the Page Data Caching example in the ASP.NET
QuickStart Tutorials.
Also see the “WeakReference Class” topic in the MSDN documentation.
3.30 Rolling Back Object Changes
Problem
You have an object that allows its state to be changed. However, you do not want
these changes to become permanent if other changes to the system cannot be made
at the same time. In other words, you want to be able to roll back the changes if any
of a group of related changes fails.
Solution
Use the memento design pattern to allow your object to save its original state in order
to roll back changes.
The memento design pattern allows object state to be saved so that it can be restored
in response to a specific situation. The memento pattern is very useful for imple-
menting undo/redo or commit/rollback actions. This pattern usually has