Double buffering method, device, equipment and storage medium based on asynchronous decorator

By building an asynchronous decorator in the Tornado framework, the problems of data layer call complexity and low cache efficiency are solved, efficient data acquisition and processing are achieved, and system performance is improved.

CN111444223BActive Publication Date: 2024-12-10CHINA PING AN LIFE INSURANCE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202010164811.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-11
Publication Date
2024-12-10
Estimated Expiration
2040-03-11

AI Technical Summary

Technical Problem

When using the Tornado framework, calling target data from the data layer is complex, the cache efficiency is low, and the caching mechanism corresponding to the task layer is lacking.

Method used

By building an asynchronous decorator at the task layer and the data layer, and using the asynchronous decorator to extract cached data, efficient data acquisition and processing are achieved.

Benefits of technology

Improve cache efficiency, simplify the process of calling target data from the data layer, and improve system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111444223B_ABST
    Figure CN111444223B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of cloud technology, and discloses a double-caching method, device, equipment and storage medium based on an asynchronous decorator, which is used to extract cache data through an asynchronous decorator to improve cache efficiency. The method of the present invention includes: obtaining a data extraction instruction, and generating a target task layer asynchronous decorator according to the data extraction instruction; obtaining a first target data key-value pair according to the target task layer asynchronous decorator and a preset construction rule; obtaining the first target data in a first cache space through the target task layer asynchronous decorator, and judging whether the first target data is a null value through the target task layer asynchronous decorator; if the first target data is a null value, obtaining the second target data in a second cache space, and judging whether the second target data is a null value; if the second target data is a null value, obtaining the target data in a database according to the second target data key-value pair, and sending the target data to a preset terminal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud technology, and in particular to a double-buffer method, device, equipment and storage medium based on an asynchronous decorator. Background Art

[0002] With the development of technology, caching has become a technology widely used in computers to improve performance. In the context of Web applications, caching is used to retain pages or data between HTTP requests and use them multiple times without creating new ones. Its purpose is to save application processing time and resources.

[0003] Tornado is an open source version of a web server and its common tools. Tornado is significantly different from the current mainstream web server frameworks. Tornado is a non-blocking server and is quite fast. Based on Tornado's asynchronous function, Tornado can handle thousands of connections per second, so Tornado is an ideal framework for real-time web services.

[0004] However, the asynchronous call function involves concepts such as asynchrony, coroutines, concurrency, and non-blocking, which increases the requirements for development. In addition, it is extremely troublesome to use the Tornado framework to cache calls from the data layer, and there is not even a corresponding cache at the task layer. The efficiency of caching data through such a caching mechanism is low. Summary of the invention

[0005] The present invention provides a double-caching method, device, equipment and storage medium based on an asynchronous decorator, which is used to build an asynchronous decorator at the task layer and the data layer, extract cache data through the asynchronous decorator, solve the problem of complex calling target data from the data layer, and improve cache efficiency.

[0006] A first aspect of an embodiment of the present invention provides a double-caching method based on an asynchronous decorator, comprising: obtaining a data extraction instruction, and generating a target task layer asynchronous decorator according to the data extraction instruction; obtaining a first target data key-value pair according to the target task layer asynchronous decorator and a preset construction rule, wherein the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction; obtaining first target data in a first cache space through the target task layer asynchronous decorator, and judging whether the first target data is a null value through the target task layer asynchronous decorator, the first target data is data corresponding to the first target data key-value pair; if the first target data is a null value, forwarding the data extraction instruction to a preset data layer to obtain a second target data key-value pair, obtaining second target data in a second cache space, and judging whether the second target data is a null value, the second target data is data corresponding to the second target data key-value pair; if the second target data is a null value, forwarding the second target data key-value pair to a database, obtaining target data in the database according to the second target data key-value pair, and sending the target data to a preset terminal.

[0007] Optionally, in a first implementation method of the first aspect of the embodiment of the present invention, obtaining the data extraction instruction and generating a target task layer asynchronous decorator according to the data extraction instruction includes: constructing a synchronous decorator at the preset task layer according to the data extraction instruction to obtain a task layer synchronous decorator; constructing an asynchronous decorator at the preset task layer based on the task layer synchronous decorator to obtain an initial task layer asynchronous decorator; processing the initial task layer asynchronous decorator through a preset asynchronous module and a preset asynchronous function to obtain a target task layer asynchronous decorator.

[0008] Optionally, in a second implementation method of the first aspect of the embodiment of the present invention, if the first target data is a null value, the data extraction instruction is forwarded to the preset data layer to obtain a second target data key-value pair, the second target data is obtained in the second cache space, and it is determined whether the second target data is a null value, and the second target data is the data corresponding to the second target data key-value pair, including: obtaining the target data layer asynchronous decorator through the data extraction instruction; obtaining the second target data key-value pair through the target data layer asynchronous decorator, the data extraction instruction and the preset construction rules; according to the second target data key-value pair, obtaining the parent class data corresponding to the parent class identifier in the second cache space; according to the second target data key-value pair, obtaining the subclass data corresponding to the subclass identifier in the second cache space; synthesizing the parent class data and the subclass data to obtain the second target data, and determining whether the second target data is a null value through the target data layer asynchronous decorator.

