Data processing method and device, electronic equipment, and storage medium

By storing data in a cache and a secondary database when a user exits the application, the problem of data storage failure due to the unavailability of the original database is solved, improving the robustness of the data storage system and the accuracy of data retrieval.

CN114168630BActive Publication Date: 2026-03-27NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

In existing technologies, when there is high traffic or hardware failure, the original database becomes unavailable, leading to data storage failure and the inability to obtain the latest data.

Method used

When a user exits the application, the data is stored in the server cache. If the first database storage fails, the data is sent to the second database storage, with the priority order being cache, second database, and first database.

Benefits of technology

This reduces the read pressure on the primary database, improves system robustness, reduces the probability of data storage failure, and ensures the accuracy and efficiency of data acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114168630B_ABST
    Figure CN114168630B_ABST
Patent Text Reader

Abstract

The application provides a data processing method and device, an electronic device and a storage medium. The method comprises the following steps: when a user exits an application, storing application data corresponding to the user in a cache of a server corresponding to the application, and simultaneously, sending the application data corresponding to the user to a first database for storage; if the storage in the first database fails, sending the application data corresponding to the user to a second database for storage. In the data storage process, the application embodiment increases the cache storage, so that the reading pressure on the first database can be reduced to a certain extent when the stored data is acquired subsequently. In addition, the second database is added, so that when the storage of the application data in the first database fails, the application data can be sent to the second database for storage, thereby improving the robustness of the system and reducing the probability of data storage failure.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a data processing method and device, electronic equipment and storage medium. BACKGROUND

[0002] Data storage is a key link in application development. In the prior art, most applications use a raw database to store data. When the business access volume is too high or hardware failure or bug (vulnerability) and other uncontrollable reasons occur, the raw database is likely to be unavailable, resulting in data storage failure, and further resulting in the inability to obtain the latest stored data from the raw database. SUMMARY

[0003] In view of the above problems, the present application is proposed to provide a data processing method and device, electronic equipment and storage medium which overcome the above problems or at least partially solve the above problems, comprising:

[0004] A data processing method, the method comprising:

[0005] When a user exits an application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and the application data corresponding to the user is sent to a corresponding first database for storage;

[0006] If the first database storage fails, the application data corresponding to the user is sent to a second database for storage.

[0007] Optionally, the method further comprises:

[0008] When the user logs in the application again, the target application data when the user last exited the application is obtained in the priority order of the cache, the second database and the first database;

[0009] When the target application data is obtained from the second database, the target application data is deleted from the second database.

[0010] Optionally, if the first database storage fails, the application data corresponding to the user is sent to a second database for storage, further comprising:

[0011] The user identifier of the user is stored in the memory of the server.

[0012] Optionally, when the user logs in the application again, the target application data when the user last exited the application is obtained in the priority order of the cache, the second database and the first database, comprising:

[0013] When the user logs in the application again, the target application data is obtained from the cache;

[0014] If the target application data fails to be obtained from the cache, it is determined whether the user identifier of the user is stored in the memory;

[0015] If the user identifier of the user is stored in the memory, the target application data is obtained from the second database;

[0016] If the user identifier of the user is not stored in the memory, the target application data is obtained from the first database.

[0017] Optionally, when the target application data is obtained from the second database, the target application data is deleted from the second database, and the method further includes:

[0018] The user identifier of the user is deleted from the memory.

[0019] Optionally, the first database and the second database are of different types.

[0020] A data processing method, the method comprising:

[0021] When a user logs in an application, target application data of the user when the user last exited the application is obtained in a priority order of a cache, a second database and a first database of a server corresponding to the application; wherein the first database is an original database corresponding to the application, and the second database is used to store data when the first database fails to store data;

[0022] When the target application data is obtained from the second database, the target application data is deleted from the second database.

[0023] Optionally, a user identifier corresponding to application data stored in the second database is stored in a memory of the server, and the target application data of the user when the user last exited the application is obtained in the priority order of the cache, the second database and the first database of the server corresponding to the application, comprising:

[0024] When the user logs in the application, the target application data is obtained from the cache;

[0025] If the target application data fails to be obtained from the cache, it is determined whether the user identifier of the user is stored in the memory;

[0026] If the user identifier of the user is stored in the memory, the target application data is obtained from the second database;

[0027] If the user identifier of the user is not stored in the memory, the target application data is obtained from the first database.

[0028] Optionally, the memory of the server stores the user identifier corresponding to the application data stored in the second database, and when the target application data is obtained from the second database, the target application data is deleted from the second database.

[0029] The user identifier corresponding to the target application data is deleted from the memory.

[0030] A data processing apparatus, the apparatus comprising:

[0031] A first data storage module, configured to store the application data corresponding to a user in a cache of a server corresponding to the application when the user logs out of the application, and send the application data corresponding to the user to a first database for storage.

