A multi-level data caching method and device based on version number

By adopting a multi-level data caching method based on version numbers in the distributed system, combined with preloading and lazy loading methods, the data consistency problem in the existing technology is solved, efficient data synchronization and simplified application layer design are achieved, and support Multi-level cache architecture deployment for distributed systems.

CN112749198BActive Publication Date: 2024-10-22CHINA CITIC BANK CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202110084049.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-21
Publication Date
2024-10-22
Estimated Expiration
2041-01-21

AI Technical Summary

Technical Problem

Multi-level caches in existing distributed systems have system delays and poor availability when ensuring data consistency, cannot guarantee data consistency and integrity in real time, and have complex application layer designs.

Method used

A multi-level data caching method based on version numbers is adopted to achieve data consistency through version number management tables. It combines preloading and lazy loading methods to efficiently synchronize multi-level cache data to ensure real-time consistency between the cache and the database.

Benefits of technology

It achieves real-time consistency of multi-level cache data, improves synchronization efficiency and simplifies application layer design, and supports local active-active in the same city or three-center deployment in two places for distributed systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112749198B_ABST
    Figure CN112749198B_ABST
Patent Text Reader

Abstract

The present invention discloses a multi-level data caching method and device based on version numbers, wherein the method comprises: configuring the first version number management table information according to preset rules, obtaining the first transaction request information, loading all the version number information in the first version number management table according to the first transaction request information, obtaining the first access request information; determining the first version number from all the version number information in the loaded first version number management table according to the first access request information. Each time the data is queried, the latest version number is used to query from the cache, if it hits, it is directly returned, if it does not hit, it penetrates to the database query, returns the result, and then synchronizes the data corresponding to the latest version number to each layer of cache. The technical problems in the prior art that the real-time consistency and integrity of the multi-level cache data of the distributed system cannot be guaranteed and the system availability is poor are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed system data caching, and in particular to a version number-based multi-level data caching method and device. Background Art

[0002] In the distributed system architecture with large traffic, multi-level cache design is often used, that is, data is cached at different levels of the entire system architecture to improve access efficiency. This is also one of the most widely used solutions. When a data query request is received, the application first queries in the local process cache. If it hits, it returns directly. If it does not hit, it continues to query the distributed cache layer; if the distributed cache layer hits, it returns directly. If it does not hit, it directly requests the database layer, returns the result, and then synchronizes the data to the multi-level cache layer. After the relational database layer data is synchronized to the distributed cache layer and the local cache layer of the application, if the synchronized data of the database layer changes, such as adding, deleting or modifying, the data of the cache layer at all levels will be inconsistent with the data in the database layer. When the application accesses data, if the data of the cache layer is inconsistent with the data of the database layer, it is a serious security incident for the distributed system that requires real-time consistency of data. The data consistency problem is mainly reflected in how to update the cache when the cache data is updated to ensure the data consistency between the database and the cache and between the cache layers.

[0003] There are several main methods for ensuring data consistency in distributed system multi-level cache: first delete the cache, then execute the database transaction to write the database, and then set the cache when reading data; message queue modification plan; Timer modification plan; asynchronous serialization of database, cache update and read operations; plan based on timestamp comparison.

[0004] In the process of implementing the technical solution of the invention in the embodiment of the present application, the inventors of the present application found that the above technology has at least the following technical problems:

[0005] The system has delays and poor system availability, cannot guarantee real-time data consistency and integrity, has poor data synchronization, and the application layer design is relatively complex. Summary of the invention

[0006] The embodiments of the present application provide a multi-level data caching method and device based on version numbers, which solves the technical problems of system delay, poor system availability, inability to ensure real-time data consistency and integrity, poor data synchronization, and complex application layer design in the prior art. It realizes the real-time consistency of multi-level cache data based on version number identification, and efficiently synchronizes multi-level cache data by combining preloading and lazy loading methods, effectively supporting the technical purpose of local same-city dual-active or two-site three-center deployment and implementation of distributed system multi-level cache architecture.