[0009] Optionally, in a third implementation method of the first aspect of the embodiment of the present invention, obtaining the target data layer asynchronous decorator through the data extraction instruction includes: constructing a synchronous decorator in the preset data layer according to the data extraction instruction to obtain a data layer synchronous decorator; constructing an asynchronous decorator based on the data layer synchronous decorator to obtain an initial data layer asynchronous decorator; processing the initial data layer asynchronous decorator through a preset asynchronous module and a preset asynchronous function to obtain a target data layer asynchronous decorator.

[0010] Optionally, in a fourth implementation method of the first aspect of the embodiment of the present invention, if the second target data is a null value, the second target data key-value pair is forwarded to a database, the target data is obtained in the database according to the second target data key-value pair, and the target data is sent to a preset terminal, including: determining the first transition target data in the database through the second target data key-value pair; setting the first transition target data in the second cache space through the target data layer asynchronous decorator to obtain the second transition target data; setting the second target transition data in the first cache space through the target task layer asynchronous decorator to obtain the third transition target data; determining the third transition target data as the target data, and sending the target data to the preset front end.

[0011] Optionally, in a fifth implementation method of the first aspect of the embodiment of the present invention, the first target data key-value pair is obtained according to the target task layer asynchronous decorator and the preset construction rules, the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction, including: according to the target task layer asynchronous decorator and the data extraction instruction, the parent class identifier and the child class identifier are obtained; according to the preset construction rules and the asynchronous decorator, a key-value pair is constructed for the parent class identifier and the child class identifier to obtain the first target data key-value pair.

[0012] Optionally, in a sixth implementation method of the first aspect of the embodiment of the present invention, the first target data is obtained in the first cache space through the target task layer asynchronous decorator, and whether the first target data is a null value is determined through the target task layer asynchronous decorator, and the first target data is the data corresponding to the first target data key-value pair and also includes: if the first target data is not a null value, then the first target data is determined to be the target data, and the target data is sent to the preset front end.

[0013] A second aspect of an embodiment of the present invention provides a double-caching device based on an asynchronous decorator, including: a generating unit, used to obtain a data extraction instruction, and generate a target task layer asynchronous decorator according to the data extraction instruction; a first obtaining unit, used to obtain a first target data key-value pair according to the target task layer asynchronous decorator and a preset construction rule, wherein the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction; a first processing unit, used to obtain the first target data in a first cache space through the target task layer asynchronous decorator, and judge the first target data through the target task layer asynchronous decorator whether it is a null value, the first target data is the data corresponding to the first target data key-value pair; the second processing unit, if the first target data is a null value, is used to forward the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtain the second target data in the second cache space, and judge whether the second target data is a null value, the second target data is the data corresponding to the second target data key-value pair; the second acquisition unit, if the second target data is a null value, is used to forward the second target data key-value pair to the database, obtain the target data in the database according to the second target data key-value pair, and send the target data to the preset terminal.

[0014] Optionally, in a first implementation method of the second aspect of the embodiment of the present invention, the generation unit is specifically used to: construct a synchronous decorator at the preset task layer according to the data extraction instruction to obtain a task layer synchronous decorator; construct an asynchronous decorator at the preset task layer based on the task layer synchronous decorator to obtain an initial task layer asynchronous decorator; process the initial task layer asynchronous decorator through a preset asynchronous module and a preset asynchronous function to obtain a target task layer asynchronous decorator.

[0015] Optionally, in a second implementation method of the second aspect of the embodiment of the present invention, the first processing unit specifically includes: a first acquisition module, used to acquire the target data layer asynchronous decorator through the data extraction instruction; a second acquisition module, used to obtain a second target data key-value pair through the target data layer asynchronous decorator, the data extraction instruction and a preset construction rule; a third acquisition module, used to acquire the parent class data corresponding to the parent class identifier in the second cache space according to the second target data key-value pair; a fourth acquisition module, used to acquire the subclass data corresponding to the subclass identifier in the second cache space according to the second target data key-value pair; a data synthesis and judgment module, used to synthesize the parent class data with the subclass data to obtain second target data, and judge whether the second target data is a null value through the target data layer asynchronous decorator.

[0016] Optionally, in a third implementation method of the second aspect of the embodiment of the present invention, the first acquisition module is specifically used to: construct a synchronous decorator in the preset data layer according to the data extraction instruction to obtain a data layer synchronous decorator; construct an asynchronous decorator based on the data layer synchronous decorator to obtain an initial data layer asynchronous decorator; process the initial data layer asynchronous decorator through a preset asynchronous module and a preset asynchronous function to obtain a target data layer asynchronous decorator.

[0017] Optionally, in a fourth implementation method of the second aspect of the embodiment of the present invention, the second processing unit is specifically used to: determine the first transition target data in the database through the second target data key-value pair; set the first transition target data in the second cache space through the target data layer asynchronous decorator to obtain the second transition target data; set the second target transition data in the first cache space through the target task layer asynchronous decorator to obtain the third transition target data; determine the third transition target data as the target data, and send the target data to the preset front end.

[0018] Optionally, in a fifth implementation method of the second aspect of the embodiment of the present invention, the first acquisition unit is specifically used to: obtain the parent class identifier and the child class identifier according to the target task layer asynchronous decorator and the data extraction instruction; construct a key-value pair of the parent class identifier and the child class identifier according to the preset construction rules and the asynchronous decorator to obtain a first target data key-value pair.