[0032] A second data storage module, configured to send the application data corresponding to the user to a second database for storage if the first database fails to store the application data.

[0033] Optionally, the apparatus further comprises:

[0034] An obtaining module, configured to obtain target application data when the user logs in the application again according to a priority order of the cache, the second database and the first database.

[0035] A deleting module, configured to delete the target application data from the second database when the target application data is obtained from the second database.

[0036] Optionally, the second data storage module is further configured to store the user identifier of the user in the memory of the server.

[0037] Optionally, the obtaining module comprises:

[0038] A first obtaining module, configured to obtain the target application data from the cache when the user logs in the application again.

[0039] An obtaining judgment module, configured to judge whether the user identifier of the user is stored in the memory if the target application data fails to be obtained from the cache.

[0040] A second obtaining module, configured to obtain the target application data from the second database if the user identifier of the user is stored in the memory.

[0041] The third obtaining module is configured to obtain the target application data from the first database if the user identifier of the user is not stored in the memory.

[0042] Optionally, the deleting module is further configured to delete the user identifier of the user from the memory.

[0043] Optionally, the first database and the second database are of different types.

[0044] A data processing apparatus, the apparatus comprising:

[0045] The data obtaining module is configured to obtain target application data when a user logs in an application, according to a priority order of a cache of a server corresponding to the application, a second database and a first database, the first database being an original database corresponding to the application, the second database being configured to store data when the first database fails to store data.

[0046] The data deleting module is configured to delete the target application data from the second database when the target application data is obtained from the second database.

[0047] Optionally, the memory of the server stores a user identifier corresponding to application data stored in the second database, and the data obtaining module comprises:

[0048] The first data obtaining module is configured to obtain the target application data from the cache when the user logs in the application.

[0049] The data obtaining judging module is configured to judge whether the memory stores a user identifier of the user if the target application data is failed to be obtained from the cache.

[0050] The second data obtaining module is configured to obtain the target application data from the second database if the memory stores the user identifier of the user.

[0051] The third data obtaining module is configured to obtain the target application data from the first database if the memory does not store the user identifier of the user.

[0052] Optionally, the memory of the server stores a user identifier corresponding to application data stored in the second database, and the data deleting module is further configured to delete the user identifier corresponding to the target application data from the memory.

[0053] An electronic device comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program implementing the steps of the data processing method as described above when executed by the processor.

[0054] A computer readable storage medium having stored thereon a computer program, the computer program implementing the steps of the data processing method as described above when executed by a processor.

[0055] The present application has the following advantages:

[0056] In the embodiments of the present application, when a user exits an application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and the application data corresponding to the user is sent to the first database for storage; if the storage in the first database fails, the application data corresponding to the user is sent to the second database for storage; in the data storage process of the embodiments of the present application, the cache storage is added, and when the stored data is subsequently acquired, the reading pressure on the first database can be reduced to a certain extent; in addition, the second database is added, and when the storage of the application data in the first database fails, the application data is sent to the second database for storage, so that the robustness of the system can be improved and the probability of data storage failure can be reduced. BRIEF DESCRIPTION OF DRAWINGS

[0057] In order to more clearly illustrate the technical solutions of the present application, the following will briefly introduce the drawings needed to be used in the description of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0058] Figure 1 The step flow chart of a data processing method of an embodiment of the present application;

[0059] Figure 2 The step flow chart of another data processing method of an embodiment of the present application;

[0060] Figure 3 The structural block diagram of a data processing device of an embodiment of the present application;

[0061] Figure 4 The structural block diagram of another data processing device of an embodiment of the present application. DETAILED DESCRIPTION

[0062] In order to make the above objectives, characteristics and advantages of the present application more apparent, more comprehensible, the present application will be further described in details below in combination with the drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without any creative work, shall fall within the scope of protection of the present application.

[0063] Data storage is a key link in application development. In the prior art, most applications use a raw database to store data. When the business access volume is too high or hardware failure or bug occurs, etc., the raw database is likely to be unavailable, thereby causing data storage failure, and further causing accurate data to be unable to be obtained from the raw database.

[0064] Taking a game application as an example, according to the data storage manner of the prior art, the game data of a user is stored. When the user is offline, if the raw database is unavailable, the latest game data of the user cannot be correctly stored. When the user is online again, the game data of the user is directly obtained from the raw database. Even if the raw database is available, at this time, due to the data storage failure when the user was offline last time, the game data obtained from the raw database this time is not the latest, which will affect the game at this time.

[0065] In view of this, the embodiments of the present application provide a data processing method to overcome the defects of the prior art.

[0066] Referring to Figure 1 , a step flowchart of a data processing method provided by an embodiment of the present application is shown. In the embodiment of the present application, the data processing method can run on a server. The server can provide background services for an application. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, and big data and artificial intelligence platforms.

