Data query method and device, equipment, storage medium and product
By using a three-tier caching architecture and adjusting data popularity information, the problem that a single-tier caching architecture cannot balance access speed and data sharing is solved, achieving efficient data querying and storage resource optimization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-03-10
AI Technical Summary
Existing single-layer caching architectures cannot balance access speed and data sharing requirements. Especially when dealing with hot data, simple local caching poses risks of data inconsistency and wastes memory resources, while distributed caching becomes a performance bottleneck in high-concurrency scenarios.
A three-tier caching architecture is adopted, including local memory caching, node-level caching shared by multiple processes, and global distributed caching shared across all nodes. Querying is performed level by level to balance access speed and data sharing. Data that is not found in the database is cached, and the storage location is adjusted based on data popularity information.
It achieves the goal of meeting data sharing needs while ensuring access speed, improves data query efficiency, reduces network overhead and resource competition, and optimizes storage resource utilization.
Smart Images

Figure CN121636563A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a data query method and device, equipment, a storage medium and a product. BACKGROUND
[0002] In data caching, the related art usually adopts a single-layer cache architecture, which mainly includes: local memory caching: for example, using components such as Caffeine and Guava Cache to cache data in the memory of an application process, which has the advantage of extremely fast access speed and no network overhead. However, the disadvantage is that cached data cannot be shared among multiple nodes in a cluster, there is a risk of data inconsistency, and memory resources are wasted; distributed caching: for example, using a Redis cluster. It solves the problem of data sharing and consistency among multiple nodes, but its defect is that all data reading and writing need to go through network communication, which will become a performance bottleneck in high-concurrency and extremely sensitive delay scenarios.
[0003] In summary, the existing single-layer cache solution cannot meet the needs of access speed and data sharing, especially when it comes to hot data (data frequently accessed by multiple nodes in a cluster), neither pure local caching nor distributed caching is efficient. SUMMARY
[0004] The main purpose of the present application is to provide a data query method, device, equipment, storage medium and product, which aims to solve the technical problem that the existing single cache architecture cannot meet the needs of access speed and data sharing.
[0005] To achieve the above purpose, the present application provides a data query method, which is applied to a data query system, the data query system includes at least three cache levels: a local memory cache, a node-level cache shared by multiple processes, and a global distributed cache shared by all nodes, and the data query method includes the following steps: In response to a data query request, data is queried in the local memory cache based on the data query request to obtain a first query result; In the case that the first query result is no data queried, data is queried in the node-level cache according to the data query request to obtain a second query result; In the case that the second query result is no data queried, data is queried in the global distributed cache according to the data query request to obtain a third query result.
[0006] Optionally, after the step of querying data in the global distributed cache according to the data query request to obtain a third query result in the case that the second query result is no data queried, the method further includes: In a case where the third query result is no data, data in the database is queried according to the data query request to obtain a target query result; The data query request is responded based on the target query result, and the target query result is fed back to the global distributed cache, the node-level cache and the local memory cache for storage.
[0007] Optionally, after the step of querying data in the database according to the data query request to obtain a target query result in a case where the third query result is no data, the method further comprises: Obtaining data query information, and determining data query times of each data based on the data query information; Determining data heat information according to the data query times; Determining data storage positions of each data based on the data heat information, wherein the data storage positions comprise the global distributed cache, the node-level cache, the local memory cache or the database.
[0008] Optionally, the step of determining the data storage positions of each data based on the data heat information comprises: Obtaining data storage position reference thresholds corresponding to each cache level; Determining the data storage positions based on the data query times in the data heat information and the data storage position reference thresholds.
[0009] Optionally, after the step of determining the data storage positions of each data based on the data heat information, the method further comprises: Obtaining actual storage positions of the data; Adjusting the storage positions of the data based on the data storage positions and the actual storage positions.
[0010] Optionally, after the step of querying data in the node-level cache according to the data query request to obtain a second query result in a case where the first query result is no data, the method further comprises: In a case where the second query result is data, the data query request is responded based on the queried data, and the queried data is fed back to the local memory cache for storage.
[0011] In addition, to achieve the above object, the application further provides a data query device, which comprises at least three cache levels: a local memory cache, a node-level cache shared by multiple processes, and a global distributed cache shared by all nodes, and comprises: The first query module is configured to perform data query in the local memory cache based on the data query request and obtain a first query result. The second query module is configured to perform data query in the node-level cache based on the data query request and obtain a second query result when the first query result is no data. The third query module is configured to perform data query in the global distributed cache based on the data query request and obtain a third query result when the second query result is no data.
[0012] In addition, to achieve the above-mentioned purposes, the present application further provides a data query device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the data query method as described above.
[0013] In addition, to achieve the above-mentioned purposes, the present application further provides a storage medium, which is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the data query method as described above.
[0014] In addition, to achieve the above-mentioned purposes, the present application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps of the data query method as described above.
[0015] The present application performs data query in the local memory cache based on the data query request and obtains a first query result. When the first query result is no data, the present application performs data query in the node-level cache based on the data query request and obtains a second query result. When the second query result is no data, the present application performs data query in the global distributed cache based on the data query request and obtains a third query result. Since the present application comprises a local memory cache, a node-level cache shared by multiple processes, and a global distributed cache shared by all nodes, and starts querying from the local memory cache when querying data, the above-mentioned method of the present application can meet the demand of data sharing while taking into account the access speed, compared with the existing single-layer cache architecture. BRIEF DESCRIPTION OF DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without any creative effort.
[0018] Figure 1 The flowchart provided by the data query method embodiment one of the present application; Figure 2 The flowchart provided by the data query method embodiment two of the present application; Figure 3 The module structure diagram of the data query device of the present application embodiment; Figure 4 The device structure diagram of the hardware running environment involved in the data query method of the present application embodiment.
[0019] The purpose realization, functional features and advantages of the present application will be further explained with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0020] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application, and are not used to limit the present application.
[0021] In order to better understand the technical solutions of the present application, the following will be described in detail with reference to the drawings and specific embodiments in the specification.
[0022] The main solution of the present application embodiment is: in response to a data query request, data query is performed in the local memory cache based on the data query request, and a first query result is obtained; in the case that the first query result is no data queried, data query is performed in the node level cache according to the data query request, and a second query result is obtained; in the case that the second query result is no data queried, data query is performed in the global distributed cache according to the data query request, and a third query result is obtained. Since the present application includes local memory cache, multi-process shared node level cache and global distributed cache shared by all nodes, and the data query starts from the local memory cache and queries upwards step by step, compared with the existing single layer cache architecture, the above-mentioned method of the present application can meet the demand of data sharing while taking into account the access speed.
[0023] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as tablet computer, personal computer, mobile phone, etc., or an electronic device, data query system, etc. which can realize the above functions. The present embodiment and the following embodiments will be described taking the data query system as an example.
[0024] Based on this, the embodiment of the present application provides a data query method, referring to Figure 1 , Figure 1 a flowchart provided by the first embodiment of the data query method of the present application.
[0025] In the embodiment, the data query method is applied to a data query system, the data query system includes at least three cache levels: a local memory cache, a multi-process shared node-level cache, and a global distributed cache shared across all nodes, and the data query method includes the following steps: Step S10, in response to a data query request, performing data query in the local memory cache based on the data query request to obtain a first query result; It should be noted that the data query request can be a command triggered by a user to query data. When the data query system receives the data query request, it first performs data query in its own local memory cache. If it hits, that is, relevant data is queried, the data is directly returned to the front end. If it does not hit, that is, data is not queried, it needs to query the upper-level cache node. If the data corresponding to the data query request is hot data, it can be stored in the local memory cache, otherwise, it can be stored in the multi-process shared node-level cache, the global distributed cache shared across all nodes, and the database.
[0026] Step S20, in the case that the first query result is no data, performing data query in the node-level cache according to the data query request to obtain a second query result; It should be noted that the node-level cache can be a cache deployed on a single computing node (such as a server, an application instance, a container, or a virtual machine). It usually provides a local fast access data copy for the application program on the node, which is only valid within the node. In the case that the first query result is no data, data query needs to be performed on the upper-level storage node. The upper-level storage node of the local memory cache is the multi-process shared node-level cache. Therefore, in the case that the first query result is no data, data query is performed in the node-level cache according to the data query request. If it hits, that is, relevant data is queried, the data is returned. If it does not hit, that is, data is not queried, it needs to query the upper-level cache node. The process of returning data can be to return the queried data to the user and to return the queried data to the local memory cache asynchronously, so that the local memory cache stores the data, and the data can be queried in the local memory cache next time.
[0027] Step S30, in the case that the second query result is no data queried, data is queried in the global distributed cache according to the data query request, and a third query result is obtained.
[0028] It should be noted that the global distributed cache can be a cache system deployed on multiple nodes / servers but providing services as a whole. It is shared by all application nodes and is usually managed by a dedicated cache service cluster, providing a unified access interface. In the case that the second query result is no data queried, data needs to be queried from the upper-level storage node. The upper-level storage node of the multi-process shared node-level cache is the global distributed cache. Therefore, in the case that the second query result is no data queried, data is queried in the global distributed cache according to the data query request. If hit, that is, relevant data is queried, the data is returned. If not hit, that is, no data is queried, the upper-level cache node needs to be queried. The process of returning data can be returning the queried data to the user and asynchronously returning the queried data to the local memory cache and / or the node-level cache, so that the local memory cache and / or the node-level cache store the data.
[0029] The embodiment responds to a data query request, queries data in the local memory cache based on the data query request, and obtains a first query result. In the case that the first query result is no data queried, data is queried in the node-level cache according to the data query request, and a second query result is obtained. In the case that the second query result is no data queried, data is queried in the global distributed cache according to the data query request, and a third query result is obtained. Since the embodiment includes the local memory cache, the multi-process shared node-level cache, and the global distributed cache shared across all nodes, and queries data from the local memory cache and upwards in the case of data query, compared with the existing single-layer cache architecture, the above-mentioned manner of the embodiment can meet the data sharing requirement while taking into account the access speed.
[0030] Based on the first embodiment of the application, in the second embodiment of the application, the same or similar contents as the above-mentioned first embodiment can be referred to the above introduction, and will not be described in detail. On this basis, please refer to Figure 2 , Figure 2 The flowchart provided for the second embodiment of the data query method of the application includes the following steps after step S30: Step S40: in the case that the third query result is no data queried, data is queried in the database according to the data query request, and a target query result is obtained. It should be noted that the database is a system for persistently storing data, and is the ultimate data source of most applications. When the cache is not hit, data is read from the database and backfilled into the cache.
[0031] In the case that the third query result is no data, data query needs to be performed on the upper level storage node, and the upper level storage node of the global distributed cache is the database. Therefore, in the case that the third query result is no data, data query is performed in the database according to the data query request, a target query result is obtained, the target query result is returned to the user, and the target query result is returned to the global distributed cache, the local memory cache and / or the node level cache for caching in an asynchronous manner.
[0032] Step S50: responding to the data query request based on the target query result, and feeding back the target query result to the global distributed cache, the node level cache and the local memory cache for storage.
[0033] It should be noted that, in order to improve the data query efficiency, the data queried in the database is stored in the global distributed cache, the node level cache and the local memory cache in sequence in the embodiment, so that the data can be queried earlier in the next data query, and the data query efficiency is improved. Further, in order to avoid waste of data storage space, after the step S40, the method further includes: acquiring data query information, determining the data query times of each data based on the data query information; determining the data query times of each data based on the data query information; determining the data storage positions of each data based on the data heat information, the data storage positions including the global distributed cache, the node level cache, the local memory cache or the database.
[0034] It should be noted that each time the data is queried, the data query information is counted, and the data query information includes the data query information in the local memory cache, the node-level cache, and the global distributed cache. For example, when data is queried in the local memory cache, the data to be queried and the query time are recorded. When data is queried in the node-level cache, the data to be queried and the query time are also recorded. The data query information is reported to a unified data analysis module for data analysis, which is used to determine the specific storage location of the data. The data analysis can be triggered according to a pre-set analysis period, for example, when the current analysis period is detected, the data analysis is triggered, and the data query times of each data in the period are determined according to the data query information. The data hotness information can be determined according to the data query times, that is, the more the data query times, the higher the data hotness. The data storage location of each data can be determined based on the data hotness information, that is, the higher the data hotness, the more conducive the storage location to data query. The storage hierarchy of data can be divided into local memory cache, node-level cache, global distributed cache, and database. The higher the data hotness, the higher the storage hierarchy.
[0035] The step of determining the data storage location of each data based on the data hotness information comprises: Obtaining the data storage location reference threshold corresponding to each level of cache; Determining the data storage location based on the data query times in the data hotness information and the data storage location reference threshold.
[0036] It should be noted that a data storage location reference threshold can be set for each storage hierarchy to determine the storage hierarchy of the data, for example, the query times threshold of the local memory cache is 100, when the query times of the data in the analysis period is greater than or equal to 100, it is determined that the data is stored in the local memory cache; the query times threshold of the node-level cache is 60, when the query times of the data in the analysis period is greater than or equal to 60 but less than 100, it is determined that the data is stored in the node-level cache; the query times threshold of the global distributed cache is 30, when the query times of the data in the analysis period is greater than or equal to 30 but less than 60, it is determined that the data is stored in the global distributed cache, and the rest of the data is stored in the database. After determining the actual storage location of the data, the data is stored in the corresponding actual storage location, and the data stored in other locations is deleted.
[0037] To reasonably determine the storage location of each data point, this embodiment can also determine it based on the ranking of data query counts within the current analysis period and the available storage space at each storage level. The ranking result can further include the storage space required for storing data ranked higher than the current data point, calculated based on the data volume. For example, if storing the data with the highest query count requires 10 storage spaces, then the required storage space for the first-ranked data is 10; if storing the data with the second-highest query count requires 8 storage spaces, then the required storage space for the second-ranked data is 10 + 8, and so on, calculating the storage space required for storing data at each ranking. Finally, the actual storage space for each data point is determined based on the available space for data storage in local memory cache, node-level cache, and global distributed cache.
[0038] In practical implementation, when the business application of the data query system receives a data query request, it first searches for data in its own L1 local memory cache. If the data is found, it is returned directly. If the data is not found in L1, it searches for data in the L2 node-level cache of the node where it resides. If the data is found, it is returned to the application and asynchronously loaded into L1 for faster access next time. If the data is still not found in L2, it searches for data in the L3 global distributed cache. If the data is found, it is returned to the application and asynchronously loaded into L2 and L1. If the data is also not found in L3, it loads data from the final database, returns the data to the application, and asynchronously writes it to the L3, L2, and L1 caches in sequence. During each query process, the data access analysis module (i.e., the data analysis module mentioned above) records the access events of the corresponding data.
[0039] The data access analysis module periodically (e.g., every minute) aggregates access information (i.e., data query information) reported by all cache layers, identifying "hot data" (access frequency continuously increasing) and "cold data" (data not accessed for a long time). Then, an intelligent scheduler makes scheduling decisions, including: data promotion: When the scheduler detects that certain data is frequently accessed in L3 or L2 (the number of accesses may exceed the reference threshold for the corresponding data storage location in L3 or L2), becoming a hot data point, it proactively preloads this data into a higher-level cache. For example, it might push globally hot data from L3 to the L2 cache of all nodes, or even to the L1 cache of a specific node.
[0040] Data Demotion: When the scheduler detects a significant decrease in the access frequency of data in L1 or L2, indicating it has become cold data (i.e., the number of data queries is lower than the reference threshold for the data storage location of the corresponding storage node), it will evict it from the higher-level cache to free up valuable local or node memory. This data remains in L3. In this embodiment, the intelligent scheduler no longer passively waits for cache invalidation but actively and dynamically performs "promotion" or "demotion" operations on data across the three cache layers based on the real-time access frequency, achieving optimal data layout in the cache system. This embodiment can significantly reduce access latency: through intelligent scheduling, hot data is promoted to L1 or L2 cache, and most high-frequency accesses can be completed directly locally or within the node, avoiding the latency overhead of cross-network access to the L3 cache; it also significantly improves cache hit rate: the hierarchical structure and the "load if miss (caching data to a lower-level cache node)" mechanism increase the probability of data retention throughout the entire cache system. Hot data is accurately retained in high-level caches, significantly improving the overall hit rate; reducing network overhead and resource contention: hot data is hit in L1 and L2, effectively reducing the request pressure on the L3 global distributed cache and network bandwidth consumption, while also reducing the load on the backend database; achieving efficient use of resources: precious and limited local memory (L1) and node memory (L2) are used only to store truly hot data, while cold data is downgraded or discarded, achieving optimal and fine-grained management of storage resources.
[0041] In this embodiment, when the third query result is no data found, a data query is performed in the database according to the data query request to obtain the target query result. Based on the target query result, the data query request is responded to, and the target query result is fed back to the global distributed cache, the node-level cache, and the local memory cache for storage. The three-layer caching structure proposed in this embodiment explicitly divides the memory-level cache into three layers: "local memory cache - node-level cache - global distributed cache". This structure balances the ultimate performance of local access, data sharing within nodes, and global data consistency, forming a tiered caching solution that improves data access speed while ensuring data sharing.
[0042] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the data query method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0043] This application also provides a data query device, please refer to... Figure 3The data query device includes at least three caching levels: local memory cache, multi-process shared node-level cache, and global distributed cache shared across all nodes. The first query module 10 is used to respond to a data query request, perform a data query in the local memory cache based on the data query request, and obtain a first query result; The second query module 20 is used to perform a data query in the node-level cache according to the data query request when the first query result is that no data is found, and obtain a second query result. The third query module 30 is used to perform a data query in the global distributed cache according to the data query request when the second query result is that no data is found, so as to obtain a third query result.
[0044] In this embodiment, in response to a data query request, a data query is performed in the local memory cache based on the data query request to obtain a first query result. If the first query result indicates that no data was found, a data query is performed in the node-level cache according to the data query request to obtain a second query result. If the second query result indicates that no data was found, a data query is performed in the global distributed cache according to the data query request to obtain a third query result. Because this embodiment includes a local memory cache, a multi-process shared node-level cache, and a globally distributed cache shared across all nodes, and queries data level by level upwards starting from the local memory cache, compared to existing single-layer caching architectures, the above method in this embodiment can meet the data sharing requirements while maintaining access speed.
[0045] The data query device provided in this application, employing the data query method described in the above embodiments, can solve the technical problem that existing single-caching architectures cannot simultaneously meet the requirements of access speed and data sharing. Compared with the prior art, the beneficial effects of the data query device provided in this application are the same as those of the data query method provided in the above embodiments, and other technical features in the data query device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0046] This application provides a data query device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the data query method in Embodiment 1 above.
[0047] The following is for reference. Figure 4The diagram illustrates a structural schematic of a data query device suitable for implementing embodiments of this application. The data query device in this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The data query device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0048] like Figure 4 As shown, the data query device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the data query device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the data query device to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show data query devices with various systems, it should be understood that it is not required to implement or possess all of the systems shown. More or fewer systems may be implemented alternatively.
[0049] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0050] The data query device provided in this application, employing the data query method described in the above embodiments, can solve the technical problem that existing single-caching architectures cannot simultaneously meet the requirements of access speed and data sharing. Compared with the prior art, the beneficial effects of the data query device provided in this application are the same as those of the data query method provided in the above embodiments, and other technical features of this data query device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0051] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0052] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0053] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the data query method in the above embodiments.
[0054] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0055] The aforementioned computer-readable storage medium may be included in the data query device; or it may exist independently and not assembled into the data query device.
[0056] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof. These programming languages include object-oriented programming languages—such as Python, Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0057] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0058] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0059] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described data query method. This solves the technical problem that existing single-cache architectures cannot simultaneously meet the requirements of access speed and data sharing. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the data query method provided in the above embodiments, and will not be repeated here.
[0060] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the data query method described above.
[0061] The computer program product provided in this application can solve the technical problem that existing single-cache architectures cannot simultaneously meet the requirements of access speed and data sharing. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the data query method provided in the above embodiments, and will not be repeated here.
[0062] The above description is only a part of the embodiments of this application and does not limit the scope of protection of this application. All equivalent structural transformations made under the technical concept of this application and using the content of this application specification and drawings, or direct / indirect applications in other related technical fields, are included in the scope of protection of this application.
Claims
1. A data query method, characterized by, The data query method is applied to a data query system including at least three cache levels: a local memory cache, a node-level cache shared by multiple processes, and a global distributed cache shared across all nodes. In response to a data query request, data is queried in the local memory cache based on the data query request to obtain a first query result. In a case where the first query result is no data, data is queried in the node-level cache based on the data query request to obtain a second query result. In a case where the second query result is no data, data is queried in the global distributed cache based on the data query request to obtain a third query result.
2. The data query method of claim 1, wherein, In a case where the third query result is no data, data is queried in a database based on the data query request to obtain a target query result. The data query request is responded to based on the target query result, and the target query result is fed back to the global distributed cache, the node-level cache, and the local memory cache for storage. In a case where the third query result is no data, data is queried in a database based on the data query request to obtain a target query result.
3. The data query method of claim 2, wherein, Data query information is obtained, and the data query times of each data are determined based on the data query information. Data heat information is determined based on the data query times. Data storage locations of each data are determined based on the data heat information, and the data storage locations include the global distributed cache, the node-level cache, the local memory cache, or the database. The step of determining the data storage locations of each data based on the data heat information includes:
4. The data query method of claim 3, wherein, Data storage location reference thresholds corresponding to each cache level are obtained. Data storage locations are determined based on the data query times in the data heat information and the data storage location reference thresholds. The step of determining the data storage locations of each data based on the data heat information includes:
5. The data query method of claim 3, wherein, Actual storage locations of the data are obtained. The data storage locations are adjusted based on the data storage locations and the actual storage locations. In a case where the second query result is data, the data query request is responded to based on the queried data, and the queried data is fed back to the local memory cache for storage.
6. The data query method of any one of claims 1-5, wherein, The data query device includes at least three cache levels: a local memory cache, a node-level cache shared by multiple processes, and a global distributed cache shared across all nodes. 7. A data query apparatus, characterized by comprising: The first query module is configured to perform data query in the local memory cache based on the data query request and obtain a first query result in response to the data query request. The second query module is configured to perform data query in the node-level cache based on the data query request and obtain a second query result in a case where the first query result is no data. The third query module is configured to perform data query in the global distributed cache based on the data query request and obtain a third query result in a case where the second query result is no data.
8. A data query device, characterized by The device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the data query method according to any one of claims 1 to 6.
9. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the data query method according to any one of claims 1 to 6.
10. A computer program product, characterised in that, The computer program product comprises a computer program, and the computer program is executed by a processor to implement the steps of the data query method according to any one of claims 1 to 6.