[0019] Optionally, in a sixth implementation manner of the second aspect of the embodiment of the present invention, the first processing unit is further specifically used to: if the first target data is not a null value, determine that the first target data is target data, and send the target data to a preset front end.

[0020] A third aspect of an embodiment of the present invention provides a double-caching device based on an asynchronous decorator, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the double-caching method based on the asynchronous decorator described in any one of the above-mentioned embodiments when executing the computer program.

[0021] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method described in the first aspect above.

[0022] It can be seen from the above technical solutions that the embodiments of the present invention have the following advantages: the present invention provides a double-caching method, device, equipment and storage medium based on an asynchronous decorator, obtains a data extraction instruction, and generates a target task layer asynchronous decorator according to the data extraction instruction; obtains a first target data key-value pair according to the target task layer asynchronous decorator and a preset construction rule, and the first target data key-value pair is composed of a parent class identifier and a child class identifier; obtains the first target data in the first cache space through the target task layer asynchronous decorator, and determines whether the first target data is a null value through the target task layer asynchronous decorator, and the first target data is the data corresponding to the first target data key-value pair; if the first target data is a null value, forwards the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtains the second target data in the second cache space, and determines whether the second target data is a null value, and the second target data is the data corresponding to the second target data key-value pair; if the second target data is a null value, forwards the second target data key-value pair to the database, obtains the target data in the database according to the second target data key-value pair, and sends the target data to the preset terminal. The embodiment of the present invention constructs an asynchronous decorator at the task layer and the data layer, extracts cache data through the asynchronous decorator, solves the problem of complex calling target data from the data layer, and improves cache efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A schematic diagram of an embodiment of a double buffering method based on an asynchronous decorator in the present invention;

[0024] Figure 2 It is a schematic diagram of another embodiment of the double buffering method based on asynchronous decorator in the present invention;

[0025] Figure 3 A schematic diagram of an embodiment of a double buffer device based on an asynchronous decorator in the present invention;

[0026] Figure 4 It is a schematic diagram of another embodiment of the double buffer device based on asynchronous decorator in the present invention;

[0027] Figure 5 A schematic diagram of an embodiment of a double-buffer device based on an asynchronous decorator in the present invention. DETAILED DESCRIPTION

[0028] The present invention provides a double cache method based on asynchronous decorator, which is used to construct asynchronous decorators in task layer and data layer, extract cache data through asynchronous decorators, solve the problem of complex calling target data from data layer, and improve cache efficiency.

[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0030] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar 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 described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0031] See also Figure 1 , an embodiment of the double buffering method based on asynchronous decorator in an embodiment of the present invention includes:

[0032] 101. Obtain data extraction instructions, and generate a target task layer asynchronous decorator according to the data extraction instructions.

[0033] The server obtains the data extraction instruction and generates a target task layer asynchronous decorator according to the data extraction instruction.

[0034] The server extracts instructions based on the data and uses the preset decorator to build a synchronous decorator at the preset task layer to obtain a task layer synchronous decorator. The server builds an asynchronous decorator at the preset task layer based on the task layer synchronous decorator to obtain an initial task layer asynchronous decorator. At this time, the initial task layer asynchronous decorator does not have asynchronous function. The server needs to use the preset asynchronous module and the preset asynchronous function to implement the asynchronous function of the initial task layer asynchronous decorator, and finally obtain the target task layer asynchronous decorator.

[0035] It should be noted that the preset business layer belongs to the upper structure, that is, the logic layer, and can run business logic; in this embodiment, the preset decorator is a decorator decorator in the Python language.

[0036] 102. According to the target task layer asynchronous decorator and preset construction rules, obtain the first target data key-value pair, the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction.

[0037] The server obtains the first target data key-value pair according to the target task layer asynchronous decorator and preset construction rules. The first target data key-value pair consists of a parent class identifier and a child class identifier. The parent class identifier and the child class identifier are extracted according to the data extraction instruction.

[0038] The server obtains the parent class identifier and the subclass identifier according to the target task layer asynchronous decorator and the data extraction instruction, and obtains the first target data key-value pair according to the preset construction rules, the parent class identifier and the subclass identifier. For example, if the data extraction instruction is to obtain an article, the article category is technology, and the author of the article is A, then the server first obtains the parent class identifier as article, the subclass identifier as technology, and the author A through the target task layer asynchronous decorator, then the parent class identifier article and the subclass identifier technology, author A constitute the first target data key-value pair.

[0039] 103. Obtain the first target data in the first cache space through the target task layer asynchronous decorator, and determine whether the first target data is a null value through the target task layer asynchronous decorator, where the first target data is data corresponding to the first target data key-value pair.

[0040] The server obtains the first target data in the first cache space through the target task layer asynchronous decorator, and determines whether the first target data is a null value through the target task layer asynchronous decorator. The first target data is the data corresponding to the first target data key-value pair.

[0041] The server obtains the first target data corresponding to the first target data key-value pair in the first cache space through the target task layer asynchronous decorator, and determines whether the first target data corresponding to the first target data key-value pair is a null value through the target task layer asynchronous decorator. If the first target data is not a null value, the server directly sends the first data as the target data to the preset terminal; if the first target data is a null value, it means that the first target data is not the target data, and it is necessary to re-acquire the target data from other cache spaces and send it to the preset terminal.

[0042] 104. If the first target data is a null value, forward the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtain the second target data in the second cache space, and determine whether the second target data is a null value. The second target data is the data corresponding to the second target data key-value pair.