[0067] Among them, cloud computing is a computing mode, which distributes computing tasks on a large number of computing resources pool, so that various application systems can obtain computing power, storage space and information services according to needs. The network providing resources is called "cloud". The resources in the "cloud" are infinitely expandable to the user, and can be obtained at any time, used on demand, and expanded at any time. By establishing a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform), a variety of types of virtual resources are deployed in the resource pool for external customers to select and use. The cloud computing resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, network devices.

[0068] In the embodiment of the present application, the above data processing method can include the following steps:

[0069] Step 101, when the user exits the application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and the application data corresponding to the user is sent to the corresponding first database storage.

[0070] Step 102, if the first database storage fails, the application data corresponding to the user is sent to the second database storage.

[0071] In the embodiment of the present application, when the user exits the application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and the application data corresponding to the user is sent to the corresponding first database storage; if the first database storage fails, the application data corresponding to the user is sent to the second database storage; in the data storage process of the present application embodiment, the cache storage is increased, and when the stored data is obtained subsequently, the reading pressure on the first database can be reduced to a certain extent; in addition, the second database is increased, and when the first database fails to store the application data, the application data is sent to the second database for storage, which can improve the robustness of the system and reduce the probability of data storage failure.

[0072] In the following, the data processing method in the present exemplary embodiment will be further described.

[0073] In step 101, when the user exits the application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and the application data corresponding to the user is sent to the corresponding first database storage.

[0074] The cache refers to a memory that can exchange data at high speed. Specifically, a bidirectional linked list with a specified capacity can be opened in the memory of the server as the cache. For the convenience of description, the specified capacity is denoted as n, which indicates that the maximum cache data amount of the cache is n. In the data storage stage, when the amount of data stored in the cache reaches the maximum cache data amount n, if new data is added to the cache, the data that has not been updated for the longest time in the cache is replaced. It can be understood that the data stored in the cache is not necessarily constant. In the case where the amount of data stored in the cache reaches the maximum cache data amount, if there is a new data storage requirement, in order to make room for the storage of new data, the stored data in the cache corresponding to the new data needs to be deleted. Specifically, the stored data in the cache can be sorted according to the usage time, and the data with the earliest usage time is deleted first, and the process is repeated until the storage space freed up can be used to store new data. Of course, when the amount of stored data in the cache does not reach the maximum cache data amount, and when new data is stored in the cache without exceeding the maximum cache data amount, the new data can be directly stored in the cache without the need to delete the stored data in the cache.

[0075] The first database mentioned above can be regarded as an original database corresponding to the application, that is, the first database is a first-level database for storing application data corresponding to the application. It can be understood that, under normal circumstances, the application data of all users using the application will be stored in the first database. The first database and the cache mentioned above can correspond to the same server or different servers.

[0076] In the embodiments of the present application, when the user exits the application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and at the same time, the application data corresponding to the user is sent to the first database for storage. This can reduce the read pressure on the first database to a certain extent, and reduce the probability of failure of the first database. At the same time, when the data is read from the cache, the speed of reading data can also be improved.

[0077] Specifically, the user exiting the application mentioned above can include one or more of the following situations: the user's account logs out of the application, the user closes the application interface of the application, and the user does not perform any operation in the application within a set time.

[0078] Taking a game application as an example, when a user exits the game application, i.e., the user is offline, specifically, the user can be offline actively or passively, wherein the active offline refers to that the user actively exits the game application, and the passive offline refers to that the user is offline due to a cause other than subjective will of the user, such as offline caused by network disconnection, offline caused by power-off of a terminal device, and the like. The application data (i.e., game data) corresponding to the user is stored in a cache of a server corresponding to the game application, and the game data is sent to a first database for storage, so that when the user is online again, the game data at the last offline time can be retained to continue the game based on the game data at the last offline time.

[0079] Specifically, the game data can include a nickname, a level, experience, gold coins, skills, items, and the like, and the specific game data can be set according to actual needs. Optionally, the game data can include only data that changes in real time during the game process. That is, in the embodiment of the application, the stored application data can be set according to actual needs of the application, and can include only data that changes in real time during use of the application.

[0080] In step 102, if the first database fails to store, the application data corresponding to the user is sent to a second database for storage.

[0081] In the embodiment of the application, when the first database fails to store, such as when the first database fails to store due to an exception, the application data to be stored is sent to the second database for storage. The second database can be regarded as a secondary database corresponding to the application, and is used to temporarily store the application data when the first database fails to store the application data. The embodiment of the application can improve the robustness of the data storage system, reduce the probability of data storage failure, and further ensure the accuracy of the stored data subsequently acquired, by adding the second database to store the application data when the first database fails to store. The second database and the first database can correspond to the same server or different servers.

[0082] To further improve the stability of the data storage system, in an optional embodiment of the application, the first database and the second database are of different types. Specifically, the first database can be MongoDB, which is a database based on distributed file storage and written in C++, and is a product between a relational database and a non-relational database. The second database can be redis (Remote Dictionary Server), which is an open source Key-Value database written in ANSI C, supports network, and can be based on memory or persistent log.

