Business data processing system, method, device and storage medium based on double buffering
By adopting a dual -cache business data processing system in the government system, the problem of low efficiency in massive data processing is solved, and rapid response and efficient inquiries are realized to ensure the stable operation of the system.
Patent Information
- Application Number
- CN202210145388.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-17
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2042-02-17
AI Technical Summary
When processing massive business data, the existing technology cannot meet the needs of efficient query and response, resulting in inefficient system operation and potential crashes.
Adopt a business data processing system based on dual cache, through setting up a cache module layer between microservices and databases, storing hot data, and using dual cache mechanisms for data query and storage to achieve rapid response and efficient inquiries.
Under the premise of ensuring the accuracy of data, the system's query efficiency and response speed significantly improved the system's query efficiency and response speed, which can meet the needs of massive business data and avoid system collapse.
Smart Images

Figure CN114722077B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the processing of business data, and in particular to a business data processing system, method, device and storage medium based on double buffering. Background Art
[0002] For government systems, in order to ensure the accuracy of data, two most robust methods are usually selected to store and transmit business data: one is that all business data is directly obtained from the database, and it is queried and returned from the database in real time regardless of the amount of data; the other is to transmit the data of system operation in a serial manner, and each piece of data is transmitted in sequence. Although the security of obtaining data from the database is higher, and the serial operation system can also ensure that business data will not be contaminated by each other, etc., with the increase in the complexity of business data and the increase in the amount of data in the database, any of the above methods will consume a lot of time, seriously affecting the operating efficiency of the system, and may even cause the system to crash, which is not conducive to use. Summary of the invention
[0003] In order to overcome the deficiencies of the prior art, one of the objectives of the present invention is to provide a business data processing system based on double buffering, which can solve the problem that the prior business data processing cannot meet the demand for massive data.
[0004] A second objective of the present invention is to provide a business data processing method based on double buffering, which can solve the problem that existing business data processing cannot meet the needs of massive data.
[0005] A third objective of the present invention is to provide a business data processing device based on double buffering, which can solve the problem that existing business data processing cannot meet the needs of massive data.
[0006] A fourth object of the present invention is to provide a storage medium that can solve the problem that existing business data processing cannot meet the needs of massive data.
[0007] One of the purposes of the present invention is achieved by the following technical solution:
[0008] The business data processing system based on double buffering includes:
[0009] Database, used to store all business data of the system;
[0010] Cache module, including memory cache module and database cache module;
[0011] The microservice module is used to receive a data query instruction and query the required data from the cache module according to the data query instruction, and:
[0012] When the required business data exists in the cache module, the required business data is obtained from the cache module and fed back to the user;
[0013] When the required business data does not exist in the cache module, the required business data is obtained from the database, and the obtained business data is fed back to the user. At the same time, the obtained business data is stored in the corresponding cache module according to the different business data.
[0014] Furthermore, when the required business data is first business data, the microservice module is further used to:
[0015] When the first business data exists in the memory cache module and the first business data in the memory cache module is available, acquiring the first business data from the memory cache module;
[0016] When the first business data does not exist in the memory cache module or the first business data existing in the memory cache module is unavailable, querying the first business data from a database cache module;
[0017] And, when the first business data exists in the database cache module and the first business data in the database cache module is available, the first business data is obtained from the database cache module and the obtained first business data is stored in the memory cache module and a new timestamp is set;
[0018] When the first business data does not exist in the database cache module or the first business data in the database cache module is unavailable, obtaining the first business data from the database and storing the obtained first business data in the memory cache module and the database cache module at the same time and setting new timestamps for each;
[0019] When the required business data is the second business data, the microservice module is also used to: determine whether the database cache module has the second business data, and when the database cache module has the second business data, obtain the second business data from the database cache module; when the second business data does not exist in the database cache module, obtain the second business data from the database and store the second business data in the database cache module.
[0020] Furthermore, the microservice module is also used to generate one or more sub-query instructions according to the data query instruction, and call the corresponding thread according to each sub-query instruction to obtain the corresponding sub-business data from the cache module or other microservice modules, and process and assemble all the sub-business data obtained by the query to obtain the required business data.
[0021] Furthermore, the microservice module is also used to store the modified business data in the database and delete the corresponding business data in the cache module when the business data in the cache module needs to be modified.
[0022] The second object of the present invention is achieved by adopting the following technical solution:
[0023] A service data processing method based on double buffering is applied to a service data processing system based on double buffering as one of the purposes of the present invention, comprising:
[0024] Instruction acquisition step: obtain data query instructions;
[0025] Cache query step: query the memory cache module and / or the database cache module according to the data query instruction to determine whether the memory cache module and / or the database cache module has the required business data, if so, execute the cache module query step; if not, execute the database query step;
[0026] Cache module query step: obtaining the required business data from the memory cache module or the database cache module and executing the feedback step;
[0027] Database query step: query the required business data from the database, execute the feedback step, and store the queried business data in the corresponding cache module;
[0028] Feedback step: Feedback the required business data obtained from the query to the user.
[0029] Furthermore, when the required business data is first business data, the cache query step specifically includes:
[0030] Memory cache query step: determine whether the memory cache module has the first business data, if not, execute the database query step; if yes, execute the timestamp determination step;
[0031] Timestamp determination step: determining whether the first business data in the memory cache module is available, if so, obtaining the first business data from the memory cache module; if not, executing a database cache query step;
[0032] Database cache query step: when the first business data exists in the database cache module and the first business data in the database cache module is available, the first business data is obtained from the database cache module and the first business data is stored in the memory cache module and a new timestamp is set; when the first business data does not exist in the database cache module or the first business data in the database cache module is unavailable, the database query step is executed;
[0033] Wherein, the database query step further includes: acquiring the first business data from the database and storing the acquired first business data in the memory cache module and the database cache module and setting new timestamps respectively;
[0034] When the required business data is the second business data, the cache query step also includes: determining whether the second business data exists in the database cache module, and if so, obtaining the second business data from the database cache module; if not, executing the database query step; the database query step also includes: obtaining the second business data from the database and storing the second business data in the database cache module.
[0035] Furthermore, the instruction acquisition step also includes: splitting the data query instruction to generate one or more sub-data query instructions, and executing the cache query step and / or database query step according to each sub-data query instruction to obtain the corresponding sub-business data or obtain the corresponding sub-business data from other microservice modules; the feedback step is also used to process and assemble all the queried sub-business data to obtain the required business data and feed it back to the user.
[0036] Furthermore, it also includes: a data updating step: when there is business data that needs to be modified, the business data is modified, and the modified business data is stored in the database, and the corresponding business data in the cache module is deleted.
[0037] The third object of the present invention is achieved by adopting the following technical solution:
[0038] A business data processing device based on double buffering includes a memory and a processor, wherein the memory stores a business data processing program running on the processor, and the business data processing program is a computer program. When the processor executes the business data processing program, the steps of the business data processing method based on double buffering as adopted in the second purpose of the present invention are implemented.
[0039] The fourth object of the present invention is achieved by adopting the following technical solution:
[0040] A storage medium is a computer-readable storage medium on which a computer program is stored. The computer program is a business data processing program. When the business data processing program is executed by a processor, the steps of the business data processing method based on double buffering adopted in the second purpose of the present invention are implemented.
[0041] Compared with the prior art, the present invention has the following beneficial effects:
[0042] The present invention sets a cache module layer between the microservice module and the database to store hot data. On the premise of ensuring the accuracy of massive data, the present invention realizes the rapid response of the microservice module and meets the needs of massive business data. At the same time, the present invention adopts a double cache mechanism to realize the temporary storage of business data of different data volumes, and improves the query efficiency of the system on the premise of ensuring data accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A module diagram of a business data processing system based on double buffering provided by the present invention;
[0044] Figure 2 A flow chart of data acquisition between different microservice modules in the business data processing system based on double buffering provided by the present invention;
[0045] Figure 3 A flow chart of a business data processing method based on double buffering provided by the present invention;
[0046] Figure 4 for Figure 3 One of the flowcharts of step S3 in;
[0047] Figure 5 for Figure 3 Flow chart 2 of step S3 in . DETAILED DESCRIPTION
[0048] The present invention is further described below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that, under the premise of no conflict, the various embodiments or technical features described below can be arbitrarily combined to form a new embodiment.
[0049] Embodiment 1
[0050] The present invention provides a business data processing system based on double buffering, which can respond instantly in massive business data while ensuring data accuracy, and can quickly return required business data to meet the needs of massive business data.
[0051] The present invention provides a preferred embodiment, a business data processing system based on double buffering, such as Figure 1 As shown, it includes three parts: microservice module, cache module and database.
[0052] Among them, the microservice module is the data processing center of the entire system. All business data is processed by the microservice module and fed back to users.
[0053] The cache module and database in the present invention are both used to store data. Among them, the business data stored in the cache module is stored in the memory in the form of key-value pairs, and the business data stored therein is hot data and is temporary. The business data stored in the database is stored in the disk, and the business data stored therein is all the business data of the system and is persistent. The present invention temporarily stores the hot data in the cache module to facilitate the rapid response of the hot business data, and stores all the business data in the database to ensure the integrity and accuracy of the data. The present invention adds a cache module layer between the microservice module and the database, so that each time the microservice module receives a query instruction from the user, the microservice module will first obtain it from the cache module; when the data does not exist in the cache module, it is obtained from the database, and the queried data is stored in the cache module, so that the subsequent query of the same data can be quickly obtained from the cache module.
[0054] More preferably, the cache module in the present invention includes a memory cache module and a database cache module, wherein the memory cache module refers to a memory-based local cache, which is implemented by storing the local cache in the JVM (Java Virtual Machine) and does not require additional deployment, such as Ehcache cache (a widely used open source Java distributed cache) and Memcache cache (a distributed high-speed cache system); the database cache module refers to a memory-based database that needs to be additionally deployed on the server, such as Redis cache, which is an open source log-type, Key-Value database written in ANSI C language, supporting the network, memory-based and persistent, and providing APIs in multiple languages.
[0055] The present invention uses a double cache mechanism to store hot business data, providing fast data support for the microservice module. The present invention uses double cache instead of directly querying the database, wherein the Ehcache cache is a memory cache, and its reading efficiency is very high, but only using the memory cache module may cause insufficient memory; and the Redis cache is a key-value database. If only Redis is used for caching, there is a problem of frequent network IO reading and writing. Therefore, the use of double cache can effectively make up for the defects of both parties, solve the problem of consistency of cache module and database data and quickly return business data, that is, it can still respond instantly while ensuring data accuracy in massive business data, and quickly return the required business data.
[0056] Preferably, in order to ensure the accuracy and timeliness of the queried business data, the present invention adopts different query cache processing methods for business data of different data volumes, which can be specifically divided into the following two cases:
[0057] For large amounts of business data, the memory cache module is used first when querying. That is, when querying data, the memory cache module is queried first to determine whether there is corresponding business data in the memory cache module. If so, the timestamps in the memory cache module and the database cache module are determined to determine whether the business data in the memory cache module is available. If so, the business data is directly taken out from the memory cache module; otherwise, if there is no corresponding business data in the memory cache module, or if the business data in the memory cache module is unavailable according to the timestamps in the memory cache module and the database cache module, the corresponding business data is queried from the database or the corresponding business data is obtained from the database cache module, and then the obtained business data is re-stored in the memory cache module and the database cache module, and the same new timestamp is set in the memory cache module and the database cache module respectively.
[0058] For small-volume business data, only the database cache module is used during query. That is, when querying data, the database cache module is directly queried to see if the corresponding business data exists. If so, the corresponding business data is directly retrieved from the database cache module; if not, the corresponding business data is retrieved from the database and stored in the database cache.
[0059] In addition, the data volume of business data can be set according to actual usage requirements, such as by setting a preset value in the system. When the data volume of the queried business data exceeds a certain preset value, the business data is considered to be large-volume business data.
[0060] Since the memory cache module is a local cache module based on JVM memory, its data acquisition speed is very fast. However, the size of JVM memory is set when the JAVA program is started. If the memory cache module occupies a large amount of JVM memory, it will cause the entire JAVA program to freeze. In other words, when the business data in the memory cache module increases, the performance of JVM memory will decrease.
[0061] Obviously, for large amounts of business data, the performance of the memory cache module is better than that of the database cache module, and the memory cache module is used preferentially. At the same time, in order to avoid the problem of memory overflow, a reasonable expiration time is set for the business data when storing the business data (that is, the business data of the memory cache module will be automatically released in memory after a certain period of time) so as to achieve the best in space and time; and for small amounts of business data, since the performance loss is not large, only the database cache module can be used, and the memory cache module is not needed. In addition, for large amounts of business data, the present invention sets a timestamp to judge the validity of the business data. Since the memory cache module is a local cache based on JVM, when a large amount of business data is stored in the memory cache module, it may fail, resulting in the memory cache module storing old data and causing data inconsistency. Therefore, the present invention can ensure the accuracy of the data by setting a timestamp. Specifically, the data inconsistency problem pointed out in the present invention is mainly reflected in the case of multi-server deployment. The memory cache modules used by different servers are all implemented based on the local cache of the local JVM memory, that is, the memory cache modules between the servers do not interfere with each other; and the cache data of the database cache module is shared, so there may be data inconsistency problems between the database cache module and the memory cache modules of each server. Therefore, the present invention can efficiently solve the problem of data inconsistency by using timestamps. Specifically, assuming that there are existing servers A and B, and a database cache module C, under load balancing, user 1 uses server A and stores business data in A's memory cache module and database cache module C, and stores a timestamp; then user 2 uses server B and also uses the same business and updates the business data. At this time, the new business data will be stored in server B's memory cache module and database cache module C, and store a new timestamp; when user 1 uses server A again, the system will compare the timestamp of the memory cache module in server A with the timestamp in database cache module C, and find that the timestamp of the memory cache module in server A is smaller, that is, the business data in the memory cache module in server A is invalid, then the business data in the memory cache module is discarded, and the cache data in the database cache module is used, and the cache data in the memory cache module in server A is reset.
[0062] Preferably, in order to ensure the timeliness of data query, the microservice module in the present invention may also be provided with multiple. For each microservice module, when a data query instruction is received, a parallel processing method can be used to implement data query. That is, the microservice module can use multiple sub-threads to implement data query at the same time. By using the thread pool to simultaneously enable the function of obtaining its own query data and the function of obtaining the data queried by other microservice modules, and then using the concurrent toolkit to monitor the completion of each sub-thread, and finally notifying the main thread that all data has been acquired, all the obtained data is processed and assembled and fed back to the user. Among them, when parallel processing is adopted, the data acquired by each thread lock is unrelated, and the operation of a sub-thread in the thread pool will not affect the operation of other sub-threads. Preferably, after acquiring the data, the acquired data is generally assembled using the ParallelStream parallel stream to replace the one-by-one traversal method.
[0063] In the process of using parallel processing, all collection classes (such as Map, List) are replaced by concurrent safe collection classes such as ConcurrentHashMap and ConcurrentLinkedQueue, because ordinary collection classes are prone to array out-of-bounds, dead loops and other problems in multi-threaded concurrency. The use of concurrent safe collection classes can avoid these problems. The present invention uses a multi-threaded parallel solution to replace the existing serial processing data, which significantly improves the response speed of the interface. At the same time, through the special processing of data and the use of a concurrent toolkit, the concurrent safety problems caused by multi-threading are eliminated, the accuracy of the data is guaranteed, and the system runs safely and stably.
[0064] Preferably, after obtaining the data query instruction, the microservice module can split it into multiple sub-query instructions, and call the corresponding thread according to each sub-query instruction to obtain the corresponding sub-business data from the cache module or other microservice modules, and then process and assemble all the queried sub-business data to obtain the final required business data. Specifically, Figure 2 As shown, when performing data query, microservice module one can obtain data from the cache module, as well as from other microservice modules two and three.
[0065] Preferably, when the present invention uses double buffering, it is easy to have problems such as data inconsistency and dirty buffer modules, which will cause the system to lose data accuracy. Therefore, every time the business data is changed in the system, while the business data is stored in the database, the corresponding business data in the two buffer modules need to be deleted according to the buffer index to avoid the inconsistency between the new and old data. For example, when business data 1 is stored in the buffer module, and the system needs to change the business data 1 and store it in the database, if the business data 1 in the buffer module is not deleted, the problem of inconsistency between the business data 1 in the buffer module and the business data 1 in the database will occur.
[0066] In addition, after obtaining business data from the cache module, if the business data in the cache module needs to be modified, first make a deep copy of the business data in the cache module before modifying it to prevent the problem of dirty cache modules. For example, for the memory cache module, the Ehcache cache strategy is shallow copy. Modifying the data in the Ehcache cache will affect the value in the cache. Using a deep copy can prevent the generation of dirty cache.
[0067] Embodiment 2
[0068] Based on the first embodiment, the present invention provides a business data processing method based on double buffering, such as Figure 3 As shown, the following steps are included:
[0069] Step S1, obtaining a data query instruction. The microservice module obtains the data query instruction sent by the user, so that the microservice module implements data query according to the data query instruction.
[0070] Step S2: query the memory cache module and / or the database cache module according to the data query instruction to determine whether the required business data exists in the cache module. If so, execute step S3; if not, execute step S4.
[0071] When you need to query data, first query the cache module to see if the required business data exists. If so, directly obtain the business data from the cache module to achieve a fast data response; if not, query the business data from the database. Since the cache module stores part of the business data, and the database stores all the business data, when the corresponding business data does not exist in the cache module, it can be queried from the database.
[0072] Step S3: Obtain required business data from the memory cache module or the database cache module, and execute step S6.
[0073] When there is business data in the cache module, the corresponding business data can be directly obtained from the cache module.
[0074] Step S4: Query the required business data from the database, execute step S6, and execute step S5 at the same time.
[0075] Step S5: store the queried business data in the corresponding cache module according to the different business data. When the business data does not exist in the cache module, query the business data from the database, and store the queried business data in the corresponding cache module synchronously, so that the business data can be directly obtained from the cache module when it is queried again in the future, so as to achieve a quick response.
[0076] Step S6: Feedback the required business data found to the user.
[0077] Preferably, since different business data have different data volumes and use different cache modules, when the required business data is the first business data, the first business data referred to in this application refers to the aforementioned business data with a large data volume. For example, when the data volume of the first business data exceeds a preset value, the data can be considered to be business data with a large data volume; Figure 4 As shown, step S3 also includes:
[0078] Step S311, determine whether the memory cache module has the first business data, if not, execute step S317; if yes, execute step S312. For large amounts of business data, the memory cache module is used first, so first determine whether the memory cache module has the first business data.
[0079] Step S312, determine whether the first business data in the memory cache module is available, if so, execute step S313; if not, execute step S314.
[0080] Specifically, the availability of the first business data in the memory cache module can be determined by obtaining the timestamp of the first business data stored in the memory cache module and the database cache module. For example, in an example provided by the present invention, for multiple servers, when the timestamp in the memory cache module of the local server is less than the timestamp in the database cache module, the data in the memory cache module is considered invalid. In addition, the determination of whether the first business data in the memory cache module is available is not limited to the determination of the size of the timestamp as indicated in the present application, and the determination is made according to actual needs.
[0081] Step S313: Obtain the first business data from the memory cache module, and then execute step S318.
[0082] Step S314: When the first business data exists in the database cache module and the first business data is available, execute step S316.
[0083] Step S315: When the database cache module does not have the first business data or the existing first business data is unavailable, execute step S317.
[0084] Step S316: Acquire the first business data from the database cache module, store the acquired first business data in the memory cache module and set a new timestamp, and execute step S318.
[0085] Step S317: Acquire the first business data from the database, and re-store the first business data in the memory cache module and the database cache module and set new timestamps for each module, and then execute step S318.
[0086] Step S318: Feedback the first service data to the user.
[0087] Preferably, when the required business data is the second business data, the second business data of the present application refers to the aforementioned business data of small data volume, for example, the data volume of the business data to be queried does not exceed a preset value; Figure 5 As shown, step S3 also includes:
[0088] Step S321, determine whether the second business data exists in the database cache module, if yes, proceed to step S322; if no, proceed to step S323. For small-volume business data, only the database cache module is used, so when querying data in the cache module, it can be directly searched from the database cache module.
[0089] Step S322: Obtain the second business data from the database cache module, and then execute step S325.
[0090] Step S323: Obtain the second business data from the database, and then execute steps S324 and S325.
[0091] Step S324: store the second business data in the database cache module.
[0092] Step S325: Feedback the second service data to the user.
[0093] Preferably, step S1 also includes: splitting the acquired data query instruction to generate one or more sub-data query instructions, and executing steps S2, S3, S4 and S5 according to each sub-data query instruction to obtain the corresponding sub-business data or obtain the corresponding sub-business data from other microservice modules.
[0094] Correspondingly, step S6 also includes processing and assembling all the sub-service data found to obtain the required service data and feeding it back to the user. That is, the sub-service data found by each sub-thread is processed and assembled to obtain the final service data.
[0095] Preferably, the present invention further comprises: a data updating step: when there is business data that needs to be modified, the business data is modified, and the modified business data is stored in the database, and the corresponding business data in the cache module is deleted. That is, when the business data is modified, the modified business data is stored in the database, and the business data in the cache module needs to be deleted to avoid inconsistency between new and old data.
[0096] Embodiment 3
[0097] Based on the second embodiment, the present invention also provides a business data processing device based on double buffering, which includes a memory and a processor, wherein the memory stores a business data processing program running on the processor, and the business data processing program is a computer program. When the processor executes the business data processing program, the following steps are implemented:
[0098] Instruction acquisition step: obtain data query instructions;
[0099] Cache query step: query the memory cache module and / or the database cache module according to the data query instruction to determine whether the memory cache module and / or the database cache module has the required business data, if so, execute the cache module query step; if not, execute the database query step;
[0100] Cache module query step: obtaining the required business data from the memory cache module or the database cache module and executing the feedback step;
[0101] Database query step: query the required business data from the database, execute the feedback step, and store the queried business data in the corresponding cache module;
[0102] Feedback step: Feedback the required business data obtained from the query to the user.
[0103] Furthermore, when the required business data is first business data, the cache query step specifically includes:
[0104] Memory cache query step: determine whether the memory cache module has the first business data, if not, execute the database query step; if yes, execute the timestamp determination step;
[0105] Timestamp determination step: determining whether the first business data in the memory cache module is available, if so, obtaining the first business data from the memory cache module; if not, executing a database cache query step;
[0106] Database cache query step: when the first business data exists in the database cache module and the first business data in the database cache module is available, the first business data is obtained from the database cache module and the first business data is stored in the memory cache module and a new timestamp is set; when the first business data does not exist in the database cache module or the first business data in the database cache module is unavailable, the database query step is executed;
[0107] Wherein, the database query step further includes: acquiring the first business data from the database and storing the acquired first business data in the memory cache module and the database cache module and setting new timestamps respectively;
[0108] When the required business data is the second business data, the cache query step also includes: determining whether the second business data exists in the database cache module, and if so, obtaining the second business data from the database cache module; if not, executing the database query step; the database query step also includes: obtaining the second business data from the database and storing the second business data in the database cache module.
[0109] Furthermore, the instruction acquisition step also includes: splitting the data query instruction to generate one or more sub-data query instructions, and executing the cache query step and / or database query step according to each sub-data query instruction to obtain the corresponding sub-business data or obtain the corresponding sub-business data from other microservice modules; the feedback step is also used to process and assemble all the queried sub-business data to obtain the required business data and feed it back to the user.
[0110] Furthermore, it also includes: a data updating step: when there is business data that needs to be modified, the business data is modified, and the modified business data is stored in the database, and the corresponding business data in the cache module is deleted.
[0111] Embodiment 4
[0112] Based on the second embodiment, the present invention also provides another embodiment, a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and the computer program is a business data processing program. When the business data processing program is executed by a processor, the following steps are implemented:
[0113] Instruction acquisition step: obtain data query instructions;
[0114] Cache query step: query the memory cache module and / or the database cache module according to the data query instruction to determine whether the memory cache module and / or the database cache module has the required business data. If so, execute the cache module query step; if not, execute the database query step;
[0115] Cache module query step: obtaining the required business data from the memory cache module or the database cache module and executing the feedback step;
[0116] Database query step: query the required business data from the database, execute the feedback step, and store the queried business data in the corresponding cache module;
[0117] Feedback step: Feedback the required business data obtained from the query to the user.
[0118] Furthermore, when the required business data is first business data, the cache query step specifically includes:
[0119] Memory cache query step: determine whether the memory cache module has the first business data, if not, execute the database query step; if yes, execute the timestamp determination step;
[0120] Timestamp determination step: determining whether the first business data in the memory cache module is available, if so, obtaining the first business data from the memory cache module; if not, executing a database cache query step;
[0121] Database cache query step: when the first business data exists in the database cache module and the first business data in the database cache module is available, the first business data is obtained from the database cache module and the first business data is stored in the memory cache module and a new timestamp is set; when the first business data does not exist in the database cache module or the first business data in the database cache module is unavailable, the database query step is executed;
[0122] Wherein, the database query step further includes: acquiring the first business data from the database and storing the acquired first business data in the memory cache module and the database cache module and setting new timestamps respectively;
[0123] When the required business data is the second business data, the cache query step also includes: determining whether the second business data exists in the database cache module, and if so, obtaining the second business data from the database cache module; if not, executing the database query step; the database query step also includes: obtaining the second business data from the database and storing the second business data in the database cache module.
[0124] Furthermore, the instruction acquisition step also includes: splitting the data query instruction to generate one or more sub-data query instructions, and executing the cache query step and / or database query step according to each sub-data query instruction to obtain the corresponding sub-business data or obtain the corresponding sub-business data from other microservice modules; the feedback step is also used to process and assemble all the queried sub-business data to obtain the required business data and feed it back to the user.
[0125] Furthermore, it also includes: a data updating step: when there is business data that needs to be modified, the business data is modified, and the modified business data is stored in the database, and the corresponding business data in the cache module is deleted.
[0126] The above-mentioned embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and substitutions made by technicians in this field on the basis of the present invention shall fall within the scope of protection required by the present invention.
Claims
1. A business data processing system based on double buffering, characterized in that: include: Database, used to store all business data of the system; Cache module, including memory cache module and database cache module; The microservice module is used to receive a data query instruction and query the required data from the cache module according to the data query instruction, and: When the required business data exists in the cache module, the required business data is obtained from the cache module and fed back to the user; When the required business data does not exist in the cache module, the required business data is obtained from the database and fed back to the user. At the same time, the obtained business data is stored in the corresponding cache module according to different data sizes.
2. The business data processing system based on double buffering according to claim 1, characterized in that: When the required business data is the first business data, the microservice module is further used to: When the first business data exists in the memory cache module and the first business data in the memory cache module is available, acquiring the first business data from the memory cache module; When the first business data does not exist in the memory cache module or the first business data existing in the memory cache module is unavailable, querying the first business data from a database cache module; And, when the first business data exists in the database cache module and the first business data in the database cache module is available, the first business data is obtained from the database cache module and the obtained first business data is stored in the memory cache module and a new timestamp is set; When the first business data does not exist in the database cache module or the first business data in the database cache module is unavailable, obtaining the first business data from the database and storing the obtained first business data in the memory cache module and the database cache module at the same time and setting new timestamps for each; When the required business data is the second business data, the microservice module is also used to: determine whether the database cache module has the second business data, and when the database cache module has the second business data, obtain the second business data from the database cache module; when the second business data does not exist in the database cache module, obtain the second business data from the database and store the second business data in the database cache module.
3. The business data processing system based on double buffering according to claim 1, characterized in that: The microservice module is also used to generate one or more sub-query instructions according to the data query instruction, and call the corresponding thread according to each sub-query instruction to obtain the corresponding sub-business data from the cache module or other microservice modules, and process and assemble all the sub-business data obtained by the query to obtain the required business data.
4. The business data processing system based on double buffering according to claim 1, characterized in that: The microservice module is also used to store the modified business data in the database and delete the corresponding business data in the cache module when the business data in the cache module needs to be modified.
5. A method for processing business data based on double buffering, applied to a business data processing system based on double buffering as claimed in any one of claims 1 to 4, characterized in that: include: Instruction acquisition step: obtain data query instructions; Cache query step: query the memory cache module and / or the database cache module according to the data query instruction to determine whether the memory cache module and / or the database cache module has the required business data. If so, obtain the required business data from the memory cache module or the database cache module and execute the feedback step; if not, execute the database query step; Database query step: query the required business data from the database, execute the feedback step, and store the queried business data in the corresponding cache module; Feedback step: Feedback the required business data obtained from the query to the user.
6. The service data processing method based on double buffering according to claim 5, characterized in that: When the required business data is the first business data, the cache query step specifically includes: Memory cache query step: determine whether the memory cache module has the first business data, if not, execute the database query step; if yes, execute the timestamp determination step; Timestamp determination step: determining whether the first business data in the memory cache module is available, if so, obtaining the first business data from the memory cache module; if not, executing a database cache query step; Database cache query step: when the first business data exists in the database cache module and the first business data in the database cache module is available, the first business data is obtained from the database cache module and the first business data is stored in the memory cache module and a new timestamp is set; when the first business data does not exist in the database cache module or the first business data in the database cache module is unavailable, the database query step is executed; Wherein, the database query step further includes: acquiring the first business data from the database and storing the acquired first business data in the memory cache module and the database cache module and setting new timestamps respectively; When the required business data is the second business data, the cache query step also includes: determining whether the second business data exists in the database cache module, and if so, obtaining the second business data from the database cache module; if not, executing the database query step; the database query step also includes: obtaining the second business data from the database and storing the second business data in the database cache module.
7. The service data processing method based on double buffering according to claim 6 is characterized in that: The instruction acquisition step also includes: splitting the data query instruction to generate one or more sub-data query instructions, and executing the cache query step and / or database query step according to each sub-data query instruction to obtain the corresponding sub-business data or obtain the corresponding sub-business data from other microservice modules; the feedback step is also used to process and assemble all the queried sub-business data to obtain the required business data and feed it back to the user.
8. The service data processing method based on double buffering according to claim 7 is characterized in that: Also includes: Data update step: when there is business data that needs to be modified, the business data is modified, and the modified business data is stored in the database, and the corresponding business data in the cache module is deleted at the same time.
9. A business data processing device based on double buffering, comprising a memory and a processor, wherein the memory stores a business data processing program running on the processor, the business data processing program being a computer program, characterized in that: When the processor executes the service data processing program, the processor implements the steps of the service data processing method based on double buffering as described in any one of claims 5 to 8.
10. A storage medium, which is a computer-readable storage medium, on which a computer program is stored, the computer program being a business data processing program, characterized in that: When the business data processing program is executed by the processor, the steps of the business data processing method based on double buffering as described in any one of claims 5 to 8 are implemented.
Citation Information
Patent Citations
A system and method for avoiding cache avalanche through multi-level caching in micro-service
CN109669960A
Micro-service cross-service data acquisition method and device and micro-service equipment
CN111125170A