[0007] The embodiment of the present application provides a multi-level data caching method based on version numbers, which is applied to a multi-layer cache system, wherein the multi-layer cache system includes a first memory cache library, a second memory cache library, and a first database, wherein the method includes: configuring first version number management table information according to preset rules; obtaining first transaction request information; loading all version number information in the first version number management table according to the first transaction request information; obtaining first access request information, wherein the first access request information includes a first target data table; determining a first version number from all version number information in the first version number management table after loading according to the first access request information, wherein the first version number is consistent with the first target data table Corresponding; according to the first version number, query the first data from the first memory cache library, and obtain a first query result, wherein the first memory cache library is a local memory cache; when the first query result is a valueless hit, query the first data from the second memory cache library, and obtain a second query result, wherein the second memory cache library is a distributed cache; when the second query result is a valueless hit or an exception, obtain second access request information; according to the second access request information, after accessing the first database, obtain a third query result; write the third query result into the second memory cache library and the first memory cache library in sequence, and return the third query result to the application node in the multi-layer cache system.

[0008] On the other hand, the present application also provides a multi-level data cache device based on version numbers, wherein the device includes: a first configuration unit, the first configuration unit is used to configure first version number management table information according to preset rules; a first obtaining unit, the first obtaining unit is used to obtain first transaction request information; a first loading unit, the first loading unit is used to load all version number information in the first version number management table according to the first transaction request information; a second obtaining unit, the second obtaining unit is used to obtain first access request information, wherein the first access request information includes a first target data table; a third obtaining unit, the third obtaining unit is used to determine the first version number from all version number information in the loaded first version number management table according to the first access request information, wherein the first version number corresponds to the first target data table; a fourth obtaining unit, the fourth obtaining unit is used to obtain the first version number according to the first access request information The first version number queries the first data from the first memory cache library and obtains the first query result, wherein the first memory cache library is a local memory cache; a fifth obtaining unit, the fifth obtaining unit is used to query the first data from the second memory cache library and obtain the second query result when the first query result is a valueless hit, wherein the second memory cache library is a distributed cache; a sixth obtaining unit, the sixth obtaining unit is used to obtain second access request information when the second query result is a valueless hit or an exception; a seventh obtaining unit, the seventh obtaining unit is used to obtain a third query result after accessing the first database according to the second access request information; a first reading unit, the first reading unit is used to write the third query result into the second memory cache library and the first memory cache library in sequence, and return the third query result to the application node in the multi-layer cache system.

[0009] On the other hand, an embodiment of the present application also provides a multi-level data cache device based on version numbers, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the program.

[0010] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0011] Since the cache data is identified by version number, the data consistency between each layer of cache and between the cache and the database is guaranteed. Every time there is a data change in a data table, the version number in the configuration table needs to be changed synchronously. Every time the data is queried, the latest version number is used to query from the cache. If it hits, it is returned directly. If it does not hit, it penetrates the database query, returns the result, and then synchronizes the data corresponding to the latest version number to each layer of cache. At the same time, a multi-level cache data synchronization method combining preloading and lazy loading is adopted. The synchronization efficiency is high and the use is simple. It realizes the real-time consistency of multi-level cache data based on version number identification of cache data. The preloading and lazy loading methods are combined to efficiently synchronize multi-level cache data, effectively supporting the technical purpose of local dual-active in the same city or two-site three-center deployment and implementation of distributed system multi-level cache architecture.

[0012] The above description is an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, which can be implemented in accordance with the contents of the specification, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A schematic diagram of a process flow of a multi-level data caching method based on version numbers according to an embodiment of the present application;

[0014] Figure 2 Another flowchart of a multi-level data caching method based on version numbers according to an embodiment of the present application;

[0015] Figure 3 A schematic diagram of a multi-level cache system architecture;

[0016] Figure 4 This is a schematic diagram of the structure of a multi-level data cache device based on version numbers according to an embodiment of the present application;

[0017] Figure 5 It is a schematic diagram of the structure of an exemplary electronic device according to an embodiment of the present application.

[0018] Explanation of the figure marks: first configuration unit 11, first obtaining unit 12, first loading unit 13, second obtaining unit 14, third obtaining unit 15, fourth obtaining unit 16, fifth obtaining unit 17, sixth obtaining unit 18, seventh obtaining unit 19, first reading unit 20, bus 300, receiver 301, processor 302, transmitter 303, memory 304, bus interface 305. DETAILED DESCRIPTION

[0019] The embodiments of the present application provide a multi-level data caching method and device based on version numbers, which solves the technical problems of system delay, poor system availability, inability to ensure real-time data consistency and integrity, poor data synchronization, and complex application layer design in the prior art. It realizes the real-time consistency of multi-level cache data based on version number identification of cache data, and efficiently synchronizes multi-level cache data by combining preloading and lazy loading methods, effectively supporting the technical purpose of local same-city dual-active or two-site three-center deployment and implementation of distributed system multi-level cache architecture. Below, the example embodiments of the present application will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments of the present application, and it should be understood that the present application is not limited to the example embodiments described here.