[0083] It should be noted that the types of the first and second databases are not limited to the examples above. They can also be combinations of other types of databases. For example, the first database could be MongoDB and the second database could be SQL DB (Structured Query Language server database).

[0084] Furthermore, to facilitate subsequent retrieval of stored application data, in an optional embodiment of this application, the process of sending the application data corresponding to the user to the second database storage if the first database storage fails further includes:

[0085] The user's identifier is stored in the server's memory.

[0086] In this embodiment, while sending the application data corresponding to the user to the second database for storage, the user's user identifier is stored in the server's memory. When retrieving the stored application data later, the user identifier stored in memory can be used to determine whether the application data corresponding to the user is stored in the second database. If the user identifier is not stored in memory, it means that the application data corresponding to the user identifier is not stored in the second database. If the user identifier is stored in memory, it means that the application data corresponding to the user identifier is stored in the second database. Therefore, the efficiency of retrieving the stored application data later can be improved.

[0087] It is important to emphasize that the memory used to store user identifiers is different from the cache used to store application data mentioned earlier. That is, user identifiers stored in memory will not be forced to be deleted from memory due to the addition of new data or the length of time they have not been used.

[0088] Furthermore, in an optional embodiment of this application, the above data processing method further includes a data processing method in the data acquisition stage. Therefore, the above data processing method may further include:

[0089] When the user logs into the application again, the target application data from when the user last logged out of the application is retrieved according to the priority order of the cache, the second database, and the first database.

[0090] When the target application data is retrieved from the second database, the target application data is deleted from the second database.

[0091] In the embodiment, the application data is acquired according to the priority order of the cache, the second database and the first database when the stored application data is acquired, so that the efficiency and accuracy of data acquisition can be improved. When the application data is acquired from the second database, the acquired application data is deleted from the second database, so that the efficiency and accuracy of data acquisition can be further improved.

[0092] Specifically, when the user logs in the application again, the application data of the user when the user exits the application last time, i.e. the target application data, is acquired from the cache of the server first. Since the corresponding application data is stored in the cache of the server when the user exits the application in the data processing process in the application data storage stage, and the data acquisition speed from the cache is faster than that from other storages / databases. Therefore, in the embodiment, when the stored application data needs to be acquired, the cache is tried to be acquired first.

[0093] If the target application data cannot be acquired from the cache, the target application data corresponding to the user is acquired from the second database. Since the data in the cache is not fixed, i.e. the data stored in the cache first can be replaced by the data stored in the cache later, there can be a case that the application data cannot be acquired from the cache. In this case, the target application data corresponding to the user is acquired from the second database.

[0094] If the target application data cannot be acquired from the second database, the target application data corresponding to the user is acquired from the first database. Since the second database is used to store the application data only when the first database cannot store the application data, if the application data corresponding to the user when the user exits the application last time, i.e. the target application data to be acquired at this time, is successfully stored in the first database, the target application data is not stored in the second database at this time. Therefore, there can be a case that the target application data cannot be acquired from the second database, and the target application data corresponding to the user is acquired from the first database.

[0095] In order to facilitate understanding, the target application data is acquired according to the above priority order, so that the effect of improving the accuracy of data acquisition can be achieved. The following is an example of a game application.

[0096] When the user exits the game application last time, the game level of the game data of the user is level 10, and the first database successfully stores the game data, i.e. the game level of the game data stored in the first database is level 10;

[0097] When the user logs in the game application this time, the game data of the user when he / she exited the game application last time, i.e. the game data of the game level of 10, can be obtained from the first database (or the cache) according to the priority order of the cache, the second database and the first database; the user can resume the corresponding game character based on the obtained game data and control the game character to perform corresponding game tasks, etc.

[0098] When the user exits the game application this time, the game level in the corresponding game data is 15 because the user operated the game in the login state, i.e. the game level is 15. If the first database fails to store the game data, the game data is stored in the second database, i.e. the game level in the game data stored in the second database is 15, while the corresponding game data of the user stored in the first database is still the game data corresponding to the user when he / she exited the game application last time, i.e. the game level in the game data stored in the first database is 10, and the game level in the corresponding game data stored in the cache is 15.

[0099] When the user logs in the game application next time, the game data of the user when he / she exited the game application last time, i.e. the game data of the game level of 15, can be obtained according to the priority order of the cache, the second database and the first database; if the corresponding game data of the user is obtained from the cache, the game level in the obtained game data is 15 according to the game data storage condition of the last exit (i.e. the exit in the last paragraph) in the last paragraph, and no data is obtained from the second database and the first database; if the corresponding game data of the user is not obtained from the cache, the corresponding game data of the user can be obtained from the second database, and the game level in the obtained game data is 15 according to the game data storage condition of the last exit (i.e. the exit in the last paragraph) in the last paragraph, which is accurate. Since the corresponding game data of the user is obtained from the second database, the game data of the game level of 10 stored in the first database is not obtained, thereby realizing the efficiency and accuracy of data obtaining.

