1. Norton Ghost's convenience and problems
Most of our win users have used Norton Ghost, as long as the current system backup to generate image files, such as the system poisoning or crashes, with Norton Ghost recovery back to the back of the time.
This can be said to be the basic principle of Memo (Memento) mode, first backup, need to restore. So the memo mode is better understood.
However, in practical application, it is necessary to pay attention to how to apply the memo mode correctly.
When we write the article in Word, Ghost to back up all the hard disk, once the article is wrong, need to recover, use ghost to overwrite the hard disk?
Just like some website backup system, do is full station recovery, although convenient, but his backup and recovery scope and Norton Ghost is similar.
If you only adjust the style of a page's page list, you encounter the following issues:
1, 99% of the data has not changed, that is, 99% of the backup and recovery are redundant
2, full-site backup and recovery, the pressure on the server is very large, and even drag down the server
3, the execution time may be very long
4, the whole station data operation, once the halfway operation failed, you have to start again
2, PHP development of "undo" function
We usually use a lot of software to provide a call "undo" or "undo" function, you can undo the previous operation, then we develop PHP can also learn from.
This allows us to better apply and understand the memento model, as backup and recovery can be done on a variety of grain size.
Cases:
- <?php
- //Memo class
- class Memento
- {
- Public function backup ()
- {
- //Save an existing page-out style
- Echo ' style has been saved <br> ';
- }
- Public function restore ()
- {
- //Use a saved style to overwrite
- Echo ' style has been restored <br> ';
- }
- }
- //Set pagination style
- class ListStyle
- {
- //Memo Object
- Private $memento;
- //Construction method
- Public function __construct ()
- {
- $this ->memento = New Memento ();
- }
- //Set style
- Public function setStyle ()
- {
- //Start back up style first
- $this ->memento->backup ();
- //Set style
- Echo ' Set the style <br> ';
- }
- //Undo Method
- Public function undo ()
- {
- $this ->memento->restore ();
- }
- }
- $listStyle = New ListStyle ();
- //Set style while backing up
- $listStyle ->setstyle ();
- //Undo Settings
- $listStyle ->undo ();
- ?>
This eliminates the need to backup and restore the entire station.
2, PHP development of "redo" function
We implemented the "undo" function in front of the other software, which corresponds to the "redo" function, usually called "redo".
So we need to improve the code.
Cases:
- <?php
- //Memo class
- class Memento
- {
- Public function backup ()
- {
- //Save an existing page-out style
- Echo ' style has been saved <br> ';
- }
- Public function restore ()
- {
- //Use a saved style to overwrite
- Echo ' style has been restored <br> ';
- }
- }
- //Set pagination style
- class ListStyle
- {
- //Memo Object
- Private $memento;
- //Construction method
- Public function __construct ()
- {
- $this ->memento = New Memento ();
- }
- //Set style
- Public function setStyle ()
- {
- //Start back up style first
- $this ->memento->backup ();
- //Set style
- Echo ' Set the style <br> ';
- }
- //Undo Method
- Public function undo ()
- {
- //Save first, for redo
- $this ->memento->backup ();
- $this ->memento->restore ();
- }
- //Redo Method
- Public function redo ()
- {
- $this ->memento->restore ();
- }
- }
- $listStyle = New ListStyle ();
- //Set style while backing up
- $listStyle ->setstyle ();
- //Undo Settings
- $listStyle ->undo ();
- //Redo Settings
- $listStyle ->redo ();
- ?>
In this way, we can provide a detailed implementation of the memo mode. more PHP Tutorial , please visit the Code home ;
Thinking:
Memo mode is a common mode, especially in software development, for PHP, can also be used in some situations.
But PHP's memo mode, often need to pay attention to the feasibility, because the software, such as word, are single-machine-based, and PHP's Web site is often accessed by many users simultaneously.
A lot of access, if the backup at this time, the server can withstand? How do I resolve data consistency for concurrent access?
Although this paper discusses the application of fine and independent memo mode, it is necessary to apply different strategies according to the specific situation in practical application.
This article original address:http://www.daimajiayuan.com/sitejs-16852-1.html