[0020] Application Overview

[0021] In distributed systems, especially distributed transaction and payment systems, there are often scenarios where certain hot data (low-frequency modification, high-frequency access) are read with high concurrency. In order to improve access efficiency, a multi-level cache architecture design of local memory cache and distributed cache (such as redis cluster) is generally adopted, and such systems require that cache data and database data must meet real-time consistency. The existing technology still has technical problems such as system delay, poor system availability, inability to ensure real-time data consistency and integrity, poor data synchronization, and complex application layer design.

[0022] In response to the above technical problems, the overall idea of ​​the technical solution provided by this application is as follows:

[0023] The embodiment of the present application provides a multi-level data caching method based on version numbers, which is applied to a multi-layer cache system, wherein the multi-layer cache system includes a first memory cache library, a second memory cache library, and a first database, wherein the method includes: configuring first version number management table information according to preset rules; obtaining first transaction request information; loading all version number information in the first version number management table according to the first transaction request information; obtaining first access request information, wherein the first access request information includes a first target data table; determining a first version number from all version number information in the first version number management table after loading according to the first access request information, wherein the first version number is consistent with the first target data table Corresponding; according to the first version number, query the first data from the first memory cache library, and obtain a first query result, wherein the first memory cache library is a local memory cache; when the first query result is a valueless hit, query the first data from the second memory cache library, and obtain a second query result, wherein the second memory cache library is a distributed cache; when the second query result is a valueless hit or an exception, obtain second access request information; according to the second access request information, after accessing the first database, obtain a third query result; write the third query result into the second memory cache library and the first memory cache library in sequence, and return the third query result to the application node in the multi-layer cache system.

[0024] After introducing the basic principles of the present application, various non-limiting implementation methods of the present application will be specifically described below in conjunction with the drawings in the specification.

[0025] Embodiment 1

[0026] like Figure 1 As shown, an embodiment of the present application provides a multi-level data caching method based on version numbers, which is applied to a multi-layer cache system, wherein the multi-layer cache system includes a first memory cache library, a second memory cache library, and a first database, wherein the method includes:

[0027] Step S100: configuring the first version number management table information according to preset rules;

[0028] Furthermore, the embodiment S100 of the present application also includes:

[0029] Step S101a: obtaining a first header name, a second header name, and a third header name, wherein the first header name and the second header name have a first association relationship;

[0030] Step S102a: obtaining the first table content according to the first table header name, obtaining the second table content according to the second table header name, and obtaining the third table content according to the third table header name;

[0031] Step S103a: configure the first version number management table information according to the first header name, the first table content, the second header name, the second table content, the third header name, and the third table content.

[0032] Specifically, the first table content, the second table content and the third table content are determined by determining the first table header name, the second table header name and the third table header name, thereby completing the configuration of the first version number management table.

[0033] The VRSNNUM table structure is as follows:

[0034] Table 1. VRSNNUM table structure information

[0035] Field Name Field meaning Can it be empty? BANK_NUM Bank Number Cannot be empty VRSN_TYP Parameter Type Cannot be empty LAST_VRSN_NUM Previous version number Cannot be empty CRNT_VRSN_NUM Today's version number Cannot be empty USER_NAM Maintainer UPD_TIME Maintenance time

[0036] Specifically, the version number is a common version design scheme, which is to add a version number field on the table where historical data is to be retained. Each time a data operation is performed, a new version is created. The version can only increase but not decrease, so you only need to get the largest version number to get the latest business data. In addition to retaining historical data, the version number also has a function of avoiding concurrent editing operations. When the data table uses the cache function, the VRSNNUM table needs to be configured.

[0037] The VRSNNUM table is used to manage the version numbers of all data tables. This solution uses version numbers to identify cached data to ensure data consistency between caches at all levels and between caches and databases. Every time there is a data change in a data table, the version number configured in the VRSNNUM table needs to be synchronized by +1.

[0038] Step S200: obtaining first transaction request information;

[0039] Step S300: loading all version number information in the first version number management table according to the first transaction request information;