[0100] In order to ensure that the application data stored in the second database is the latest application data, the target application data needs to be deleted from the second database when the target application data is obtained from the second database. Further, it is ensured that the obtained stored application data is the latest application data of the user, and the accuracy of data obtaining is ensured.

[0101] Further, in an optional embodiment of the present application, in the storage mode of storing the user identifier of the user in the memory of the server while storing the application data in the second database, when the user logs in the application again, the target application data of the user when the user last exits the application can be obtained according to the priority order of the cache, the second database and the first database, which can include:

[0102] obtaining the target application data from the cache when the user logs in the application again;

[0103] if the target application data fails to be obtained from the cache, judging whether the user identifier of the user is stored in the memory;

[0104] if the user identifier of the user is stored in the memory, obtaining the target application data from the second database;

[0105] if the user identifier of the user is not stored in the memory, obtaining the target application data from the first database.

[0106] In the embodiment, since the user identifier corresponding to the application data stored in the second database is stored in the memory of the server, whether the application data corresponding to the user is stored in the second database can be judged according to whether the user identifier of the user is stored in the memory, so that the efficiency of obtaining the application data can be improved.

[0107] Further, in an optional embodiment of the present application, when the target application data is obtained from the second database, it further includes:

[0108] deleting the user identifier of the user from the memory.

[0109] In the embodiment, when the target application data of the user is successfully obtained from the second database, the target application data is deleted from the second database, and the user identifier corresponding to the target application data (i.e. the user identifier of the user corresponding to the target application data) is deleted from the memory. It can be ensured that the application data stored in the second database is the latest, so as to prevent the situation that the application data obtained from the second database is not the latest when the user logs in the application next time.

[0110] In the embodiment, when the target application data stored in the second database is acquired, the target application data is deleted from the second database, and the user identifier corresponding to the target application data is deleted from the memory, so that the first database and the second database store the latest application data at the next data storage process, the acquired stored application data is the latest application data corresponding to the user, and the accuracy of data acquisition is ensured. The application data stored in the second database and the user identifier stored in the memory have a one-to-one correspondence, so that the accuracy of determining whether the corresponding application data exists in the second database according to the user identifier in the memory is ensured.

[0111] In the embodiment, when the user exits the application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and the application data corresponding to the user is sent to the first database for storage. If the storage fails, the application data corresponding to the user is sent to the second database for storage. In the data storage process, the cache storage is added, so that the reading pressure on the first database can be reduced to some extent when the stored data is acquired subsequently. In addition, the second database is added, so that when the application data fails to be stored in the first database, the application data is sent to the second database for storage, the robustness of the data storage system and the data acquisition system is improved, and the probability of data storage failure is reduced.

[0112] It should be noted that, for the method embodiments, in order to simply describe, the method embodiments are described as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited to the order of the actions described, because according to the embodiments of the present application, some steps can be performed in other order or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily necessary for the embodiments of the present application.

[0113] Referring to Figure 2 , a step flowchart of another data processing method provided by an embodiment of the present application is shown, and the data processing method can run on a client device or a server. The client device can be a device close to the user side with data transmission function, such as a smart phone, a tablet computer, a notebook computer, etc. The server can be a physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, and basic cloud computing services such as big data and artificial intelligence platforms.

[0114] The embodiment of the present application mainly provides a data processing method from the perspective of data acquisition, which can specifically include the following steps:

[0115] In step 201, when a user logs in an application, target application data of the user when the user last exited the application is acquired according to a priority order of a cache of a server corresponding to the application, a second database and a first database; the first database is an original database corresponding to the application, and the second database is used to store data when the first database fails to store data.

[0116] In step 202, when the target application data is acquired from the second database, the target application data is deleted from the second database.

[0117] In the embodiment of the present application, when a user logs in an application, target application data of the user when the user last exited the application is acquired according to a priority order of a cache of a server corresponding to the application, a second database and a first database; the first database is an original database corresponding to the application, and the second database is used to store data when the first database is unavailable; when the target application data is acquired from the second database, the target application data is deleted from the second database. According to the characteristics of data storage of the cache, the first database and the second database, the priority order of data acquisition is set in the embodiment of the present application, so that the data acquisition efficiency and accuracy can be improved.

[0118] In the following, the data processing method in the present exemplary embodiment will be further described.

[0119] In step 201, when a user logs in an application, target application data of the user when the user last exited the application is acquired according to a priority order of a cache of a server corresponding to the application, a second database and a first database; the first database is an original database corresponding to the application, and the second database is used to store data when the first database fails to store data.

[0120] In the embodiment, when a user logs in an application, application data of the user when the user last exited the application, i.e. target application data, needs to be acquired to continue using the application on the basis of the last use progress.

