CN107203915B - Data storage method and device - Google Patents

Data storage method and device Download PDF

Info

Publication number
CN107203915B
CN107203915B CN201610151263.1A CN201610151263A CN107203915B CN 107203915 B CN107203915 B CN 107203915B CN 201610151263 A CN201610151263 A CN 201610151263A CN 107203915 B CN107203915 B CN 107203915B
Authority
CN
China
Prior art keywords
data
database
storage
sending
local
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610151263.1A
Other languages
Chinese (zh)
Other versions
CN107203915A (en
Inventor
温涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced Nova Technology Singapore Holdings Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201610151263.1A priority Critical patent/CN107203915B/en
Publication of CN107203915A publication Critical patent/CN107203915A/en
Application granted granted Critical
Publication of CN107203915B publication Critical patent/CN107203915B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0633Lists, e.g. purchase orders, compilation or processing
    • G06Q30/0635Processing of requisition or of purchase orders

Abstract

The application discloses a data storage method and a device, wherein the method comprises the following steps: acquiring first data to be stored in a first database; if the first database is detected to be incapable of storing data, adding the first data into a local message, and storing the local message carrying the first data into a local system; and sending the first data to a second database so that the second database stores the first data. Therefore, the method and the device can ensure the reliability of data storage and can also improve the success rate of data storage.

Description

Data storage method and device
Technical Field
The present application relates to the field of internet technologies, and in particular, to a data storage method and apparatus.
Background
With the continuous development of internet technology, the application of online shopping is more and more extensive.
In the prior art, after receiving a user order instruction, a website server generates corresponding order data according to the user order instruction, and stores the order data in a database.
However, when the database storage fails, the website server directly sends order storage failure information to the user, so that the user has to place an order again, the difficulty of online shopping is improved, and the user experience is reduced.
Disclosure of Invention
The application provides a data storage method and a data storage device, which are used for solving the problem that in the prior art, when the database storage fails, a user needs to place an order again.
According to a first aspect of embodiments of the present application, there is provided a data storage method, including:
acquiring first data to be stored in a first database;
if the first database is detected to be incapable of storing data, adding the first data into a local message, and storing the local message carrying the first data into a local system;
and sending the first data to a second database so that the second database stores the first data.
According to a second aspect of embodiments of the present application, there is provided a data storage apparatus comprising:
an acquisition unit configured to acquire first data to be stored in a first database;
the local storage unit is used for adding the first data into a local message and storing the local message carrying the first data into a local system if the first database is detected to be incapable of storing data;
and the first sending unit is used for sending the first data to a second database so as to enable the second database to store the first data.
According to a third aspect of embodiments herein, there is provided a data storage apparatus comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to:
acquiring first data to be stored in a first database;
if the first database is detected to be incapable of storing data, adding the first data into a local message, and storing the local message carrying the first data into a local system;
and sending the first data to a second database so that the second database stores the first data.
By applying the embodiment of the application, after the first data to be stored in the first database is obtained, if the first database is detected to be incapable of storing the data, the first data can be added into the local message, the local message carrying the first data is stored in the local system, and the first data is sent to the second database.
Drawings
FIG. 1 is a schematic diagram of a data storage scenario according to an embodiment of the present application;
FIG. 2 is a flow chart of one embodiment of a data storage method of the present application;
FIG. 3 is a flow chart of another embodiment of a data storage method of the present application;
FIG. 4 is a diagram of a hardware configuration of an apparatus in which the data storage device of the present application is located;
FIG. 5 is a block diagram of one embodiment of a data storage device according to the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
Referring to fig. 1, a schematic diagram of a data storage scenario in an embodiment of the present application is shown:
the scenario of fig. 1 includes: users, web servers, primary databases, and backup databases. The websites browsed by the user can be some shopping websites, and the user can realize online shopping by sending order instructions to the shopping websites.
After receiving the user order instruction, the website server may generate corresponding order data according to the user order instruction, and store the order data in the master database. The order data may include an order number, an order amount, commodity information, and the like.
If the main database is detected to be successfully stored, the order storage success information can be directly sent to the user.
If the main database is detected to fail to store, a local message corresponding to the order data can be generated, the local message comprises the order data, and the local message is stored in a local system, so that the order data cannot be lost; then, sending order storage success information to the user; and finally, storing the order data into a backup database, and deleting the order data stored in the local system if the backup database is successfully stored.
The following provides a detailed description of examples of the present application.
Referring to fig. 2, which is a flowchart of an embodiment of the data storage method of the present application, the method may be applied to a website server, and may include the following steps:
step 210: first data to be stored in a first database is acquired.
In the embodiment of the application, if a user order instruction is received, corresponding order data can be generated according to the user order instruction, and the order data is used as first data to be stored in the first database. The first database may be a primary database or a backup database.
Step 220: if it is detected that the first database cannot store the data, the first data may be added to the local message, and the local message carrying the first data is stored in the local system.
In the embodiment of the application, if it is detected that the first database cannot store data, the reasons are many, and it may be that the first database fails to work due to hardware failure; it is also possible that the first database has insufficient storage space, cannot store data, etc. At this time, in order to prevent the first data from being lost, the first data may be stored in the local system first.
In addition, if it is required to detect whether the first database can store data, the following method can be adopted, but not limited to:
(1) and sending the first data to the first database so that the first database stores the first data.
(2) And receiving a first storage result returned by the first database.
(3) If the first storage result is storage failure, determining that the first database cannot store data; if the first storage result is successful, the first database can store data.
When the local message carrying the first data is stored in the local system, a local message notification mode may be adopted:
firstly, sending a local message to the user; and then receiving the local message sent by the user, thereby achieving the purpose of storing the first data in the local system.
Step 230: and sending the first data to a second database so that the second database stores the first data.
In the embodiment of the application, if the first database is a main database, the second database can be a backup database; if the first database is a backup database, the second database may be a primary database.
If the number of the first databases is 1 and the number of the second databases is 1, the first data may be directly sent to the second databases, so that the second databases store the first data.
If the number of the first databases is more than 1 and the number of the second databases is 1, then if the first data is directly stored in the second databases, the data in the second databases will be confused, and it is unclear which first database is the backup data.
Therefore, a first database identifier can be added to the first data to obtain second data; and then sending the second data to a second database so that the second database stores the second data to a storage area corresponding to the first database identifier, wherein the purpose of the method is to control the second database to synchronize the data in the storage area corresponding to the first database identifier with the first database corresponding to the first database identifier if the first database corresponding to the first database identifier is detected to be capable of storing the data.
In addition, after the first data are sent to the second database, a second storage result returned by the second database can be received; if the second storage result is successful storage, the local message carrying the first data in the local system can be deleted, so that the storage resource of the local system can be saved.
As can be seen from the above embodiments, after first data to be stored in a first database is acquired, if it is detected that the first database cannot store the data, the first data may be added to a local message, the local message carrying the first data is stored in a local system, and the first data is sent to a second database.
Referring to fig. 3, which is a flowchart of another embodiment of the data storage method of the present application, the method may be applied to a website server, and may include the following steps:
step 300: and receiving a user order instruction.
Step 310: and generating corresponding order data according to the order instruction of the user, wherein the order data is first data to be stored in a first database.
Step 320: the first data is sent to a first database.
Step 330: and receiving a first storage result returned by the first database.
Step 340: and if the first storage result is storage failure, determining that the first database cannot store data.
Step 350: and adding the first data into the local message, and storing the local message carrying the first data into a local system.
Step 360: and sending order storage success information to the user.
Step 370: the first data is sent to a second database.
Step 380: and receiving a second storage result returned by the second database.
Step 390: and if the second storage result is successful storage, deleting the local message carrying the first data in the local system.
As can be seen from the above embodiments, after receiving a user order instruction, generating corresponding order data according to the user order instruction, if it is detected that the first database cannot store data, the first data may be added to the local message, the local message carrying the first data is stored in the local system, the order storage success information is sent to the user, the first data is then sent to the second database, and if the second database is successfully stored, the local message carrying the first data in the local system is deleted, so that reliability of order data storage is ensured, and user experience is improved.
Corresponding to the embodiment of the data storage method, the application also provides an embodiment of the data storage device.
The embodiments of the data storage device of the present application can be applied to the website server respectively. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory for operation through the processor of the device where the software implementation is located as a logical means. From a hardware level, as shown in fig. 4, a hardware structure diagram of a device in which the data storage apparatus of the present application is located is shown, except for the processor, the memory, the network interface, and the nonvolatile memory shown in fig. 4, the device in which the apparatus is located in the embodiment may further include other hardware, for example, for a terminal, a camera, a touch screen, a communication component, and the like may be included, and for a server, a forwarding chip responsible for processing a message may be included, and the like, according to an actual function of the device.
Referring to fig. 5, a block diagram of an embodiment of a data storage device according to the present application, where the data storage device may be applied to a web server and may be used to execute the data storage method shown in fig. 2, where the data storage device may include: an acquisition unit 51, a local storage unit 52 and a first transmission unit 53.
An acquiring unit 51 configured to acquire first data to be stored in a first database;
the local storage unit 52 is configured to, if it is detected that the first database cannot store data, add the first data to a local message, and store the local message carrying the first data in a local system;
a first sending unit 53, configured to send the first data to a second database, so that the second database stores the first data. The first database may be a primary database, and the second database may be a backup database.
In an alternative implementation: the apparatus may further include: a second transmitting unit, a first receiving unit and a determining unit (not shown in fig. 5).
The second sending unit is used for sending the first data to a first database after the first data to be stored in the first database is acquired, so that the first database stores the first data;
the first receiving unit is used for receiving a first storage result returned by the first database;
and the determining unit is used for determining that the first database can not store data if the first storage result is storage failure.
In another alternative implementation: the first transmitting unit 53 may include: an add subunit and a transmit subunit (not shown in fig. 5).
The adding subunit is used for adding a first database identifier to the first data to obtain second data;
and the sending subunit is configured to send the second data to the second database, so that the second database stores the second data.
In another alternative implementation: the apparatus may further include: a second receiving unit and a deleting unit (not shown in fig. 5).
The second receiving unit is used for receiving a second storage result returned by a second database after the first data is sent to the second database;
and the deleting unit is used for deleting the local message carrying the first data in the local system if the second storage result is successful in storage.
In another alternative implementation: the acquiring unit 51 may include: a receiving sub-unit and a generating sub-unit (not shown in fig. 5).
The receiving subunit is used for receiving the order instruction of the user;
and the generating subunit is used for generating corresponding order data according to the user order instruction, wherein the order data is the first data.
In another alternative implementation: the apparatus may further include: a third transmitting unit (not shown in fig. 5).
And the third sending unit is used for sending the order storage success information to the user after the local message carrying the first data is stored in the local system.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the request scheme. One of ordinary skill in the art can understand and implement it without inventive effort.
Corresponding to fig. 5, an embodiment of the present application further provides a data storage apparatus, where the apparatus may be applied to a website server, and the apparatus includes:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to:
acquiring first data to be stored in a first database;
if the first database is detected to be incapable of storing data, adding the first data into a local message, and storing the local message carrying the first data into a local system;
and sending the first data to a second database so that the second database stores the first data.
As can be seen from the above embodiments, after first data to be stored in a first database is acquired, if it is detected that the first database cannot store the data, the first data may be added to a local message, the local message carrying the first data is stored in a local system, and the first data is sent to a second database.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (11)

1. A method of data storage, the method comprising:
receiving a user order instruction;
generating and acquiring corresponding first data to be stored in a first database according to the user order instruction;
if the first database is detected to be incapable of storing data, adding the first data into a local message, and storing the local message carrying the first data into a local system;
sending first data storage success information to a user;
and sending the first data to a second database so that the second database stores the first data.
2. The method of claim 1, wherein the first database is a primary database and the second database is a backup database.
3. The method of claim 1, wherein after obtaining the first data to be stored in the first database, further comprising:
sending the first data to the first database so that the first database stores the first data;
receiving a first storage result returned by the first database;
and if the first storage result is storage failure, determining that the first database cannot store data.
4. The method of claim 1, wherein sending the first data to a second database comprises:
adding a first database identifier to the first data to obtain second data;
and sending the second data to the second database so as to enable the second database to store the second data to a storage area corresponding to the first database identification.
5. The method of claim 1, wherein after sending the first data to the second database, further comprising:
receiving a second storage result returned by the second database;
and if the second storage result is successful storage, deleting the local message carrying the first data in the local system.
6. A data storage device, characterized in that the device comprises:
the acquisition unit is used for receiving a user order instruction; generating and acquiring corresponding first data to be stored in a first database according to the user order instruction;
the local storage unit is used for adding the first data into a local message and storing the local message carrying the first data into a local system if the first database is detected to be incapable of storing data;
a third sending unit, configured to send the first data storage success information to the user;
and the first sending unit is used for sending the first data to a second database so as to enable the second database to store the first data.
7. The apparatus of claim 6, wherein the first database is a primary database and the second database is a backup database.
8. The apparatus of claim 6, further comprising:
the second sending unit is used for sending the first data to a first database after the first data to be stored in the first database is acquired, so that the first database stores the first data;
the first receiving unit is used for receiving a first storage result returned by the first database;
and the determining unit is used for determining that the first database can not store data if the first storage result is storage failure.
9. The apparatus of claim 6, wherein the first sending unit comprises:
the adding subunit is used for adding a first database identifier to the first data to obtain second data;
and the sending subunit is configured to send the second data to the second database, so that the second database stores the second data in the storage area corresponding to the first database identifier.
10. The apparatus of claim 6, further comprising:
the second receiving unit is used for receiving a second storage result returned by a second database after the first data is sent to the second database;
and the deleting unit is used for deleting the local message carrying the first data in the local system if the second storage result is successful in storage.
11. A data storage device, characterized in that the device comprises:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to:
receiving a user order instruction;
generating and acquiring corresponding first data to be stored in a first database according to the user order instruction;
if the first database is detected to be incapable of storing data, adding the first data into a local message, and storing the local message carrying the first data into a local system;
sending first data storage success information to a user;
and sending the first data to a second database so that the second database stores the first data.
CN201610151263.1A 2016-03-16 2016-03-16 Data storage method and device Active CN107203915B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610151263.1A CN107203915B (en) 2016-03-16 2016-03-16 Data storage method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610151263.1A CN107203915B (en) 2016-03-16 2016-03-16 Data storage method and device

Publications (2)

Publication Number Publication Date
CN107203915A CN107203915A (en) 2017-09-26
CN107203915B true CN107203915B (en) 2020-07-21

Family

ID=59903695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610151263.1A Active CN107203915B (en) 2016-03-16 2016-03-16 Data storage method and device

Country Status (1)

Country Link
CN (1) CN107203915B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542961A (en) * 2018-10-19 2019-03-29 中国平安财产保险股份有限公司 Date storage method, device, computer equipment and storage medium
CN109858731A (en) * 2018-12-11 2019-06-07 许继集团有限公司 Distribution main station system, historical data storage method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1933614A (en) * 2006-09-29 2007-03-21 华为技术有限公司 Data storing system and method for guaranteeing data lossless which store failure
CN104270302A (en) * 2014-09-22 2015-01-07 上海钢有商贸有限公司 Online order transmitting system and method
CN104765749A (en) * 2014-01-07 2015-07-08 阿里巴巴集团控股有限公司 Data storage method and device
CN104966023A (en) * 2015-03-10 2015-10-07 深圳市腾讯计算机系统有限公司 Data protection system, method and apparatus

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050119992A1 (en) * 1995-05-19 2005-06-02 Martino Rocco L. Telephone/transaction entry device and system for entering transaction data into databases

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1933614A (en) * 2006-09-29 2007-03-21 华为技术有限公司 Data storing system and method for guaranteeing data lossless which store failure
CN104765749A (en) * 2014-01-07 2015-07-08 阿里巴巴集团控股有限公司 Data storage method and device
CN104270302A (en) * 2014-09-22 2015-01-07 上海钢有商贸有限公司 Online order transmitting system and method
CN104966023A (en) * 2015-03-10 2015-10-07 深圳市腾讯计算机系统有限公司 Data protection system, method and apparatus

Also Published As

Publication number Publication date
CN107203915A (en) 2017-09-26

Similar Documents

Publication Publication Date Title
CN108153670B (en) Interface testing method and device and electronic equipment
CN108470298B (en) Method, device and system for transferring resource numerical value
CN108833521B (en) Message pushing method, device, system, computer equipment and storage medium
CN106933871B (en) Short link processing method and device and short link server
US10050899B2 (en) Data processing method, apparatus, client, server and system
CN109586969A (en) Content distributing network disaster recovery method, device, computer equipment and storage medium
CN107656988A (en) Document edit method and system
CN108683668A (en) Resource checksum method, apparatus, storage medium and equipment in content distributing network
CN110196843B (en) File distribution method based on container cluster and container cluster
CN111880858A (en) Document processing and instant messaging method, device, electronic equipment and storage medium
CN107918673B (en) Subscription data processing method and device, storage medium and computer equipment
CN107798405B (en) Medical service reservation method, medical service reservation device, storage medium and computer equipment
CN107203915B (en) Data storage method and device
CN111079095A (en) ID generation method and system
CN107634854B (en) Service data processing method and device
CN109391658B (en) Account data synchronization method and equipment, storage medium and terminal thereof
US20210112025A1 (en) Method and server for processing messages
CN111767481A (en) Access processing method, device, equipment and storage medium
CN107220818B (en) Online payment method and device
CN107463568B (en) Method and device for acquiring historical access data
CN108229127B (en) System and method for generating authentication data in advance to distinguish clients
CN104753755A (en) System access method, system access device, application client, and IM background system
CN110944037B (en) Method, computer device and storage medium for client cache change configuration
CN114363403A (en) Service access method, system, computer device and storage medium
US9210147B1 (en) Method, apparatus and computer program product for assessing risk associated with authentication requests

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20200921

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200921

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240218

Address after: Guohao Times City # 20-01, 128 Meizhi Road, Singapore

Patentee after: Advanced Nova Technology (Singapore) Holdings Ltd.

Guo jiahuodiqu after: Xin Jiapo

Address before: Ky1-9008 Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands, ky1-9008

Patentee before: Innovative advanced technology Co.,Ltd.

Guo jiahuodiqu before: Ikujin group

TR01 Transfer of patent right