[0040] Specifically, if Figure 2As shown, when the application receives a transaction request, it reads all the version number information in the VRSNNUM table into the local memory Map structure during initialization. The version number composition rule is: 8-digit accounting date + 3-digit bank number + 5-digit sequence number, and the first version number of the day starts from 00000. The Map structure is an associative container of STL, which provides one-to-one (the first one can be called a keyword, each keyword can only appear once in the map, and the second one may be called the value of the keyword) data processing capabilities. Due to this feature, it is possible to provide a fast channel in programming when we process one-to-one data.

[0041] Step S400: obtaining first access request information, wherein the first access request information includes a first target data table;

[0042] Step S500: determining a first version number from all version number information in the loaded first version number management table according to the first access request information, wherein the first version number corresponds to the first target data table;

[0043] Specifically, the multi-layer cache system obtains the first access request information of the application, the first access request includes the access request information of the application to the first target data table, and finds the version number information corresponding to the data table from the first version number management table in the local memory version number Map structure based on the first access request information, that is, obtains the first version number information. The first version number is used to ensure that the data read within a transaction processing cycle is consistent.

[0044] Step S600: querying first data from the first memory cache library according to the first version number, and obtaining a first query result, wherein the first memory cache library is a local memory cache;

[0045] Step S700: when the first query result is no value hit, query the first data from the second memory cache library and obtain a second query result, wherein the second memory cache library is a distributed cache;

[0046] Specifically, the architecture diagram of the multi-layer cache system in this embodiment is as follows: Figure 3As shown, the local cache is the memory space where the data is stored in the application code. The advantage of the local cache is that it can provide fast data access, but the disadvantage is that it cannot be distributed and shared, and there is no fault tolerance. The distributed cache is the distributed storage of data among a fixed number of cluster nodes. The advantage is that the cache capacity can be expanded, but the disadvantage is that a lot of configuration is required during the expansion process, and there is no fault tolerance mechanism. The application accesses the data table in a single way by primary key or multiple ways by index, and uses the primary key value or index value and version number to access the data. When the application accesses the first target data table, according to the first version number information, the first data is first searched in the first memory cache library, that is, the local memory cache, to obtain the first query result, and the first query result is divided into the results of cache data value hit and no value hit. When the first query result is no value hit, the primary key value or index value and version number are used to continue to search for the first data in the second memory cache library, that is, the distributed cache library, and obtain the second query result, which also includes the results of the first data having a value hit and no value hit in the distributed cache.

[0047] Step S800: when the second query result is no value hit or abnormal, obtaining second access request information;

[0048] Specifically, the second access request information is the request information for the application to directly access the database. When the distributed cache also has no value hit or the access is abnormal, the second access request information is obtained, and the application directly accesses the data and searches for the first data information in the database.

[0049] Step S900: after accessing the first database according to the second access request information, a third query result is obtained;

[0050] Specifically, according to the second access request information, the application uses the primary key value or the index value to directly access the database and obtains the third query result information, where the third query result information includes information on whether the first data has a numerical hit in the database.

[0051] Step S1000: write the third query result into the second memory cache library and the first memory cache library in sequence, and return the third query result to the application node in the multi-layer cache system.

[0052] Specifically, after the application directly accesses the database to obtain the third query result information, the system writes the third query result into a distributed cache (Redis), writes it into a local memory cache, and finally sends the third query result to the application. Redis is open source and free, complies with the BSD protocol, and is a high-performance key-value non-relational database. The application node is a level under the application virtualization node in the scope pane of the application virtualization client management console, and the data processing system transmits and obtains information between the application node and the application.

[0053] Furthermore, step S100 in the embodiment of the present application also includes:

[0054] Step S101b: obtaining the current time;

[0055] Step S102b: when performing daily cutting processing within the current time, obtaining first usage information;

[0056] Step S103b: According to the first usage information, the first initial version number of the current time is used to preload all the data in the first version number management table into the second memory cache library, wherein the cache data is stored in a key-value manner;

[0057] Step S104b: assigning the first initial version number to the second version number by full preloading, and assigning the third version number to the first initial version number, so that in the period from the completion of full preloading to the day-cut processing, the third version number is used to access the cache, wherein the second version number is the version number corresponding to the previous time of the current time, and the third version number is the version number corresponding to the next time of the current time;

[0058] Step S105b: After the daily switching process is completed, the third version number is used.