[0121] In the embodiment, the cache is a bidirectional list with a specified capacity in the memory of the server, and has the characteristic of high-speed data exchange. The characteristic of the cache for storing data can be referred to the description of the previous embodiment. When the user exits the application each time, the corresponding application data of the user can be stored in the cache of the server; the first database is the original database corresponding to the application, that is, the first database is a first-level database for storing the application data corresponding to the application. It can be understood that, in normal circumstances, the data of all users corresponding to the application will be stored in the first database. The second database can be regarded as a second-level database corresponding to the application, which temporarily assumes the responsibility of storing the application data when the first database fails to store the application data.

[0122] It can be understood that when the user exits the application, the application data corresponding to the user is stored in the cache of the server corresponding to the application, and the application data corresponding to the user is sent to the corresponding first database for storage; if the first database fails to store, the application data is sent to the second database for storage.

[0123] In the embodiment, when the user logs in the application, the target application data is obtained according to the priority order of the cache, the second database and the first database, which can improve the efficiency and accuracy of data acquisition.

[0124] Specifically, when the user logs in the application, the target application data corresponding to the user is first attempted to be obtained from the cache of the server. Since the data obtained from the cache is faster than the data obtained from other storage / databases. Therefore, in the embodiment, when the target application data corresponding to the user needs to be obtained, the cache is first attempted to be obtained. If the target application data corresponding to the user can be obtained from the cache, the steps of obtaining the target application data from the second database and the first database can be omitted.

[0125] If the target application data cannot be obtained from the cache, the target application data corresponding to the user is attempted to be obtained from the second database. Since the data in the cache is not fixed, that is, the data stored in the cache at the first time can be replaced by the data stored in the cache at the second time, therefore, there can be a case that the target application data cannot be obtained from the cache, in which case, the target application data corresponding to the user is attempted to be obtained from the second database. If the target application data corresponding to the user can be obtained from the second database, it indicates that the first database fails to store the application data corresponding to the user when the user exits the application last time, and the application data corresponding to the user is successfully stored in the second database, in which case, after the target application data is obtained from the second database, the step of obtaining the target application data from the first database can be omitted.

[0126] If the target application data cannot be obtained from the second database, the target application data corresponding to the user is obtained from the first database. Since the second database is used to store application data when the first database cannot store application data, if the application data corresponding to the user is successfully stored in the first database when the user last exited the application, the target application data is not stored in the second database at this time. Therefore, there is a case that the target application data cannot be obtained from the second database, and at this time, the target application data corresponding to the user is obtained from the first database; the accuracy of the obtained application data can be ensured, that is, the obtained application data is the application data corresponding to the user when the user last exited the application, that is, the latest application data is ensured to be obtained.

[0127] In an optional embodiment of the present application, the first database and the second database are of different types. For example, the first database can be MongoDB, which is a database based on distributed file storage, written in C++ language, and a product between relational database and non-relational database. The second database can be redis (Remote Dictionary Server), which is an open source Key-Value database written in ANSI C language, supporting network, and based on memory or persistent log.

[0128] It should be noted that the types of the first database and the second database are not limited to the above examples, and can also be other types of databases, for example, the first database is MongoDB and the second database is SQL DB (Structured Query Language server database).

[0129] In step 202, when the target application data is obtained from the second database, the target application data is deleted from the second database.

[0130] In order to ensure that the application data stored in the second database is the latest application data, when the required application data is obtained from the second database, the application data needs to be deleted from the second database. Further, it is ensured that the obtained stored application data is the latest application data corresponding to the user, and the accuracy of data acquisition is ensured.

[0131] Further, in an optional embodiment of the present application, the memory of the server stores a user identifier corresponding to the application data stored in the second database, and the target application data when the user last exited the application is obtained according to the priority order of the cache of the server corresponding to the application, the second database and the first database, which can specifically include:

[0132] obtaining the target application data from the cache when the user logs in the application;

[0133] if the target application data fails to be obtained from the cache, judging whether the user identifier of the user is stored in the memory;

[0134] if the user identifier of the user is stored in the memory, obtaining the target application data from the second database;

[0135] if the user identifier of the user is not stored in the memory, obtaining the target application data from the first database.

[0136] In the embodiment, since the user identifier corresponding to the application data stored in the second database is stored in the memory of the server, whether the target application data corresponding to the user is stored in the second database can be judged according to whether the user identifier of the user is stored in the memory, so that the efficiency of obtaining the application data can be improved.

[0137] Further, in an optional embodiment of the present application, when the target application data is obtained from the second database, the target application data is deleted from the second database, and the method further comprises:

[0138] the user identifier corresponding to the target application data is deleted from the memory.

