Data processing method, device, electronic device and storage medium
By creating preset placeholder data in the cache system and using target data coverage, the problem of excessive pressure on the database during network attacks is solved, and database performance is improved.
Patent Information
- Application Number
- CN202111388831.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-22
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-11-22
AI Technical Summary
When handling network attacks, the client's data requests are not found in the cache or in the database, causing the database to be under too much pressure and affect performance.
Create preset placeholder data corresponding to the account identification in the cache system, and create account identification and target data in the database, and use target data to cover the preset placeholder data to reduce direct query to the database.
By establishing preset placeholder data in the cache system, a large number of attack requests are avoided to go to the database, reducing the pressure on the database and improving database performance.
Smart Images

Figure CN114691729B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of the current mobile Internet, there is a large amount of data interaction between the client and the backend database. In the prior art, when the client reads data from the database, it generally reads the data in the cache first. When the data does not exist in the cache, it can read the data from the database. The goal of this is to reduce the requests to the database so that as many requests as possible can get the results in the cache.
[0003] However, in some network attacks, the requests have no corresponding data either in the cache or in the database. According to the above process, they will eventually reach the database, which will cause great pressure on the database and affect database performance. Summary of the invention
[0004] The present disclosure provides a data processing method, device, electronic device and storage medium. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a data processing method, including:
[0006] Receive a data request from a client; the data request includes an account ID;
[0007] Determine a cache system corresponding to the business to which the data request belongs; the business is one of multiple businesses corresponding to the cache system;
[0008] If the data obtained from the cache system based on the account identifier is a null value, the database corresponding to the business is determined;
[0009] If the data obtained from the database based on the account identifier is a null value, the account identifier and the preset placeholder data corresponding to the account identifier are created in the cache system;
[0010] Send preset placeholder data to the client.
[0011] In some possible embodiments, after sending the preset placeholder data to the client, the method further includes:
[0012] receiving a data request; the data request includes an account identifier;
[0013] Determine the cache system corresponding to the business to which the data request belongs;
[0014] Get the preset placeholder data from the cache system;
[0015] Send preset placeholder data to the client.
[0016] In some possible embodiments, the method further includes:
[0017] Receive a target data creation instruction from a client; the target data creation instruction includes an account identifier;
[0018] Determine the database corresponding to the business to which the target data creation instruction belongs;
[0019] Create an account ID and target data corresponding to the account ID in the database;
[0020] In the cache system, the preset placeholder data is overwritten with the target data.
[0021] In some possible embodiments, the method further includes:
[0022] Receive a target data update instruction from a client; the target data update instruction includes an account identifier and update data;
[0023] Identify the database;
[0024] Based on the update data, the target data corresponding to the account identifier is updated to obtain the updated target data;
[0025] Delete the target data in the cache system.
[0026] In some possible embodiments, after deleting the target data in the cache system, the method further includes:
[0027] Receive a data request from a client; the data request includes an account ID;
[0028] The data corresponding to the account ID obtained from the cache system is null;
[0029] The data corresponding to the account ID obtained from the database is the updated target data;
[0030] The updated target data is stored in the cache system as data corresponding to the account identifier;
[0031] Feedback the updated target data to the client.
[0032] In some possible embodiments, in the cache system, overwriting the preset placeholder data with the target data includes:
[0033] Sending a data overwrite instruction to the cache system; the data overwrite instruction includes target data and an account identifier; the data overwrite instruction is used to instruct the cache system to overwrite the preset placeholder data with the target data;
[0034] In the case where the target data fails to overwrite the preset placeholder data, deleting the preset placeholder data in the cache system;
[0035] The data overwrite instruction is stored in the message queue, so that the consumer end corresponding to the message queue sends the data overwrite instruction to the cache system.
[0036] In some possible embodiments, after deleting the preset placeholder data in the cache system, the method further includes:
[0037] receiving a data request; the data request includes an account identifier;
[0038] The data corresponding to the account ID obtained from the cache system is null;
[0039] The data corresponding to the account ID obtained from the database is the target data.
[0040] According to a second aspect of an embodiment of the present disclosure, there is provided a data processing device, including:
[0041] A receiving module is configured to execute and receive a data request from a client; the data request includes an account identifier;
[0042] A cache system determination module is configured to determine a cache system corresponding to a service to which a data request belongs; the service is one of multiple services corresponding to the cache system;
[0043] A database determination module is configured to determine a database corresponding to the business if the data obtained from the cache system based on the account identifier is a null value;
[0044] A placeholder data creation module is configured to execute, if the data obtained from the database based on the account identifier is a null value, create the account identifier and preset placeholder data corresponding to the account identifier in the cache system;
[0045] The sending module is configured to send preset placeholder data to the client.
[0046] In some possible embodiments, the device further includes:
[0047] A receiving module is configured to execute receiving a data request; the data request includes an account identifier;
[0048] A cache determination module, configured to execute determination of a cache system corresponding to the business to which the data request belongs;
[0049] A placeholder data acquisition module is configured to acquire preset placeholder data from the cache system;
[0050] The sending module is configured to send preset placeholder data to the client.
[0051] In some possible embodiments, the device further includes:
[0052] A receiving module is configured to execute a target data creation instruction of a receiving client; the target data creation instruction includes an account identifier;
[0053] A database determination module is configured to execute and determine a database corresponding to the business to which the target data creation instruction belongs;
[0054] A target data creation module is configured to create an account identifier and target data corresponding to the account identifier in a database;
[0055] The target data overwriting module is configured to be executed in the cache system and overwrite the preset placeholder data with the target data.
[0056] In some possible embodiments, the device further includes:
[0057] A receiving module is configured to execute a target data update instruction received from a client; the target data update instruction includes an account identifier and update data;
[0058] A database determination module is configured to execute database determination;
[0059] A target data updating module is configured to update the target data corresponding to the account identifier based on the update data to obtain updated target data;
[0060] The target data deletion module is configured to delete the target data in the cache system.
[0061] In some possible embodiments, the device further includes:
[0062] A receiving module is configured to execute and receive a data request from a client; the data request includes an account identifier;
[0063] The target data acquisition module is configured to execute that the data corresponding to the account identifier obtained from the cache system is a null value; the data corresponding to the account identifier obtained from the database is the updated target data;
[0064] A target data storage module is configured to store the updated target data as data corresponding to the account identifier in the cache system;
[0065] The sending module is configured to feed back the updated target data to the client.
[0066] In some possible embodiments, the target data coverage module is configured to execute:
[0067] Sending a data overwrite instruction to the cache system; the data overwrite instruction includes target data and an account identifier; the data overwrite instruction is used to instruct the cache system to overwrite the preset placeholder data with the target data;
[0068] In the case where the target data fails to overwrite the preset placeholder data, deleting the preset placeholder data in the cache system;
[0069] The data overwrite instruction is stored in the message queue, so that the consumer end corresponding to the message queue sends the data overwrite instruction to the cache system.
[0070] In some possible embodiments, the receiving module is configured to execute receiving a data request; the data request includes an account identifier;
[0071] The target data acquisition module is configured to execute that the data corresponding to the account identifier obtained from the cache system is a null value; the data corresponding to the account identifier obtained from the database is the target data.
[0072] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement a method as described in any one of the first aspects above.
[0073] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the methods in the first aspect of the embodiment of the present disclosure.
[0074] According to the fifth aspect of an embodiment of the present disclosure, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a readable storage medium, at least one processor of a computer device reading and executing the computer program from the readable storage medium, so that the computer device performs any one of the methods in the first aspect of the embodiment of the present disclosure.
[0075] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0076] Receive a data request from a client, the data request includes an account ID, determine the cache system corresponding to the business to which the data request belongs, the business is one of the multiple businesses corresponding to the cache system, if the data obtained from the cache system based on the account ID is a null value, then determine the database corresponding to the business, if the data obtained from the database based on the account ID is a null value, create the account ID and preset placeholder data corresponding to the account ID in the cache system, and send the preset placeholder data to the client. In the embodiment of the present application, by establishing preset placeholder data in the cache system, subsequent requests can be fed back in the cache system, avoiding the situation where a large number of attack requests go to the database, and reducing the pressure on the database.
[0077] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0079] Figure 1 is a schematic diagram of an application environment according to an exemplary embodiment;
[0080] Figure 2 is a flow chart of a data processing method according to an exemplary embodiment;
[0081] Figure 3 is a flow chart of a data processing method according to an exemplary embodiment;
[0082] Figure 4 is a flowchart of data creation according to an exemplary embodiment;
[0083] Figure 5 is a flow chart showing a data update according to an exemplary embodiment;
[0084] Figure 6 is a flow chart showing a data acquisition method according to an exemplary embodiment;
[0085] Figure 7 is a block diagram of a data processing device according to an exemplary embodiment;
[0086] Figure 8 It is a block diagram of an electronic device for data processing according to an exemplary embodiment. DETAILED DESCRIPTION
[0087] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0088] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar first objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0089] All user data in this application is authorized by the user.
[0090] See also Figure 1 , Figure 1 is a schematic diagram of an application environment of a data processing method according to an exemplary embodiment. Figure 1 As shown, the application environment may include a server 01 and a client 02. The database may be hosted on the server 01, or may be independent of the server 01 and hosted on a database server.
[0091] In some possible embodiments, the client 02 may include but is not limited to a smartphone, a desktop computer, a tablet computer, a laptop computer, a smart speaker, a digital assistant, an augmented reality (AR) / virtual reality (VR) device, a smart wearable device, etc. It may also be software running on the client, such as an application, a small program, etc. Optionally, the operating system running on the client may include but is not limited to Android system, IOS system, Linux, Windows, Unix, etc.
[0092] In some possible embodiments, the server 01 receives a data request from the client 02, the data request includes an account identifier, and determines a cache system corresponding to a business to which the data request belongs, where the business is one of multiple businesses corresponding to the cache system. If the data obtained from the cache system based on the account identifier is a null value, the database corresponding to the business is determined, and if the data obtained from the database based on the account identifier is a null value, the account identifier and preset placeholder data corresponding to the account identifier are created in the cache system, and the preset placeholder data is sent to the client 02.
[0093] Optionally, the server 01 may include an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The operating system running on the server may include but is not limited to Android, IOS, Linux, Windows, Unix, etc.
[0094] Optionally, if the server where the database or cache system is located is not server 01, the server where the database or cache system is located includes an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The operating system running on the server may include but is not limited to Android, IOS, Linux, Windows, Unix, etc.
[0095] Figure 1 The schematic diagram of the application environment shown is an optional environment schematic diagram. In other possible embodiments, the application environment may include a business server 01, a client 02, a database server 03, and a cache system 04. There is a link between the business server 01 and the client 02, and there is a link between the business server 01 and the database server 03 and the cache system 04.
[0096] Figure 2 is a flow chart of a data processing method according to an exemplary embodiment. Figure 2 As shown, the data processing method can be applied to a server or other node devices, and includes the following steps:
[0097] In step S201, a data request from a client is received; the data request includes an account identifier.
[0098] In an embodiment of the present application, a server receives a data request sent by a client, and the server may be a business server for a specific business. For example, the server may be connected to a music application so that a user can obtain a certain music from the server through the music application on the client. The server may be connected to a social application so that a user can obtain certain information from the server through the social application on the client. The server may be connected to a game application so that a user can obtain certain virtual pet data from the server through the social application on the client. The following description of the embodiment of the present application takes the server as a business server connected to a game application as an example. For other application scenarios, please refer to the business server of this game application.
[0099] In some possible embodiments, the server may receive a data request from a client, wherein the data request carries an account identifier. Optionally, the account identifier may include a user's phone number, an email address, the user's account information, and an identifier of the client.
[0100] In step S203, the cache system corresponding to the service to which the data request belongs is determined; the service is one of multiple services corresponding to the cache system.
[0101] In an optional embodiment, the client application and the service server are one-to-one corresponding. That is, a game application has a dedicated server to connect with it, and when the server receives a data request, it determines that the service to which the data request belongs is the service corresponding to the game application.
[0102] In another optional embodiment, the client application and the service server are not one-to-one corresponding. For example, the server can provide services for application A and application B. In this case, the data request must carry not only the account ID but also the application ID. In this way, when the server receives the data request, it can determine which application is currently providing services.
[0103] In the embodiment of the present application, the cache system can be hosted in the server, or can be independent of the server as a separate device, but only stores data for the services provided by the server.
[0104] In the embodiment of the present application, the cache system can be hosted in the server or can be independent of the server as a separate device, but can store data for services provided by multiple servers. In other words, the current server is only one of the servers that the cache system can serve, that is, the service to which the data request belongs can be one of the multiple services corresponding to the cache system.
[0105] Based on this, after receiving a data request, the server can directly determine the cache system corresponding to the business to which the data request belongs, or determine the cache system corresponding to the business to which the data request belongs based on the identifier of the application.
[0106] In some possible embodiments, the cache system can be a public cache system that provides data cache services for multiple businesses or multiple servers. Optionally, the cache system can be a Remote Dictionary Server (Redis) type database, which is a key-value storage system. Optionally, the cache system can be a memcached type database, which is a key-value storage system.
[0107] In step S205, if the data obtained from the cache system based on the account identifier is a null value, the database corresponding to the business is determined.
[0108] In an embodiment of the present application, when the server determines the cache system corresponding to the business, it can call the cache system, use the account ID as the key, and obtain the data corresponding to the Key from the cache system. Optionally, assuming that the data obtained from the cache system is a null value, it may be that the client has not yet created the data corresponding to the account ID in the database, and therefore, the data corresponding to the account ID cannot be obtained in the cache system. Optionally, assuming that the data obtained from the cache system is a null value, it may also mean that the data corresponding to the account ID exists in the database, but due to some reasons, such as network delays and cluster jitters, the data corresponding to the account ID cannot be synchronized in the cache system in a timely manner, and the server cannot obtain the data corresponding to the account ID in the cache system. In an embodiment of the present application, a null value means that the server cannot obtain the data corresponding to the key from the cache system.
[0109] Based on the above reasons, the server can determine the database corresponding to the business, and further determine whether the data corresponding to the account identifier can be obtained from the database.
[0110] In the embodiment of the present application, the database can be hosted in the server, or it can be independent of the server as a separate device, but it only stores data for the services provided by the server.
[0111] In the embodiment of the present application, the database can be hosted in the server or can be independent of the server as a separate device, but can store data for services provided by multiple servers. In other words, the current server is only one of the servers that the database can serve, that is, the service to which the data request belongs can be one of the multiple services corresponding to the database.
[0112] In step S207, if the data obtained from the database based on the account identifier is a null value, the account identifier and preset placeholder data corresponding to the account identifier are created in the cache system.
[0113] In the embodiment of the present application, when the server determines the database corresponding to the business, it can call the database, use the account ID as the key, and obtain the data corresponding to the Key from the database. Optionally, assuming that the data obtained from the database is a null value, it may be that the client has not yet created the data corresponding to the account ID in the database, and therefore, the data corresponding to the account ID cannot be obtained in the database.
[0114] In this case, the operation of the client sending a data request to the server may be an unconscious operation made by the corresponding user of the client, or it may be a network attack. However, as long as the data corresponding to the account identifier is not created in the database, the server will eventually go to the database to query the data after receiving the data request, which will inevitably cause great pressure on the database and affect the database performance. Based on this, the server can create the account identifier (key) and the preset placeholder data (value) corresponding to the account identifier in the cache system.
[0115] For example, assuming that the service provided by the server is a game application for a virtual pet, and the data request includes account information XXXXXX123, if the data corresponding to the account identifier is not created in the database, the account information XXXXXX123 and the preset placeholder data corresponding to the account information can be set in the cache system, and the preset placeholder data can include the identifier of the virtual pet, the attribute information of the virtual pet, and the attribute information can include the type and level of the virtual pet. In addition, the cache system can also store the account identifier, and save the relationship between the account identifier and the preset placeholder data in the form of a key-value pair.
[0116] Optionally, the identifier, type and level of the virtual pet in the preset placeholder data can be preset. The identifier, type and level of the virtual pet in the preset placeholder data can be identifiers, types and levels that cannot be used for normally created virtual pets. For example, the type is "-1" and the level is "-1".
[0117] In step S209, the preset placeholder data is sent to the client.
[0118] Optionally, after the server creates preset placeholder data corresponding to the account identifier in the cache system, the server may directly send the preset placeholder data to the client.
[0119] Optionally, after the server creates preset placeholder data corresponding to the account identifier in the cache system, it may send a feedback message to the client, where the feedback message indicates that there is no corresponding data for the account identifier.
[0120] In some possible embodiments, after the server creates the preset placeholder data in the cache system, it may receive a data request containing the account identifier again. Optionally, the server may directly read the preset placeholder data and feed it back to the client.
[0121] Figure 3 is a flow chart of a data processing method according to an exemplary embodiment. Figure 3 As shown, after step S209, the following steps may be included:
[0122] In step S301, a data request is received, the data request including an account identifier.
[0123] In step S303, the cache system corresponding to the business to which the data request belongs is determined.
[0124] In step S305, preset placeholder data is obtained from the cache system.
[0125] In step S307, the preset placeholder data is sent to the client.
[0126] In an embodiment of the present application, the server receives a data request sent by a client, and parses the data request to obtain an account identifier. The server can directly determine the cache system corresponding to the business to which the data request belongs, or determine the cache system corresponding to the business to which the data request belongs based on the identifier of the application. Since the preset placeholder data corresponding to the account identifier has been created in the cache system before, the server can read the preset placeholder data from the cache system instead of reading the data from the database. Subsequently, the server can directly send the preset placeholder data to the client, or send a feedback message to the client, which indicates that there is no corresponding data for the account identifier.
[0127] Since there is already preset placeholder data in the cache system, data requests can directly obtain data from the cache system and feed it back to the client without going to the database. This can reduce the amount of data requests faced by the database, thereby ensuring the performance of the database.
[0128] Figure 4 is a flowchart of data creation according to an exemplary embodiment. Figure 4 As shown, after step S209 or step S307, the following steps are included:
[0129] In step S401, a target data creation instruction from a client is received; the target data creation instruction includes an account identifier.
[0130] In the embodiment of the present application, the server receives a target data creation instruction sent by the client and can parse the target data creation instruction to obtain an account identifier.
[0131] In step S403, the database corresponding to the business to which the target data creation instruction belongs is determined.
[0132] Since the server receives the target data creation instruction sent based on the same application, or may be called a write instruction, the server may determine the database corresponding to the business to which the target data creation instruction belongs.
[0133] In step S405, the account identifier and target data corresponding to the account identifier are created in the database.
[0134] Optionally, after receiving the target data creation instruction, the server can obtain the initial data corresponding to the account identifier. Taking a game application as an example, the initial data of a virtual pet includes the virtual pet's pet identifier (such as a randomly generated number or text, and different from the pet identifiers of other virtual pets), the type of the virtual pet (such as "0", "0" indicates that the type is to be determined), and the level of the virtual pet (such as "0", "0" indicates the initial level). The initial data is stored as the target data in the database. In addition, the account identifier can also be saved in the database, and the relationship between the account identifier and the target data can be saved in the form of a key-value pair.
[0135] In step S407, in the cache system, the preset placeholder data is overwritten with the target data.
[0136] Since the data corresponding to the account ID in the cache system is still the preset placeholder data, if the server receives a data request for the account ID at this time, it will still feedback the preset placeholder data, which is obviously unreasonable. Based on this, after the server creates the target data corresponding to the account ID in the database, it can overwrite the preset placeholder data in the cache system based on the target data, so that the account ID in the cache system also corresponds to the same target data.
[0137] In some possible embodiments, a monitoring component binlog may be set in the database to monitor insert events in the database. When an insert event occurs in the database, the monitoring component may obtain the target data, determine the preset placeholder data corresponding to the account identifier, and overwrite the preset placeholder data with the target data.
[0138] In some other possible embodiments, after the server creates the target data corresponding to the account identifier in the database, it can send a data overwrite instruction to the cache system. The data overwrite instruction includes the target data and the account identifier, and the data overwrite instruction can be used to instruct the cache system to overwrite the preset placeholder data with the target data. Optionally, in the event that the target data fails to overwrite the preset placeholder data, the preset placeholder data in the cache system can be deleted, and the data overwrite instruction can be stored in a message queue so that the consumer end corresponding to the message queue sends the data overwrite instruction to the cache system.
[0139] In this way, when the data overwrite instruction fails to be sent due to network delay or cluster jitter, the message queue can be used to ensure that the data overwrite instruction is sent again, thereby unifying the data in the cache system and the data in the database. At the same time, by deleting the preset placeholder data in the cache system, it can also be ensured that if there is data corresponding to the requested account identifier, the wrong preset placeholder data can be obtained from the cache system.
[0140] In some possible embodiments, after deleting the preset placeholder data in the cache system, when receiving a data request, the account data can be parsed from the data request. Subsequently, the cache system corresponding to the business to which the data request belongs is determined. At this time, since the preset placeholder data in the cache system has been deleted, the data corresponding to the account identifier obtained from the cache system is a null value. Then, the server can determine the database corresponding to the business and obtain the data corresponding to the account identifier from the database as the target data.
[0141] In this way, even if the target data fails to overwrite the preset placeholder data in the cache system and the data overwriting instruction is still in the message queue, the client can still obtain the accurate target data from the database.
[0142] After the target data corresponding to the account ID exists in the database, the target data may be modified (for example, deleting certain fields or modifying certain fields). Based on this, Figure 5 is a flow chart showing a data update according to an exemplary embodiment. Figure 5 As shown, after step S407, the following steps are included:
[0143] In step S501, a target data update instruction from a client is received; the target data update instruction includes an account identifier and update data.
[0144] In the embodiment of the present application, the server receives the target data update instruction sent by the client, and can parse the target data update instruction to obtain the account identifier and update data. The update data may include the field to be updated and the update position in the target data.
[0145] In step S503, the database is determined.
[0146] Since the target data update instruction received by the server is sent based on the same application program, the server can determine the database corresponding to the business (the same business) to which the target data update instruction belongs.
[0147] In step S505, the target data corresponding to the account identifier is updated based on the update data to obtain updated target data.
[0148] In step S507, the target data in the cache system is deleted.
[0149] In the embodiment of the present application, the data in the database may be permanent data. The cache system may be public and needs to be connected to multiple services or multiple servers. Therefore, considering the amount of data that the cache system needs to store, the data stored may be temporary. Optionally, after the server updates the target data corresponding to the account identifier based on the updated data and obtains the updated target data, it may delete the target data in the cache system considering the data storage capacity of the cache system.
[0150] After deleting the target data in the cache system, if the server receives a data request containing the account identifier again, the updated target data can be obtained from the database and saved in the cache system. Figure 6 is a flow chart of data acquisition according to an exemplary embodiment. Figure 6 As shown, after step S507, the following steps are included:
[0151] In step S601, a data request from a client is received; the data request includes an account identifier.
[0152] In step S603, the data corresponding to the account identifier obtained from the cache system is a null value.
[0153] In step S605, the data corresponding to the account identification obtained from the database is the updated target data.
[0154] In step S607, the updated target data is stored in the cache system as data corresponding to the account identifier.
[0155] In step S609, the updated target data is fed back to the client.
[0156] In an embodiment of the present application, the server receives a data request sent by the client, and parses the data request to obtain an account identifier. The server can directly determine the cache system corresponding to the business to which the data request belongs, or determine the cache system corresponding to the business to which the data request belongs based on the identifier of the application.
[0157] Because in the above text, after the target data in the database is updated, the target data in the cache system has been deleted. Therefore, the data corresponding to the account identifier obtained by the server from the cache system is a null value. That is, the server cannot obtain the data corresponding to the account identifier from the cache system. Then the server can determine the database corresponding to the business, and obtain the data corresponding to the account identifier from the database as the updated target data. In order to prevent the subsequent data requests received from going to the database again because there is no updated target data in the cache system, which puts pressure on the database, the updated target data can be stored in the cache system as the data corresponding to the account identifier, and at the same time, the updated target data can be fed back to the client.
[0158] In another optional embodiment, when the server updates the target data corresponding to the account identifier based on the update data and obtains the updated target data, the updated target data can be used to overwrite the target data in the cache system, thereby keeping the data in the cache system and the database consistent. However, considering the amount of data that the cache system needs to store and the temporary nature of the data stored in the cache system, the data storage situation in the cache system can be monitored, and when the data storage situation in the cache system meets the preset conditions, the data can be deleted.
[0159] Optionally, the data storage situation in the storage system meeting a preset condition may include that the server does not receive a data request for the data within a preset time period.
[0160] In summary, in the embodiments of the present application, when data corresponding to an account identifier is not created in the database, preset placeholder data can be established in the cache system so that subsequent requests can be fed back in the cache system, thereby avoiding a large number of attack requests going to the database and reducing the pressure on the database.
[0161] Figure 7 is a block diagram of a data processing device according to an exemplary embodiment. Figure 7 The device includes an instruction receiving module 701, a cache system determining module 702, a database determining module 703, a placeholder data creating module 704 and a sending module 705.
[0162] The receiving module 701 is configured to receive a data request from a client; the data request includes an account identifier;
[0163] The cache system determination module 702 is configured to determine the cache system corresponding to the service to which the data request belongs; the service is one of the multiple services corresponding to the cache system;
[0164] The database determination module 703 is configured to determine the database corresponding to the business if the data obtained from the cache system based on the account identifier is a null value;
[0165] The placeholder data creation module 704 is configured to execute, if the data obtained from the database based on the account identifier is a null value, creating the account identifier and the preset placeholder data corresponding to the account identifier in the cache system;
[0166] The sending module 705 is configured to send preset placeholder data to the client.
[0167] In some possible embodiments, the device further includes:
[0168] A receiving module is configured to execute receiving a data request; the data request includes an account identifier;
[0169] A cache determination module, configured to execute determination of a cache system corresponding to the business to which the data request belongs;
[0170] A placeholder data acquisition module is configured to acquire preset placeholder data from the cache system;
[0171] The sending module is configured to send preset placeholder data to the client.
[0172] In some possible embodiments, the device further includes:
[0173] A receiving module is configured to execute a target data creation instruction of a receiving client; the target data creation instruction includes an account identifier;
[0174] A database determination module is configured to execute and determine a database corresponding to the business to which the target data creation instruction belongs;
[0175] A target data creation module is configured to create an account identifier and target data corresponding to the account identifier in a database;
[0176] The target data overwriting module is configured to be executed in the cache system and overwrite the preset placeholder data with the target data.
[0177] In some possible embodiments, the device further includes:
[0178] A receiving module is configured to execute a target data update instruction received from a client; the target data update instruction includes an account identifier and update data;
[0179] A database determination module is configured to execute database determination;
[0180] A target data updating module is configured to update the target data corresponding to the account identifier based on the update data to obtain updated target data;
[0181] The target data deletion module is configured to delete the target data in the cache system.
[0182] In some possible embodiments, the device further includes:
[0183] A receiving module is configured to execute and receive a data request from a client; the data request includes an account identifier;
[0184] The target data acquisition module is configured to execute that the data corresponding to the account identifier obtained from the cache system is a null value; the data corresponding to the account identifier obtained from the database is the updated target data;
[0185] A target data storage module is configured to store the updated target data as data corresponding to the account identifier in the cache system;
[0186] The sending module is configured to feed back the updated target data to the client.
[0187] In some possible embodiments, the target data coverage module is configured to execute:
[0188] Sending a data overwrite instruction to the cache system; the data overwrite instruction includes target data and an account identifier; the data overwrite instruction is used to instruct the cache system to overwrite the preset placeholder data with the target data;
[0189] In the case where the target data fails to overwrite the preset placeholder data, deleting the preset placeholder data in the cache system;
[0190] The data overwrite instruction is stored in the message queue, so that the consumer end corresponding to the message queue sends the data overwrite instruction to the cache system.
[0191] In some possible embodiments, the receiving module is configured to execute receiving a data request; the data request includes an account identifier;
[0192] The target data acquisition module is configured to execute that the data corresponding to the account identifier obtained from the cache system is a null value; the data corresponding to the account identifier obtained from the database is the target data.
[0193] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0194] Figure 88 is a block diagram of a data processing apparatus 800 according to an exemplary embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0195] Reference Figure 8 , the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0196] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0197] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0198] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0199] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0200] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0201] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0202] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0203] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0204] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.
[0205] In an exemplary embodiment, a storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
Claims
1. A data processing method, characterized in that: include: Receive data requests from clients; The data request includes an account identification; Determine a cache system corresponding to the business to which the data request belongs; The business is one of multiple businesses corresponding to the cache system; If the data obtained from the cache system based on the account identifier is a null value, determining a database corresponding to the business; If the data obtained from the database based on the account identifier is a null value, creating the account identifier and preset placeholder data corresponding to the account identifier in the cache system; The preset placeholder data is sent to the client.
2. The data processing method according to claim 1, characterized in that: After sending the preset placeholder data to the client, the method further includes: receiving the data request; the data request including the account identifier; Determine the cache system corresponding to the business to which the data request belongs; Acquire the preset placeholder data from the cache system based on the account identifier; The preset placeholder data is sent to the client.
3. The data processing method according to any one of claims 1-2, characterized in that: The method further comprises: Receiving a target data creation instruction from the client; the target data creation instruction includes the account identifier; Determine the database corresponding to the business to which the target data creation instruction belongs; Creating the account identifier and target data corresponding to the account identifier in the database; In the cache system, the preset placeholder data is overwritten with the target data.
4. The data processing method according to claim 3, characterized in that: The method further comprises: Receiving a target data update instruction from the client; the target data update instruction includes the account identifier and update data; determining the database; updating the target data corresponding to the account identifier based on the update data to obtain updated target data; The target data in the cache system is deleted.
5. The data processing method according to claim 4, characterized in that: After deleting the target data in the cache system, the method further includes: receiving the data request from the client; the data request including an account identifier; The data corresponding to the account identifier obtained from the cache system is a null value; The data corresponding to the account identifier obtained from the database is the updated target data; storing the updated target data as data corresponding to the account identifier in the cache system; The updated target data is fed back to the client.
6. The data processing method according to claim 3, characterized in that: In the cache system, using the target data to overwrite the preset placeholder data includes: Sending a data overwriting instruction to the cache system; the data overwriting instruction includes the target data and the account identifier; the data overwriting instruction is used to instruct the cache system to overwrite the preset placeholder data with the target data; In the case where the target data fails to overwrite the preset placeholder data, deleting the preset placeholder data in the cache system; The data overwriting instruction is stored in a message queue, so that the consumer end corresponding to the message queue sends the data overwriting instruction to the cache system.
7. The data processing method according to claim 6, characterized in that: After deleting the preset placeholder data in the cache system, the method further includes: receiving the data request; the data request including the account identifier; The data corresponding to the account identifier obtained from the cache system is a null value; The data corresponding to the account identification obtained from the database is the target data.
8. A data processing device, characterized in that: include: A receiving module, configured to execute and receive a data request from a client; The data request includes an account identification; A cache system determination module, configured to determine a cache system corresponding to the service to which the data request belongs; the service is one of multiple services corresponding to the cache system; a database determination module, configured to determine a database corresponding to the business if the data obtained from the cache system based on the account identifier is a null value; A placeholder data creation module is configured to execute, if the data obtained from the database based on the account identifier is a null value, creating the account identifier and preset placeholder data corresponding to the account identifier in the cache system; The sending module is configured to send the preset placeholder data to the client.
9. The data processing device according to claim 8, characterized in that: The device also includes: The receiving module is configured to receive the data request; the data request includes the account identifier; The cache system determination module is configured to determine the cache system corresponding to the business to which the data request belongs; A placeholder data acquisition module, configured to acquire the preset placeholder data from the cache system; The sending module is configured to send the preset placeholder data to the client.
10. The data processing device according to any one of claims 8 to 9, characterized in that: The device also includes: The receiving module is configured to execute and receive a target data creation instruction from the client; the target data creation instruction includes the account identifier; The database determination module is configured to determine the database corresponding to the business to which the target data creation instruction belongs; A target data creation module, configured to create the account identifier and target data corresponding to the account identifier in the database; The target data overwriting module is configured to be executed in the cache system and overwrite the preset placeholder data with the target data.
11. The data processing device according to claim 10, characterized in that: The device also includes: The receiving module is configured to execute and receive a target data update instruction from the client; the target data update instruction includes the account identifier and update data; The database determination module is configured to determine the database; a target data updating module, configured to update the target data corresponding to the account identifier based on the update data to obtain updated target data; The target data deletion module is configured to delete the target data in the cache system.
12. The data processing device according to claim 11, characterized in that: The device also includes: The receiving module is configured to execute receiving the data request from the client; the data request includes an account identifier; The target data acquisition module is configured to execute that the data corresponding to the account identifier obtained from the cache system is a null value; the data corresponding to the account identifier obtained from the database is the updated target data; A target data storage module is configured to store the updated target data as data corresponding to the account identifier in the cache system; The sending module is configured to feed back the updated target data to the client.
13. The data processing device according to claim 10, characterized in that: The target data coverage module is configured to execute: Sending a data overwriting instruction to the cache system; the data overwriting instruction includes the target data and the account identifier; the data overwriting instruction is used to instruct the cache system to overwrite the preset placeholder data with the target data; In the case where the target data fails to overwrite the preset placeholder data, deleting the preset placeholder data in the cache system; The data overwriting instruction is stored in a message queue, so that the consumer end corresponding to the message queue sends the data overwriting instruction to the cache system.
14. The data processing device according to claim 13, characterized in that: The receiving module is configured to receive the data request; the data request includes the account identifier; The target data acquisition module is configured to execute that the data corresponding to the account identifier obtained from the cache system is a null value; and the data corresponding to the account identifier obtained from the database is the target data.
15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the data processing method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data processing method according to any one of claims 1 to 7.
17. A computer program product, characterized in that The computer program product comprises a computer program, which is stored in a readable storage medium. At least one processor of a computer device reads and executes the computer program from the readable storage medium, so that the computer device performs the data processing method according to any one of claims 1 to 7.