[0059] Specifically, daily switching is to switch dates, change the system accounting time, and centrally process the system business of the day. After the processing is completed, the system switches from the current working day to the next working day. During the daily switching process, transactions can be submitted as usual and correctly processed and returned. After the VRSNNUM table maintenance is completed, the first initial version number is used before the daily switching to preload the full amount of data in the configured data table into the distributed cache (redis cache). The cached data is stored in a key-value manner, and the key will be spelled with the current version number of the data table. The Key-value database is a non-relational database model, and its data is organized, indexed and stored in the form of key-value pairs. The full preload will assign the current version number of the day to the previous version number, and then assign the next version number to the current version number, initialize the current version number, so that in the period from the completion of the full preload to the time before the daily switching process, the third version number is used to access the cache, ensuring that the transactions during the period from the completion of the preload to the day can use the previous version number to access the cache normally, and use the third version number after the day switch.

[0060] Furthermore, step S200 in the embodiment of the present application further includes:

[0061] Step S201a: In the process of loading all version number information in the first version number management table, read all version number information into the Map structure of the first memory cache library, wherein the version number generation rule includes the first digit accounting date, the second digit bank number, and the third digit serial number.

[0062] Specifically, after receiving a transaction request, the application reads all version number information in the VRSNNUM table into the Map structure of the first local memory cache library during initialization. The version number generation rule is: 8-digit accounting date + 3-digit bank number + 5-digit serial number, and the first version number of the day starts from 00000.

[0063] Furthermore, step S200 in the embodiment of the present application further includes:

[0064] Step S201b: when the first target data table is changed, obtaining a second target data table and a first calling instruction;

[0065] Step S202b: According to the first calling instruction, the calling interface changes all the version number information in the first version number management table, and obtains all the changed version number information so that the second target data table corresponds to all the changed version number information.

[0066] Specifically, when there is a data change in the first target data table, the unified encapsulated interface is called to update the version number information in the VRSNNUM table. Since the data change in the first target data table and the version number change in the VRSNNUM table are in the same transaction, it is ensured that the changed second target data table and the updated new version number maintain a corresponding relationship with each other.

[0067] Furthermore, step S202b of the embodiment of the present application further includes:

[0068] Step S202b1: obtaining second access request information, wherein the second access request information includes a second target data table;

[0069] Step S202b2: determining a second target version number from all the changed version number information according to the second access request information, wherein the second target version number corresponds to the second target data table;

[0070] Step S202b3: after accessing the first database according to the second target version number, a fourth query result is obtained;

[0071] Step S202b4: write the fourth query result into the second memory cache library and the first memory cache library in sequence, and return the fourth query result to the application node in the multi-layer cache system.

[0072] Specifically, after the data in the first target data table is changed, when the application accesses the data table, it will obtain the new version number corresponding to the table, that is, the second target version number information. When the application uses the primary key value or index value and the new version number to search for data in the first memory cache and the second memory cache respectively and fails to hit the result, it will directly access the database, write the fourth query result into the second memory cache and the first memory cache in sequence, that is, the distributed cache and the local memory cache, and send the fourth query result to the application through the application node in the multi-layer cache system. This method of passively synchronizing cache data can be called lazy loading or reactive loading.

[0073] Furthermore, step S700 of the embodiment of the present application also includes:

[0074] Step S701: when the first query result is a value hit, a fifth query result is obtained, and the fifth query result is returned to the application node in the multi-layer cache system;

[0075] Step S702: When the second query result is a value hit, a sixth query result is obtained, and the sixth query result is written into the first memory cache library, and the sixth query result is returned to the application node in the multi-layer cache system.

[0076] Specifically, when the application searches for data in the first memory cache library, i.e., the local memory cache, according to the version number, if the cached data has a numerical hit, the fifth query result is obtained, and the fifth query result is sent to the application through the application node in the multi-layer cache system; when the application searches for data in the second memory cache library, i.e., the distributed memory cache, according to the version number, if the cached data has a numerical hit, the sixth query result is obtained, and the sixth query result is sent to the application through the application node in the multi-layer cache system.

[0077] The multi-level data cache method based on version number in this embodiment can also be applied to the banking system, that is, the core business system of the bank, when actually used. Figure 3 As shown in the figure, the system adopts a distributed system architecture, a distributed database, and a multi-level cache mechanism (local memory, redis cluster, database). In this system, the data read after a transaction comes in must be consistent. The version number is used to ensure that the data reading is consistent within a transaction processing cycle. While ensuring timeliness, it also ensures the consistency of the database, redis cache, and local memory data. When there is a data update, the version number is modified synchronously, and the cached data is lazily loaded into the redis cluster and local memory cache. The multi-level cache mechanism effectively reduces the redis load, relieves the pressure on the distributed database nodes, and improves the system response efficiency.