[0139] In the embodiment, when the target application data corresponding to the user is successfully obtained from the second database, the target application data is deleted from the second database, and the user identifier corresponding to the target application data (i.e. the user identifier of the user corresponding to the application data) is deleted from the memory. It can be ensured that the application data stored in the second database is the latest, so as to prevent the situation that the application data obtained from the second database is not the latest when the user logs in the application next time.

[0140] In the embodiment, when the target application data stored in the second database is obtained, the target application data is deleted from the second database, and the user identifier corresponding to the target application data is deleted from the memory, so that it can be ensured that only one of the first database and the second database stores the latest application data in the next data storage process, the stored application data obtained is the latest application data corresponding to the user, the accuracy of data obtaining is ensured, and the application data stored in the second database and the user identifier stored in the memory have a one-to-one correspondence, so as to ensure the accuracy of judging whether the corresponding application data exists in the second database according to the user identifier in the memory.

[0141] The embodiment of the present application, when the user logs in the application, the target application data when the user last exits the application is obtained according to the priority order of the cache of the server corresponding to the application, the second database and the first database; wherein the first database is the original database corresponding to the application, and the second database is used to store data when the first database is unavailable; when the target application data is obtained from the second database, the target application data is deleted from the second database; the data acquisition efficiency and accuracy can be improved.

[0142] It should be noted that for the method embodiments, in order to simply describe, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited by the order of the described actions, because according to the embodiments of the present application, certain steps can be performed in other order or at the same time. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions involved are not necessarily the necessary of the embodiments of the present application.

[0143] Referring to Figure 3 , a structural block diagram of an embodiment of a data processing apparatus of the present application is shown, the data processing apparatus provided by the embodiment can correspond to the data processing method embodiment described above, and specifically can include the following modules:

[0144] The first data storage module 301 is configured to store the application data corresponding to the user in the cache of the server corresponding to the application when the user exits the application, and simultaneously send the application data corresponding to the user to the corresponding first database for storage.

[0145] The second data storage module 302 is configured to send the application data corresponding to the user to the second database for storage if the first database storage fails.

[0146] In an optional embodiment of the present application, the apparatus further includes:

[0147] The acquisition module is configured to acquire the target application data when the user last exits the application according to the priority order of the cache, the second database and the first database when the user logs in the application again.

[0148] The deletion module is configured to delete the target application data from the second database when the target application data is obtained from the second database.

[0149] In an optional embodiment of the present application, the second data storage module 302 is further configured to store the user identifier of the user in the memory of the server.

[0150] In an optional embodiment of the present application, the obtaining module comprises:

[0151] The first obtaining module is configured to obtain the target application data from the cache when the user logs in the application again.

[0152] The obtaining judgment module is configured to judge whether the user identifier of the user is stored in the memory if the target application data fails to be obtained from the cache.

[0153] The second obtaining module is configured to obtain the target application data from the second database if the user identifier of the user is stored in the memory.

[0154] The third obtaining module is configured to obtain the target application data from the first database if the user identifier of the user is not stored in the memory.

[0155] In an optional embodiment of the present application, the deleting module is further configured to delete the user identifier of the user from the memory.

[0156] In an optional embodiment of the present application, the first database and the second database are of different types.

[0157] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the related parts refer to the part of the method embodiment.

[0158] Referring to Figure 4 , a structural block diagram of another data processing device embodiment of the present application is shown, the data processing device provided by the present embodiment corresponds to the another data processing method embodiment described above, and specifically can comprise the following modules:

[0159] The data obtaining module 401 is configured to obtain target application data when a user logs in an application according to a priority order of a cache, a second database and a first database of a server corresponding to the application, where the first database is an original database corresponding to the application, and the second database is configured to store data when the first database fails to store data.

[0160] The data deleting module 402 is configured to delete the target application data from the second database when the target application data is obtained from the second database.

[0161] Optionally, the memory of the server stores a user identifier corresponding to application data stored in the second database one by one, and the data obtaining module 401 comprises:

[0162] The first data obtaining module is configured to obtain the target application data from the cache when the user logs in the application.

[0163] The data obtaining judging module is configured to judge whether the user identifier of the user is stored in the memory if the target application data fails to be obtained from the cache.

[0164] The second data obtaining module is configured to obtain the target application data from the second database if the user identifier of the user is stored in the memory.

[0165] The third data obtaining module is configured to obtain the target application data from the first database if the user identifier of the user is not stored in the memory.

[0166] Optionally, the memory of the server stores the user identifier corresponding to the application data stored in the second database, and the data deleting module 402 is further configured to delete the user identifier corresponding to the target application data from the memory.

[0167] For the apparatus embodiment, it is basically similar to the method embodiment, so the description is relatively simple, and the related parts refer to the part of the method embodiment.

[0168] The embodiments of the present application further disclose an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and the computer program implements the steps of the data processing method when executed by the processor.

[0169] The embodiments of the present application further disclose a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program implements the steps of the data processing method when executed by a processor.

[0170] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other.