[0043] If the first target data is a null value, the server forwards the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtains the second target data in the second cache space, and determines whether the second target data is a null value. The second target data is the data corresponding to the second target data key-value pair.

[0044] After the server determines that if the first target data is a null value, the server constructs a second target data key-value pair through the target data layer asynchronous decorator according to the construction rules of the target task layer asynchronous decorator. The second target data key-value pair includes a parent class identifier and a child class identifier. The server obtains the parent class data that matches the parent class identifier in the second cache space according to the parent class flag, and obtains the child class data that matches the child class identifier in the second cache space according to the child class identifier, and synthesizes the parent class data and the child class data to obtain the second target data.

[0045] It should be noted that the difference between the second target data key-value pair constructed by the target data layer asynchronous decorator and the first target data key-value pair constructed by the target task layer asynchronous decorator is that the prefixes are different. For example, the second target data key-value pair with the parent class identified as article, the subclass identified as technology and author A is: dao:article:scienceandtechnology:A, while the first target data key-value pair with the parent class identified as article, the subclass identified as technology and author A is: handler:article:scienceandtechnology:A.

[0046] 105. If the second target data is a null value, forward the second target data key-value pair to a database, obtain the target data in the database according to the second target data key-value pair, and send the target data to a preset terminal.

[0047] If the second target data is a null value, the server forwards the second target data key-value pair to the database, obtains the target data in the database according to the second target data key-value pair, and sends the target data to the preset terminal.

[0048] After judgment by the server, if the second target data is a null value, the server forwards the second target data key-value pair to the database, the server searches for the target data corresponding to the second target key-value pair in the database, extracts the target data into the second cache space first, and after judging that the target data in the second cache space is not a null value, extracts the target data into the first cache space, and after judging that the target data in the first cache space is not a null value, sends the target data to the preset terminal.

[0049] The embodiment of the present invention constructs an asynchronous decorator at the task layer and the data layer, extracts cache data through the asynchronous decorator, solves the problem of complex calling target data from the data layer, and improves cache efficiency.

[0050] See also Figure 2 Another embodiment of the double buffering method based on asynchronous decorator in the embodiment of the present invention includes:

[0051] 201. Construct a synchronization decorator at the preset task layer according to the data extraction instruction to obtain a task layer synchronization decorator.

[0052] The server constructs a synchronization decorator at the preset task layer according to the data extraction instruction to obtain the task layer synchronization decorator.

[0053] It should be noted that the preset business layer belongs to the upper structure, that is, the logic layer, and can run business logic; in this embodiment, the preset decorator is a decorator decorator in the Python language.

[0054] 202. Construct an asynchronous decorator in the preset task layer based on the task layer synchronous decorator to obtain an initial task layer asynchronous decorator.

[0055] The server constructs an asynchronous decorator at the preset task layer based on the task layer synchronous decorator to obtain an initial task layer asynchronous decorator.

[0056] The server builds an asynchronous decorator on the preset task layer based on the task layer synchronous decorator to obtain the initial task layer asynchronous decorator. At this time, the initial task layer asynchronous decorator does not have asynchronous function. The server needs to use preset asynchronous module and preset asynchronous function to implement the asynchronous function of the initial task layer asynchronous decorator, and finally obtain the target task layer asynchronous decorator.

[0057] 203. Process the initial task layer asynchronous decorator through the preset asynchronous module and the preset asynchronous function to obtain the target task layer asynchronous decorator.

[0058] The server processes the initial task layer asynchronous decorator through the preset asynchronous module and the preset asynchronous function to obtain the target task layer asynchronous decorator.

[0059] After obtaining the initial task layer asynchronous decorator, the initial task layer asynchronous decorator does not have asynchronous functionality, that is, it cannot process the second event while processing the first event. Therefore, the server needs to process the initial task layer asynchronous decorator through the preset asynchronous module and the preset asynchronous function to obtain the target task layer asynchronous decorator. At this time, the target task layer asynchronous decorator has asynchronous functionality and can process the second event while processing the first event.

[0060] 204. According to the target task layer asynchronous decorator and preset construction rules, obtain a first target data key-value pair, the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction.

[0061] The server obtains the first target data key-value pair according to the target task layer asynchronous decorator and preset construction rules. The first target data key-value pair consists of a parent class identifier and a child class identifier. The parent class identifier and the child class identifier are extracted according to the data extraction instruction.

[0062] Specifically, the server obtains the parent class identifier and the child class identifier according to the target task layer asynchronous decorator and the data extraction instruction; the server constructs a key-value pair of the parent class identifier and the child class identifier according to the preset construction rules and the asynchronous decorator to obtain the first target data key-value pair.

[0063] The server obtains the parent class identifier and the subclass identifier according to the target task layer asynchronous decorator and the data extraction instruction, and obtains the first target data key-value pair according to the preset construction rules, the parent class identifier and the subclass identifier. For example, if the data extraction instruction is to obtain an article, the article category is technology, and the author of the article is A, then the server first obtains the parent class identifier as article, the subclass identifier as technology, and the author A through the target task layer asynchronous decorator, then the parent class identifier article and the subclass identifier technology, author A constitute the first target data key-value pair.