[0078] In summary, the multi-level data caching method based on version number provided in the embodiment of the present application has the following technical effects:

[0079] Since the cache data is identified by version number, the data consistency between each layer of cache and between the cache and the database is guaranteed. Every time there is a data change in a data table, the version number in the configuration table needs to be changed synchronously. Every time the data is queried, the latest version number is used to query from the cache. If it hits, it is returned directly. If it does not hit, it penetrates the database query, returns the result, and then synchronizes the data corresponding to the latest version number to each layer of cache. At the same time, a multi-level cache data synchronization method combining preloading and lazy loading is adopted. The synchronization efficiency is high and the use is simple. It realizes the real-time consistency of multi-level cache data based on version number identification of cache data. The preloading and lazy loading methods are combined to efficiently synchronize multi-level cache data, effectively supporting the technical purpose of local dual-active in the same city or two-site three-center deployment and implementation of distributed system multi-level cache architecture.

[0080] Embodiment 2

[0081] Based on the same inventive concept as the multi-level data caching method based on version numbers in the aforementioned embodiment, the present invention also provides a multi-level data caching device based on version numbers, such as Figure 4 As shown, the device comprises:

[0082] A first configuration unit 11, the first configuration unit 11 is used to configure the first version number management table information according to a preset rule;

[0083] A first obtaining unit 12, wherein the first obtaining unit 12 is used to obtain first transaction request information;

[0084] A first loading unit 13, the first loading unit 13 is used to load all version number information in the first version number management table according to the first transaction request information;

[0085] A second obtaining unit 14, the second obtaining unit 14 is used to obtain first access request information, wherein the first access request information includes a first target data table;

[0086] A third obtaining unit 15, the third obtaining unit 15 is used to determine a first version number from all version number information loaded in the first version number management table according to the first access request information, wherein the first version number corresponds to the first target data table;

[0087] A fourth obtaining unit 16, wherein the fourth obtaining unit 16 is used to query the first data from the first memory cache library according to the first version number and obtain a first query result, wherein the first memory cache library is a local memory cache;

[0088] A fifth obtaining unit 17, wherein the fifth obtaining unit 17 is used to query the first data from the second memory cache library and obtain a second query result when the first query result is a no-value hit, wherein the second memory cache library is a distributed cache;

[0089] A sixth obtaining unit 18, wherein the sixth obtaining unit 18 is configured to obtain second access request information when the second query result is a no-value hit or an exception;

[0090] a seventh obtaining unit 19, wherein the seventh obtaining unit 19 is configured to obtain a third query result after accessing the first database according to the second access request information;

[0091] The first reading unit 20 is used to write the third query result into the second memory cache library and the first memory cache library in sequence, and return the third query result to the application node in the multi-layer cache system.

[0092] Furthermore, the device also includes:

[0093] An eighth obtaining unit, the eighth obtaining unit is used to obtain a first header name, a second header name, and a third header name, wherein the first header name and the second header name have a first association relationship;

[0094] a ninth obtaining unit, the ninth obtaining unit being used to obtain the first table content according to the first table header name, obtain the second table content according to the second table header name, and obtain the third table content according to the third table header name;

[0095] The second configuration unit is used to configure the first version number management table information according to the first header name, the first table content, the second header name, the second table content, the third header name, and the third table content.

[0096] Furthermore, the device also includes:

[0097] a tenth obtaining unit, the tenth obtaining unit being used to obtain a current time;

[0098] an eleventh obtaining unit, the eleventh obtaining unit being used to obtain first usage information when performing a daily cutting process within the current time;

[0099] A second loading unit, the second loading unit is used to preload the full amount of data in the first version number management table into the second memory cache library using the first initial version number of the current time according to the first usage information, wherein the cache data is stored in a key-value manner;

[0100] A twelfth obtaining unit, the twelfth obtaining unit is used to assign the first initial version number to the second version number by full preloading, and assign the third version number to the first initial version number, so that in the time period from the completion of full preloading to the day-cut processing, the third version number is used to access the cache, wherein the second version number is the version number corresponding to the previous time of the current time, and the third version number is the version number corresponding to the next time of the current time;

[0101] A thirteenth obtaining unit, the thirteenth obtaining unit is used to use the third version number after the daily switching process is completed.