[0171] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, an apparatus, or a computer program product. Therefore, the embodiments of the present application can adopt a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can adopt a computer program product in the form of one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.

[0172] The embodiments of the present application are described with reference to the flowchart illustrations and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present application. It is understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal devices to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal devices, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.

[0173] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal devices to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.

[0174] These computer program instructions can also be loaded into a computer or other programmable data processing terminal devices, such that a series of operational steps are carried out on the computer or other programmable terminal devices to produce a computer implemented process so that the instructions executed on the computer or other programmable terminal devices provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.

[0175] Although the preferred embodiments of the present application have been described, those skilled in the art will be able to make additional modifications and variations to these embodiments once they have the benefit of the foregoing description. Accordingly, it is intended that the appended claims be construed to include all such modifications and variations as fall within the scope of the embodiments of the present application.

[0176] Finally, it is to be understood that the phraseology or terminology such as "first" and "second" etc. used herein is merely intended to differentiate one entity or operation from another entity or operation, without necessarily requiring or implying any actual such relationship or order between such entities or operations. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0177] The data processing method and device, electronic device and storage medium provided in the present application are described in detail above, the principles and implementation manners of the present application are described by applying specific examples in the present article, the above example description is only used to help understand the method and core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manner and application range will be changed, and the above description should not be understood as a limitation on the present application.

Claims

1. A data processing method, characterized by, The method comprises: When a user logs out of an application, storing application data corresponding to the user in a cache of a server corresponding to the application, and simultaneously sending the application data corresponding to the user to a corresponding first database storage; the application data comprises data that changes in real time during use of the application; If the first database storage fails, sending the application data corresponding to the user to a second database storage; wherein whether to obtain target application data of the user when the user last logged out of the application from the second database is determined based on whether a user identifier of the user is stored in a memory of the server; the type of the first database and the type of the second database are different; When the target application data is obtained from the second database, deleting the target application data from the second database.

2. The method of claim 1, wherein, The method further comprises: When the user logs in to the application again, obtaining the target application data of the user when the user last logged out of the application in a priority order of the cache, the second database and the first database.

3. The method of claim 2, wherein, If the first database storage fails, sending the application data corresponding to the user to a second database storage, further comprising: Storing the user identifier of the user in the memory of the server.

4. The method of claim 3, wherein, When the user logs in to the application again, obtaining the target application data from the cache; If the target application data is not obtained from the cache, determining whether the user identifier of the user is stored in the memory; If the user identifier of the user is stored in the memory, obtaining the target application data from the second database; If the user identifier of the user is not stored in the memory, obtaining the target application data from the first database. When the target application data is obtained from the second database, deleting the target application data from the second database, further comprising:

5. The method of claim 4, wherein, Deleting the user identifier of the user from the memory. The method comprises:

6. A data processing method, characterized by, When a user logs in to an application, obtaining target application data of the user when the user last logged out of the application in a priority order of a cache of a server corresponding to the application, a second database and a first database corresponding to the application; wherein the first database is an original database corresponding to the application, the second database is used to store data when the first database storage fails; the target application data comprises data that changes in real time during use of the application; whether to obtain the target application data from the second database is determined based on whether a user identifier of the user is stored in a memory of the server; When the target application data is obtained from the second database, deleting the target application data from the second database; the type of the first database and the type of the second database are different. The apparatus comprises:

7. A data processing apparatus, characterized by ​ The first data storage module is configured to store the application data corresponding to the user in the cache of the server corresponding to the application when the user exits the application, and send the application data corresponding to the user to the first database storage; the application data includes data that changes in real time during use of the application. The second data storage module is configured to send the application data corresponding to the user to the second database storage if the first database storage fails; whether the target application data of the user when the user last exited the application is obtained from the second database is determined based on whether the user identifier of the user is stored in the memory of the server; the first database and the second database are of different types; and the target application data is deleted from the second database when the target application data is obtained from the second database.

8. A data processing apparatus, characterized by, The apparatus comprises: The data acquisition module is configured to obtain the target application data of the user when the user last exited the application in the order of priority of the cache of the server corresponding to the application, the second database and the first database when the user logs in the application; the first database is the original database corresponding to the application, and the second database is configured to store data when the first database storage fails; the target application data includes data that changes in real time during use of the application; whether the target application data is obtained from the second database is determined based on whether the user identifier of the user is stored in the memory of the server; The data deletion module is configured to delete the target application data from the second database when the target application data is obtained from the second database; the first database and the second database are of different types.

9. An electronic device, comprising: The computer program is stored on the computer readable storage medium and is executable on the processor to implement the steps of the data processing method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium and is executable on the processor to implement the steps of the data processing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data processing method, server, system and computer readable program medium

    CN110898434A

  • Data processing system, method and device

    CN112597163A

  • Data storage method, device and equipment based on message-oriented middleware and storage medium

    CN112650814A