[0064] The server constructs a key-value pair of the obtained attached column identifier and subclass identifier according to the preset construction rule and the asynchronous decorator to obtain the first target data key-value pair, namely Key. The first target data key-value pair is a string. The preset construction rule can be parent class identifier: subclass identifier, and the parent class identifier and the subclass identifier are separated by a colon. For example, the first target data key-value pair with the parent class identifier being article, the subclass identifier being technology and the author A is handler:article:scienceandtechnology:A.

[0065] It should be noted that the parent class identifier and the subclass identifier are determined according to the data extraction instruction. The parent class identifier can be a business name, type name or database name, etc., and the subclass identifier can be a function name, parameter name or parameter value, etc.

[0066] 205. Obtain the first target data in the first cache space through the target task layer asynchronous decorator, and determine whether the first target data is a null value through the target task layer asynchronous decorator, where the first target data is data corresponding to the first target data key-value pair.

[0067] The server obtains the first target data in the first cache space through the target task layer asynchronous decorator, and determines whether the first target data is a null value through the target task layer asynchronous decorator. The first target data is the data corresponding to the first target data key-value pair.

[0068] Optionally, the server obtains the first target data in the first cache space through the target task layer asynchronous decorator, and determines whether the first target data is a null value through the target task layer asynchronous decorator. The first target data is the data corresponding to the first target data key-value pair and also includes: if the first target data is not a null value, the server determines that the first target data is the target data, and sends the target data to the preset front end.

[0069] The server obtains the first target data corresponding to the first target data key-value pair in the first cache space through the target task layer asynchronous decorator, and determines whether the first target data corresponding to the first target data key-value pair is a null value through the target task layer asynchronous decorator. If the first target data is not a null value, the server directly sends the first data as the target data to the preset terminal; if the first target data is a null value, it means that the first target data is not the target data, and it is necessary to re-acquire the target data from other cache spaces and send it to the preset terminal.

[0070] 206. If the first target data is a null value, forward the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtain the second target data in the second cache space, and determine whether the second target data is a null value. The second target data is the data corresponding to the second target data key-value pair.

[0071] If the first target data is a null value, the server forwards the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtains the second target data in the second cache space, and determines whether the second target data is a null value. The second target data is the data corresponding to the second target data key-value pair.

[0072] After the server determines that if the first target data is a null value, the server constructs a second target data key-value pair according to the parent class identifier and the child class identifier through the target data layer asynchronous decorator according to the construction rules of the target task layer asynchronous decorator. The server obtains the parent class data that matches the parent class identifier in the second cache space according to the parent class flag, and obtains the child class data that matches the child class identifier in the second cache space according to the child class identifier, synthesizes the parent class data and the child class data, and obtains the second target data.

[0073] It should be noted that the difference between the second target data key-value pair constructed by the target data layer asynchronous decorator and the first target data key-value pair constructed by the target task layer asynchronous decorator is that the prefixes are different. For example, the second target data key-value pair with the parent class identified as article, the subclass identified as technology and author A is: dao:article:scienceandtechnology:A, while the first target data key-value pair with the parent class identified as article, the subclass identified as technology and author A is: handler:article:scienceandtechnology:A.

[0074] Specifically, the server obtains the target data layer asynchronous decorator through the data extraction instruction; the server obtains the second target data key-value pair through the target data layer asynchronous decorator, the data extraction instruction and the preset construction rule; the server obtains the parent class data corresponding to the parent class identifier in the second cache space according to the second target data key-value pair; the server obtains the subclass data corresponding to the subclass identifier in the second cache space according to the second target data key-value pair; the server synthesizes the parent class data and the subclass data to obtain the second target data, and determines whether the second target data is a null value through the target data layer asynchronous decorator.

[0075] For ease of understanding, the following is an explanation based on specific application scenarios:

[0076] The server obtains the parent class data matching the parent class identifier in the second cache space according to the second target data key-value pair, and obtains the subclass data matching the subclass identifier in the second cache space according to the parent class data. For example, the server obtains the article data corresponding to article according to the second target data key-value pair dao:article:science and technology:A, obtains the scientific article data corresponding to science and technology according to the second target data key-value pair dao:article:science and technology:A, and obtains the author data corresponding to A according to the second target data key-value pair dao:article:science and technologyA. The server synthesizes the article data, the scientific article data, and the author data to obtain the second target data, and the second target data is the scientific article data whose author is A.

[0077] The server obtains the second target data based on the parent class data and the child class data, and determines whether the second target data is a null value. If the second target data is not a null value, the second target data is set to the first cache space, the target data is obtained, and the target data is sent to the preset terminal; if the second target data is a null value, it means that the second target data is not the target data, and the target data needs to be obtained from the database and sent to the preset terminal.

[0078] Specifically, the server obtains the target data layer asynchronous decorator through data extraction instructions, including: the server obtains the target data layer asynchronous decorator through data extraction instructions, builds a synchronous decorator in the preset data layer according to the data extraction instructions, and obtains the data layer synchronous decorator; the server builds an asynchronous decorator based on the data layer synchronous decorator to obtain an initial data layer asynchronous decorator; the server processes the initial data layer asynchronous decorator through a preset asynchronous module and a preset asynchronous function to obtain a target data layer asynchronous decorator.