[0102] Furthermore, the device also includes:

[0103] The second reading unit is used to read all the version number information in the first version number management table into the Map structure of the first memory cache library during the process of loading all the version number information in the first version number management table, wherein the generation rule of the version number includes the first digit accounting date, the second digit bank number, and the third digit serial number.

[0104] Furthermore, the device also includes:

[0105] a fourteenth obtaining unit, the fourteenth obtaining unit being used for obtaining a second target data table and a first calling instruction when the first target data table is changed;

[0106] A fifteenth obtaining unit is used to obtain all changed version number information after calling an interface according to the first calling instruction to change all version number information in the first version number management table, so that the second target data table and all changed version number information correspond to each other.

[0107] Furthermore, the device also includes:

[0108] a sixteenth obtaining unit, the sixteenth obtaining unit being used to obtain second access request information, wherein the second access request information includes a second target data table;

[0109] a seventeenth obtaining unit, the seventeenth obtaining unit being configured to determine a second target version number from the all changed version number information according to the second access request information, wherein the second target version number corresponds to the second target data table;

[0110] an eighteenth obtaining unit, the eighteenth obtaining unit being configured to obtain a fourth query result after accessing the first database according to the second target version number;

[0111] The third reading unit is used to write the fourth query result into the second memory cache library and the first memory cache library in sequence, and return the fourth query result to the application node in the multi-layer cache system.

[0112] Furthermore, the device also includes:

[0113] a nineteenth obtaining unit, wherein the nineteenth obtaining unit is configured to obtain a fifth query result when the first query result is a value hit, and return the fifth query result to the application node in the multi-layer cache system;

[0114] The twentieth obtaining unit is used to obtain the sixth query result when the second query result is a value hit, write the sixth query result into the first memory cache library, and return the sixth query result to the application node in the multi-layer cache system.

[0115] The foregoing Figure 1 The various variations and specific examples of a multi-level data caching method based on version numbers in Example 1 are also applicable to a multi-level data caching device based on version numbers in this embodiment. Through the above detailed description of a multi-level data caching method based on version numbers, technical personnel in this field can clearly know a multi-level data caching device based on version numbers in this embodiment, so for the sake of brevity of the specification, it will not be described in detail here.

[0116] Exemplary Electronic Devices

[0117] Reference below Figure 5 To describe the electronic device of the embodiment of the present application.

[0118] Figure 5 The figure shows a schematic structural diagram of an electronic device according to an embodiment of the present application.

[0119] Based on the inventive concept of a multi-level data caching method based on version numbers in the aforementioned embodiment, the present invention also provides a multi-level data caching device based on version numbers, on which a computer program is stored, and when the program is executed by a processor, the steps of any method of the multi-level data caching method based on version numbers described above are implemented.

[0120] Among them, Figure 5 In the embodiment of the present invention, a bus architecture (represented by bus 300) is shown, which may include any number of interconnected buses and bridges, and bus 300 links various circuits including one or more processors represented by processor 302 and memory represented by memory 304. Bus 300 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are not further described herein. Bus interface 305 provides an interface between bus 300 and receiver 301 and transmitter 303. Receiver 301 and transmitter 303 may be the same element, namely a transceiver, which provides a unit for communicating with various other devices over a transmission medium.

[0121] The processor 302 is responsible for managing the bus 300 and general processing, while the memory 304 may be used to store data used by the processor 302 when performing operations.

[0122] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0123] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (apparatus), and computer program products of the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0124] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0125] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a box or multiple boxes. Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0126] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A multi-level data caching method based on version number, applied to a multi-layer caching system, wherein: The multi-layer cache system includes a first memory cache library, a second memory cache library, and a first database, wherein the method includes: According to the preset rules, configure the first version number management table information; Obtaining first transaction request information; According to the first transaction request information, load all version number information in the first version number management table; Obtaining first access request information, wherein the first access request information includes a first target data table; Determine, according to the first access request information, a first version number from all version number information loaded in the first version number management table, wherein the first version number corresponds to the first target data table; According to the first version number, query the first data from the first memory cache library and obtain a first query result, wherein the first memory cache library is a local memory cache; When the first query result is a no-value hit, querying the first data from the second memory cache library and obtaining a second query result, wherein the second memory cache library is a distributed cache; When the second query result is no value hit or abnormal, obtaining second access request information; After accessing the first database according to the second access request information, a third query result is obtained; The third query result is written into the second memory cache library and the first memory cache library in sequence, and the third query result is returned to the application node in the multi-layer cache system.

2. The method of claim 1, wherein: The configuring the first version number management table information according to the preset rules includes: Obtain a first header name, a second header name, and a third header name, wherein the first header name and the second header name have a first association relationship; Obtain the first table content according to the first table header name, obtain the second table content according to the second table header name, and obtain the third table content according to the third table header name; The first version number management table information is configured according to the first header name, the first table content, the second header name, the second table content, the third header name, and the third table content.

3. The method of claim 1, wherein: After configuring the first version number management table information according to the preset rules, the method includes: Get the current time; When performing the daily cutting process within the current time, obtaining first usage information; According to the first usage information, using the first initial version number of the current time, preload all the data in the first version number management table into the second memory cache library, wherein the cache data is stored in a key-value manner; The first initial version number is assigned to the second version number by full preloading, and the third version number is assigned to the first initial version number, so that the third version number is used to access the cache in the period from the completion of full preloading to the day-cut processing, wherein the second version number is the version number corresponding to the previous time of the current time, and the third version number is the version number corresponding to the next time of the current time; After the daily switching process is completed, the third version number is used.

4. The method of claim 1, wherein: After obtaining the first transaction request information, the method further includes: In the process of loading all the version number information in the first version number management table, all the version number information is read into the Map structure of the first memory cache library, wherein the generation rule of the version number includes the first digit accounting date, the second digit bank number, and the third digit serial number.

5. The method of claim 1, wherein: After obtaining the first transaction request information, the method further includes: When the first target data table is changed, obtaining a second target data table and a first calling instruction; According to the first calling instruction, the calling interface changes all the version number information in the first version number management table, and then obtains all the changed version number information, so that the second target data table corresponds to all the changed version number information.

6. The method of claim 5, wherein: The method further comprises: Obtaining second access request information, wherein the second access request information includes a second target data table; Determine, according to the second access request information, a second target version number from among all the changed version number information, wherein the second target version number corresponds to the second target data table; After accessing the first database according to the second target version number, a fourth query result is obtained; The fourth query result is written into the second memory cache library and the first memory cache library in sequence, and the fourth query result is returned to the application node in the multi-layer cache system.

7. The method of claim 1, wherein: The method further comprises: When the first query result is a value hit, a fifth query result is obtained, and the fifth query result is returned to the application node in the multi-layer cache system; When the second query result is a value hit, a sixth query result is obtained, and the sixth query result is written into the first memory cache library, and the sixth query result is returned to the application node in the multi-layer cache system.

8. A multi-level data cache device based on version number, applied to a multi-layer cache system, wherein: The multi-layer cache system includes a first memory cache library, a second memory cache library, and a first database. Wherein, the device comprises: A first configuration unit, the first configuration unit is used to configure the first version number management table information according to a preset rule; A first obtaining unit, wherein the first obtaining unit is used to obtain first transaction request information; a first loading unit, configured to load all version number information from the first version number management table according to the first transaction request information; a second obtaining unit, the second obtaining unit being configured to obtain first access request information, wherein the first access request information includes a first target data table; a third obtaining unit, configured to determine a first version number from all version number information in the loaded first version number management table according to the first access request information, wherein the first version number corresponds to the first target data table; a fourth obtaining unit, the fourth obtaining unit being used to query first data from the first memory cache library according to the first version number, and obtain a first query result, wherein the first memory cache library is a local memory cache; a fifth obtaining unit, wherein when the first query result is a no-value hit, the fifth obtaining unit is used to query the first data from the second memory cache library and obtain a second query result, wherein the second memory cache library is a distributed cache; a sixth obtaining unit, configured to obtain second access request information when the second query result is a no-value hit or an exception; a seventh obtaining unit, configured to obtain a third query result after accessing the first database according to the second access request information; The first reading unit is used to write the third query result into the second memory cache library and the first memory cache library in sequence, and return the third query result to the application node in the multi-layer cache system.

9. A multi-level data cache device based on version numbers, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Data processing method and system based on multi-level cache, device and storage medium

    CN109388656A

  • Configuration management method, system and device

    CN110597739A

  • Distributed cache system, associated query and update method and device, and storage medium

    CN111723110A

  • Distributed cache management method based on version control and manager

    CN111858556A

  • Backup and restore in a distributed database utilizing consistent database snapshots

    US20160306709A1