[0079] The server constructs a synchronous decorator on the preset data layer according to the data extraction instruction and uses the preset decorator to obtain the data layer synchronous decorator. The server constructs an asynchronous decorator on the preset data layer based on the data layer synchronous decorator to obtain the initial data layer asynchronous decorator. At this time, the initial data layer asynchronous decorator does not have asynchronous function. The server needs to use the preset asynchronous module and the preset asynchronous function to implement the asynchronous function of the initial data layer asynchronous decorator, and finally obtain the target data layer asynchronous decorator.

[0080] 207. If the second target data is a null value, forward the second target data key-value pair to a database, obtain the target data in the database according to the second target data key-value pair, and send the target data to a preset terminal.

[0081] If the second target data is a null value, the server forwards the second target data key-value pair to the database, obtains the target data in the database according to the second target data key-value pair, and sends the target data to the preset terminal.

[0082] Specifically, the server determines the first transition target data in the database through the second target data key-value pair; the server sets the first transition target data in the second cache space through the target data layer asynchronous decorator to obtain the second transition target data; the server sets the second target transition data in the first cache space through the target task layer asynchronous decorator to obtain the third transition target data; the server determines the third transition target data as the target data, and sends the target data to the preset front end.

[0083] It should be noted that the first transition target data is the data in the database that matches the second target data key-value pair, the second transition target data is the data in the second cache space that matches the second target data key-value pair, and the third transition target data is the data in the first cache space that matches the first target data key-value pair.

[0084] After judgment by the server, if the second target data is a null value, the server determines the first transition target data in the database based on the second target data key-value pair. After determining that the first transition target data is not a null value, the server sets the first transition target data in the second cache space. At this time, the second transition target data is obtained. The server then sets the second transition target data in the first cache space. After determining that the second transition target data is not a null value, the third transition target data is obtained, and the third transition target data is determined as the target data. Finally, the server sends the third transition target data to the preset terminal.

[0085] The embodiment of the present invention constructs an asynchronous decorator at the task layer and the data layer, extracts cache data through the asynchronous decorator, solves the problem of complex calling target data from the data layer, and improves cache efficiency.

[0086] The above describes the double buffering method based on the asynchronous decorator in the embodiment of the present invention. The following describes the double buffering device based on the asynchronous decorator in the embodiment of the present invention. Figure 3 , an embodiment of a double buffer device based on an asynchronous decorator in an embodiment of the present invention includes:

[0087] The generating unit 301 is used to obtain a data extraction instruction and generate a target task layer asynchronous decorator according to the data extraction instruction;

[0088] A first acquisition unit 302 is used to acquire a first target data key-value pair according to the target task layer asynchronous decorator and the preset construction rule, where the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction;

[0089] The first processing unit 303 is used to obtain the first target data in the first cache space through the target task layer asynchronous decorator, and determine whether the first target data is a null value through the target task layer asynchronous decorator, and the first target data is the data corresponding to the first target data key-value pair;

[0090] The second processing unit 304 is used to forward the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtain the second target data in the second cache space, and determine whether the second target data is a null value, and the second target data is the data corresponding to the second target data key-value pair if the first target data is a null value;

[0091] The second acquisition unit 305 is used to forward the second target data key-value pair to the database if the second target data is a null value, acquire the target data in the database according to the second target data key-value pair, and send the target data to the preset terminal.

[0092] The embodiment of the present invention constructs an asynchronous decorator at the task layer and the data layer, extracts cache data through the asynchronous decorator, solves the problem of complex calling target data from the data layer, and improves cache efficiency.

[0093] See also Figure 4 Another embodiment of the double buffer device based on the asynchronous decorator in the embodiment of the present invention includes:

[0094] The generating unit 301 is used to obtain a data extraction instruction and generate a target task layer asynchronous decorator according to the data extraction instruction;

[0095] A first acquisition unit 302 is used to acquire a first target data key-value pair according to the target task layer asynchronous decorator and the preset construction rule, where the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction;

[0096] The first processing unit 303 is used to obtain the first target data in the first cache space through the target task layer asynchronous decorator, and determine whether the first target data is a null value through the target task layer asynchronous decorator, and the first target data is the data corresponding to the first target data key-value pair;

[0097] The second processing unit 304 is used to forward the data extraction instruction to the preset data layer to obtain the second target data key-value pair, obtain the second target data in the second cache space, and determine whether the second target data is a null value, and the second target data is the data corresponding to the second target data key-value pair if the first target data is a null value;

[0098] The second acquisition unit 305 is used to forward the second target data key-value pair to the database if the second target data is a null value, acquire the target data in the database according to the second target data key-value pair, and send the target data to the preset terminal.

[0099] Optionally, the generating unit 301 is specifically configured to:

[0100] Construct a synchronization decorator at the preset task layer according to the data extraction instruction to obtain a task layer synchronization decorator;

[0101] Based on the task layer synchronous decorator, an asynchronous decorator is constructed in the preset task layer to obtain the initial task layer asynchronous decorator;

[0102] The initial task layer asynchronous decorator is processed by presetting asynchronous modules and presetting asynchronous functions to obtain the target task layer asynchronous decorator.

[0103] Optionally, the first processing unit 303 specifically includes:

[0104] The first acquisition module 3031 is used to acquire the target data layer asynchronous decorator through the data extraction instruction;

[0105] The second acquisition module 3032 is used to obtain a second target data key-value pair through the target data layer asynchronous decorator, the data extraction instruction and the preset construction rule;

[0106] The third acquisition module 3033 is used to acquire the parent class data corresponding to the parent class identifier in the second cache space according to the second target data key-value pair;

[0107] A fourth acquisition module 3034 is used to acquire subclass data corresponding to the subclass identifier in the second cache space according to the second target data key-value pair;

[0108] The data synthesis and judgment module 3035 is used to synthesize the parent class data and the child class data to obtain the second target data, and judge whether the second target data is a null value through the target data layer asynchronous decorator.

[0109] Optionally, the first acquisition module 3031 is specifically used for:

[0110] Construct a synchronization decorator in the preset data layer according to the data extraction instruction to obtain a data layer synchronization decorator;

[0111] Build an asynchronous decorator based on the data layer synchronous decorator to obtain the initial data layer asynchronous decorator;

[0112] The initial data layer asynchronous decorator is processed by presetting the asynchronous module and the preset asynchronous function to obtain the target data layer asynchronous decorator.

[0113] Optionally, the second processing unit 304 is specifically configured to:

[0114] Determine the first transition target data in the database through the second target data key-value pair;

[0115] The first transition target data is set in the second cache space through the target data layer asynchronous decorator to obtain the second transition target data;

[0116] The second target transition data is set in the first cache space through the target task layer asynchronous decorator to obtain the third transition target data;

[0117] The third transition target data is determined as the target data, and the target data is sent to the preset front end.

[0118] Optionally, the first acquiring unit 302 is specifically configured to:

[0119] According to the target task layer asynchronous decorator and data extraction instructions, obtain the parent class identifier and the child class identifier;

[0120] A key-value pair is constructed for the parent class identifier and the child class identifier according to the preset construction rules and the asynchronous decorator to obtain a first target data key-value pair.

[0121] Optionally, the first processing unit 303 is further configured to:

[0122] If the first target data is not a null value, the first target data is determined to be the target data, and the target data is sent to the preset front end.

[0123] The embodiment of the present invention constructs an asynchronous decorator at the task layer and the data layer, extracts cache data through the asynchronous decorator, solves the problem of complex calling target data from the data layer, and improves cache efficiency.

[0124] above Figure 3 to Figure 4 The double buffer device based on asynchronous decorator in the embodiment of the present invention is described in detail from the perspective of modular functional entity. The double buffer device based on asynchronous decorator in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0125] Combine the following Figure 5 A detailed introduction to the various components of the double-buffered device based on asynchronous decorator:

[0126] Figure 5 1 is a schematic diagram of the structure of a double-buffered device based on an asynchronous decorator provided by an embodiment of the present invention. The double-buffered device 500 based on an asynchronous decorator may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 501 (for example, one or more processors) and a memory 509, and one or more storage media 508 (for example, one or more mass storage devices) storing application programs 507 or data 506. Among them, the memory 509 and the storage medium 508 can be short-term storage or permanent storage. The program stored in the storage medium 508 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the sign-in management device. Furthermore, the processor 501 can be configured to communicate with the storage medium 508 to execute a series of instruction operations in the storage medium 508 on the double-buffered device 500 based on the asynchronous decorator.

[0127] The double buffer device 500 based on asynchronous decorator may also include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input and output interfaces 504, and / or one or more operating systems 505, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. It can be understood by those skilled in the art that Figure 5 The double-buffer device structure based on asynchronous decorator shown in the figure does not constitute a limitation on the double-buffer device based on asynchronous decorator, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0128] Combine the following Figure 5 A detailed introduction to the various components of the double-buffered device based on asynchronous decorator:

[0129] Processor 501 is the control center of the double-buffer device based on asynchronous decorator, and can be processed according to the double-buffer method based on asynchronous decorator. Processor 501 uses various interfaces and lines to connect various parts of the entire double-buffer device based on asynchronous decorator, and extracts cache data through task decorator by running or executing software programs and / or modules stored in memory 509, and calling data stored in memory 509, thereby improving cache efficiency. Storage medium 508 and memory 509 are both carriers for storing data. In the embodiment of the present invention, storage medium 508 can refer to an internal memory with a small storage capacity but a fast speed, and memory 509 can be an external memory with a large storage capacity but a slow storage speed.

[0130] The memory 509 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing of the double buffer device 500 based on the asynchronous decorator by running the software programs and modules stored in the memory 509. The memory 509 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc.; the data storage area can store data created according to the use of the double buffer device based on the asynchronous decorator, etc. In addition, the memory 509 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. The double buffer program based on the asynchronous decorator provided in the embodiment of the present invention and the received data stream are stored in the memory, and when needed, the processor 501 calls from the memory 509.

[0131] When loading and executing computer program instructions on a computer, a process or function according to an embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. Computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, a computer instruction may be transmitted from a website site, a computer, a server, or a data center to another website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, twisted pair) or wireless (e.g., infrared, wireless, microwave, etc.) means. Computer-readable storage media may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. Available media may be magnetic media, (e.g., floppy disk, hard disk, tape), optical media (e.g., optical disk), or semiconductor media (e.g., solid state disk (SSD)), etc.

[0132] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0133] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A double buffering method based on asynchronous decorator, characterized in that: include: Obtaining a data extraction instruction, and generating a target task layer asynchronous decorator according to the data extraction instruction; According to the target task layer asynchronous decorator and the preset construction rule, a first target data key-value pair is obtained, wherein the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction; Obtaining first target data in a first cache space through the target task layer asynchronous decorator, and determining whether the first target data is a null value through the target task layer asynchronous decorator, the first target data being data corresponding to the first target data key-value pair; If the first target data is a null value, forwarding the data extraction instruction to the preset data layer to obtain a second target data key-value pair, obtaining the second target data in the second cache space, and determining whether the second target data is a null value, the second target data being the data corresponding to the second target data key-value pair; If the second target data is a null value, the second target data key-value pair is forwarded to a database, target data is acquired from the database according to the second target data key-value pair, and the target data is sent to a preset terminal.

2. The double buffering method based on asynchronous decorator according to claim 1, characterized in that: The obtaining of the data extraction instruction and generating the target task layer asynchronous decorator according to the data extraction instruction comprises: Constructing a synchronization decorator at the preset task layer according to the data extraction instruction to obtain a task layer synchronization decorator; Based on the task layer synchronous decorator, an asynchronous decorator is constructed in the preset task layer to obtain an initial task layer asynchronous decorator; The initial task layer asynchronous decorator is processed by a preset asynchronous module and a preset asynchronous function to obtain a target task layer asynchronous decorator.

3. The double buffering method based on asynchronous decorator according to claim 1 is characterized in that: If the first target data is a null value, the data extraction instruction is forwarded to the preset data layer to obtain a second target data key-value pair, the second target data is obtained in the second cache space, and it is determined whether the second target data is a null value, and the second target data is the data corresponding to the second target data key-value pair, including: Obtain the target data layer asynchronous decorator through the data extraction instruction; Obtaining a second target data key-value pair through the target data layer asynchronous decorator, the data extraction instruction and the preset construction rule; According to the second target data key-value pair, obtaining the parent class data corresponding to the parent class identifier in the second cache space; According to the second target data key-value pair, obtaining the subclass data corresponding to the subclass identifier in the second cache space; The parent class data and the child class data are synthesized to obtain second target data, and whether the second target data is a null value is determined through the target data layer asynchronous decorator.

4. The double buffering method based on asynchronous decorator according to claim 3 is characterized in that: The step of obtaining the target data layer asynchronous decorator through the data extraction instruction includes: Constructing a synchronization decorator in the preset data layer according to the data extraction instruction to obtain a data layer synchronization decorator; Construct an asynchronous decorator based on the data layer synchronous decorator to obtain an initial data layer asynchronous decorator; The initial data layer asynchronous decorator is processed by a preset asynchronous module and a preset asynchronous function to obtain a target data layer asynchronous decorator.

5. The double buffering method based on asynchronous decorator according to claim 4 is characterized in that: If the second target data is a null value, forwarding the second target data key-value pair to a database, acquiring target data in the database according to the second target data key-value pair, and sending the target data to a preset terminal includes: Determine the first transition target data in the database through the second target data key-value pair; The first transition target data is set in the second cache space by the target data layer asynchronous decorator to obtain second transition target data; The second transition target data is set in the first cache space by the target task layer asynchronous decorator to obtain third transition target data; The third transition target data is determined as target data, and the target data is sent to the preset front end.

6. The double buffering method based on asynchronous decorator according to claim 1, characterized in that: The step of obtaining a first target data key-value pair according to the target task layer asynchronous decorator and the preset construction rule, wherein the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction, including: According to the target task layer asynchronous decorator and the data extraction instruction, obtain the parent class identifier and the child class identifier; A key-value pair is constructed for the parent class identifier and the child class identifier according to the preset construction rule and the asynchronous decorator to obtain a first target data key-value pair.

7. The double buffering method based on asynchronous decorator according to any one of claims 1 to 6, characterized in that: The first target data is obtained in the first cache space through the target task layer asynchronous decorator, and the first target data is determined to be a null value through the target task layer asynchronous decorator, and the first target data is the data corresponding to the first target data key-value pair, and further includes: If the first target data is not a null value, the first target data is determined to be target data, and the target data is sent to a preset front end.

8. A double buffer device based on asynchronous decorator, characterized in that: include: A generating unit, used for acquiring a data extraction instruction and generating a target task layer asynchronous decorator according to the data extraction instruction; A first acquisition unit is used to acquire a first target data key-value pair according to the target task layer asynchronous decorator and the preset construction rule, wherein the first target data key-value pair is composed of a parent class identifier and a child class identifier, and the parent class identifier and the child class identifier are extracted according to the data extraction instruction; A first processing unit is used to obtain first target data in a first cache space through the target task layer asynchronous decorator, and to determine whether the first target data is a null value through the target task layer asynchronous decorator, wherein the first target data is data corresponding to the first target data key-value pair; a second processing unit, for forwarding the data extraction instruction to a preset data layer to obtain a second target data key-value pair, obtaining the second target data in a second cache space, and determining whether the second target data is a null value, if the first target data is a null value, the second target data being data corresponding to the second target data key-value pair; The second acquisition unit is used to forward the second target data key-value pair to a database if the second target data is a null value, acquire the target data in the database according to the second target data key-value pair, and send the target data to a preset terminal.

9. A double buffer device based on an asynchronous decorator, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the double buffering method based on asynchronous decorator as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the double buffering method based on asynchronous decorator as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Spatial data double cache method and mechanism based on key value structure

    CN103092775A

  • Data caching processing method and device, electronic device and readable storage medium

    CN109885786A

  • Data synchronization method, device and system, storage medium and server

    WO2018076868A1