Data query method and device, electronic equipment and storage medium
By optimizing multi-level caching and intelligent retrieval, the problem of slow response speed for large-scale front-end queries has been solved, achieving fast response and efficient querying, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-03-27
AI Technical Summary
Existing technologies often result in slow response times for large-scale front-end queries, especially in high-concurrency environments. This leads to high server resource consumption, severe query latency, and negatively impacts user experience and system performance.
A multi-level caching query method is adopted, first querying the client cache, then the server cache if no match is found, and finally performing a fuzzy search in the server memory. This method combines intelligent retrieval and memory keyword fast search techniques to optimize cached content and query strategies.
It significantly improves the front-end data query response speed, maintains consistency in query performance and user experience, reduces server load, and optimizes application performance in high data traffic scenarios.
Smart Images

Figure CN121743358A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of big data technology or other related fields. Specifically, it relates to a data query method and apparatus, electronic device, and storage medium. Background Technology
[0002] In the context of digital transformation, the real-time processing of massive amounts of data in the financial sector has become crucial for efficient business operations. This data is not only enormous in quantity but also contains complex and varied structures and types. However, existing front-end data query technologies face significant challenges.
[0003] For small datasets, client-side or page caching is sufficient for fast queries. However, traditional query methods fall short when dealing with hundreds of thousands or even millions of data points. Due to the massive data volume and the fuzziness of query conditions, direct SQL queries on the server-side database encounter significant latency, severely impacting user experience and overall system performance. Especially in high-concurrency environments, each query request consumes server resources, and frequent disk I / O operations not only slow down queries but also increase the burden on the database. Furthermore, as data is constantly updated and grown, database index optimization becomes increasingly difficult, making it hard to continuously improve the efficiency of fuzzy queries. Related technologies suffer from slow response times for large-scale front-end queries.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] The main objective of this application is to provide a data query method, apparatus, electronic device, and storage medium to at least solve the technical problem of slow response speed for front-end large data volume queries in related technologies.
[0006] To achieve the above objectives, according to one aspect of this application, a data query method is provided, the method comprising: receiving a data query request and query conditions; accessing a client cache based on the query conditions, and generating a data query result based on the first access result if the returned first access result is not empty; accessing a server cache based on the query conditions if the first access result is empty, and generating a data query result based on the second access result if the returned second access result is not empty; and accessing server memory based on the query conditions if the second access result is empty, and generating a data query result based on the returned third access result.
[0007] Further, the step of accessing the client cache based on the query conditions includes: traversing the client cache, matching each piece of client cache data with the query conditions; copying the successfully matched client cache data to obtain the first access result; and in the case of a failed match, setting the first access result to null and sending the data query request and query conditions to the server.
[0008] Furthermore, after generating a data query result based on the first access result, the data query method further includes: if the first access result is not empty, locating the first type of access timestamp of the client cache data corresponding to the first access result in the client cache, and updating the first type of access timestamp based on the current timestamp.
[0009] Further, the step of accessing the server cache based on the query conditions includes: traversing the server cache, matching each piece of server cache data with the query conditions; constructing the second access result in the form of a key-value pair using the successfully matched server cache data as the value and the query conditions as the key; and setting the second access result to null if the matching fails.
[0010] Furthermore, after generating a data query result based on the second access result, the data query method further includes: if the second access result is not empty, locating the second type of access timestamp of the server cache data corresponding to the second access result in the server cache, and updating the second type of access timestamp based on the current timestamp; updating the access frequency counter related to the server cache data corresponding to the second access result; copying the second access result as new client cache data, and determining the current timestamp as the first type of access timestamp of the new client cache data, and storing it in the client cache; if the client cache exceeds the storage capacity, removing the client cache data with the earliest first type of access timestamp.
[0011] Further, the step of accessing server memory based on the query conditions includes: dividing the server memory into N memory shards based on the query conditions, and obtaining a set of memory keywords for each memory shard, where N is a positive integer; for each memory shard, performing keyword retrieval in each set of memory keywords based on the query conditions, and locating target memory data from the memory shard based on the retrieved target keywords; copying the target memory data to obtain the third access result.
[0012] Furthermore, after generating the data query result based on the returned third access result, the data query method further includes: copying the third access result into new server-side cache data and new client-side cache data, and determining the current timestamp as a first type of access timestamp and a second type of access timestamp; associating the new client-side cache data with the first type of access timestamp and storing it in the client cache, associating the new server-side cache data with the second type of access timestamp and storing it in the server cache, and setting an access frequency counter for the new server-side cache data; if the server cache exceeds the storage capacity, removing the server-side cache data with the earliest second type of access timestamp, or removing the server-side cache data with the least access frequency based on the access frequency counter.
[0013] To achieve the above objectives, according to another aspect of this application, a data query apparatus is also provided. The apparatus includes: a receiving unit for receiving a data query request and query conditions; a first generating unit for accessing a client cache based on the query conditions, and generating a data query result based on the first access result if the returned first access result is not empty; a second generating unit for accessing a server cache based on the query conditions if the first access result is empty, and generating a data query result based on the second access result if the returned second access result is not empty; and a third generating unit for accessing server memory based on the query conditions if the second access result is empty, and generating a data query result based on the returned third access result.
[0014] Further, the first generation unit includes: a first matching module, used to traverse the client cache and match each piece of client cache data with the query conditions; a first copying module, used to copy the successfully matched client cache data to obtain the first access result; and a first emptying module, used to empty the first access result and send the data query request and query conditions to the server if the matching fails.
[0015] Furthermore, the data query device includes: a first update module, configured to, after generating a data query result based on the first access result, locate the first type of access timestamp of the client cache data corresponding to the first access result in the client cache if the first access result is not empty, and update the first type of access timestamp based on the current timestamp.
[0016] Further, the second generation unit includes: a second matching module, used to traverse the server cache and match each piece of server cache data with the query condition; a construction module, used to construct the second access result in key-value pair form using the successfully matched server cache data as the value and the query condition as the key; and a second empty module, used to empty the second access result in the event of a matching failure.
[0017] Furthermore, the data query device further includes: a second update module, configured to, after generating a data query result based on the second access result, locate the second type of access timestamp of the server cache data corresponding to the second access result in the server cache when the second access result is not empty, and update the second type of access timestamp based on the current timestamp; a third update module, configured to update the access frequency counter related to the server cache data corresponding to the second access result; a second copy module, configured to copy the second access result as new client cache data, and determine the current timestamp as the first type of access timestamp of the new client cache data, and associate and store it in the client cache; and a first removal module, configured to remove the client cache data with the earliest first type of access timestamp when the client cache exceeds the storage capacity.
[0018] Further, the third generation unit includes: a sharding module, used to shard the server memory based on query conditions to obtain N memory shards, and obtain a set of memory keywords for each memory shard, where N is a positive integer; a retrieval module, used to perform keyword retrieval in each set of memory keywords for each memory shard based on the query conditions, and locate target memory data from the memory shard based on the retrieved target keywords; and a third copying module, used to copy the target memory data to obtain the third access result.
[0019] Furthermore, the data query device further includes: a determining module, configured to, after generating a data query result based on the returned third access result, copy the third access result into new server-side cache data and new client-side cache data, and determine the current timestamp as a first type of access timestamp and a second type of access timestamp; a setting module, configured to associate the new client-side cache data with the first type of access timestamp and store it in the client cache, associate the new server-side cache data with the second type of access timestamp and store it in the server cache, and set an access frequency counter for the new server-side cache data; and a second removal module, configured to, when the server cache exceeds the storage capacity, remove the server-side cache data with the earliest second type of access timestamp, or remove the server-side cache data with the least access frequency based on the access frequency counter.
[0020] To achieve the above objectives, according to another aspect of this application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the data query method described in any one of the above claims.
[0021] To achieve the above objectives, according to another aspect of this application, an electronic device is also provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the data query method described in any of the above claims.
[0022] To achieve the above objectives, according to another aspect of this application, a computer program product is also provided, including computer instructions, wherein when the computer instructions are executed by a processor, they implement the steps of the data query method described in any one of the above claims.
[0023] This invention proposes a data query method. First, it receives a data query request and query conditions. Then, it accesses the client cache based on the query conditions. If the first access result is not empty, it generates a data query result based on the first access result. If the first access result is empty, it accesses the server cache based on the query conditions. If the second access result is not empty, it generates a data query result based on the second access result. Finally, if the second access result is empty, it accesses the server memory based on the query conditions and generates a data query result based on the returned third access result.
[0024] This invention employs a multi-level caching query combined with intelligent retrieval. Through a carefully designed client-side and server-side caching mechanism and an efficient memory keyword fast search method, it achieves a significant improvement in the front-end data query response speed. This enables the technical effect of maintaining consistent query performance and user experience in a big data environment, thereby solving the technical problem of slow response speed for large-scale front-end queries in related technologies.
[0025] Specifically, upon receiving a data query request and its accompanying query conditions, this invention first searches for matching records using the client's local storage. If a match is found, the query result can be directly fed back to the user in a very short time, avoiding lengthy network transmission and server processing time. If the initial match fails, a secondary search is performed using the server-side cache, attempting to match recent popular queries stored on the server. If the secondary match is successful, the query result can also be fed back to the user in a short response time. Only when both caches fail is the fuzzy query index in the server's memory triggered. Through algorithm optimization and data structure design, the final query is ensured to be as efficient and fast as possible, minimizing the latency of traditional database queries. This progressive query strategy shortens the data search path, improves query speed, and ultimately provides users with an instant response experience, significantly improving the performance of front-end applications in high-data-traffic scenarios and overcoming the bottlenecks of existing technologies. Attached Figure Description
[0026] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0027] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a data query method is shown.
[0028] Figure 2 This is a flowchart of an optional data query method according to an embodiment of the present invention;
[0029] Figure 3 This is a schematic diagram of an optional three-layer fuzzy data query matching mechanism according to an embodiment of the present invention;
[0030] Figure 4 This is a schematic diagram of an optional data query device according to an embodiment of the present invention;
[0031] Figure 5 This is a structural block diagram of an electronic device for performing a data query method according to an embodiment of the present invention. Detailed Implementation
[0032] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] To facilitate understanding of the present invention by those skilled in the art, some terms or nouns involved in the various embodiments of the present invention are explained below:
[0035] Fuzzy search is a data query method that allows users to input incomplete or partial matching keywords for retrieval. It is the opposite of exact search and is suitable for scenarios where users have vague memories or where the search conditions are complex and varied.
[0036] It should be noted that the data query method and apparatus in this application can be used in the field of big data technology for fast fuzzy query of massive front-end data, and can also be used in any field other than big data technology for fast fuzzy query of massive front-end data. This application does not limit the application field of the data query method and apparatus.
[0037] It should be noted that all relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data) involved in this application are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, processing, transmission, provision, disclosure, use, and handling of such data comply with the laws, regulations, and standards of the relevant regions, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding access points are provided for users to choose to authorize or refuse access. For example, this system has interfaces with relevant users or organizations. Before obtaining relevant information, a request to obtain the information needs to be sent to the aforementioned user or organization through the interface, and the relevant information is obtained only after receiving consent from the aforementioned user or organization.
[0038] The information collection (e.g., user voice, video, and text collection) and analysis operations involved in this application have provided users with corresponding operation entry points during execution, allowing users to choose to agree to or reject the automated decision results; if the user chooses to reject, the process will proceed to the expert decision-making process.
[0039] The following embodiments of the present invention can be applied to various systems / applications / devices that require optimization of front-end large-scale data queries and improved query response speed, enabling fast data query products based on multi-level caching and in-memory keyword fast lookup. The present invention uses client-side caching to locally store and quickly retrieve recent queries, and then searches the server-side cache for queries that did not hit the client-side cache. This allows for better capture and utilization of recent hot queries, while simultaneously performing precise matching of query conditions to reduce the frequency of direct access to server memory. Through this multi-level caching and sharded concurrent query strategy, the present invention not only significantly improves query efficiency but also effectively alleviates the pressure on backend resources in high-concurrency scenarios, ensuring the stability and efficiency of the data query process.
[0040] This invention also employs a strategy of dynamically maintaining cached content to accurately locate and update frequently queried data, intelligently instrumenting and caching data queries, making testing and application convenient and quick, and providing rapid and accurate location and return of query results. It offers an efficient and practical query solution for front-end applications with large data volumes.
[0041] The present invention will now be described in detail with reference to various embodiments.
[0042] Example 1
[0043] According to an embodiment of the present invention, an embodiment of a data query method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0044] The data query method embodiment provided in Embodiment 1 of the present invention can be executed on a mobile terminal, computer terminal or similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a data query method is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0045] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0046] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the data query method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the above-mentioned data query method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0047] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0048] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0049] Under the above operating environment, the present invention provides, as follows: Figure 2The data query method shown is implemented by a front-end data query system. It combines big data processing and caching optimization technologies to address high-concurrency user query scenarios. In particular, it addresses the slow response speed of the front-end display interface when processing tens of millions of data points. By establishing a multi-layered data query caching system and a fast memory keyword retrieval mechanism, it first queries the client cache, then performs a secondary retrieval in the server cache, and finally executes the fuzzy matching step in the server memory. This significantly improves data query efficiency and user experience.
[0050] Throughout the query process, this invention focuses on the dynamic maintenance of cached content and the optimization of query strategies to ensure that the system can maintain fast response and stable operation even under extreme data query pressure.
[0051] The embodiments of the present invention will now be described in detail with reference to each specific step.
[0052] Figure 2 This is a flowchart of an optional data query method according to an embodiment of the present invention, such as... Figure 2 As shown, the method includes the following steps:
[0053] Step S201: Receive data query request and query conditions.
[0054] In this embodiment of the invention, a data query request refers to an instruction issued by a front-end application to a back-end service to request a specific type of data. Technically, it is manifested as an HTTP request (Hypertext Transfer Protocol Request) or a GET or POST request in other network protocols. The parameters carried by the request constitute the query conditions, and the purpose is to enable the back-end system to filter out the data that the user wants to view based on these conditions.
[0055] Query criteria are a core component of data query requests, used to precisely define the range and characteristics of data that users wish to retrieve. Query criteria can include, but are not limited to: keywords, date ranges, geographic locations, user IDs, or any other information that can be used to describe data characteristics. Query criteria are used to connect user needs with the rapid retrieval of massive amounts of data. Query criteria may be a single keyword, such as a part of a product name; or a combination of multiple attributes, such as a name, a part of a mobile phone number, or a transaction date range. Query criteria are typically submitted in the form of structured data, such as a JSON-formatted parameter list, or a query parameter in a URL (Uniform Resource Locator). For example, query criteria could include the following: "keyword":"customer name"; "date_range":{"start_date":"2023-01-01","end_date":"2023-12-31"}; "location":"region name".
[0056] Step S202: Access the client cache based on the query conditions. If the first access result returned is not empty, generate a data query result based on the first access result.
[0057] The storage characteristics of client-side caching: In the implementation environment of this invention, client-side caching refers to a temporary data storage mechanism stored locally on the front-end application (such as a browser or mobile application). It has volatile storage characteristics, meaning the data is not permanently stored and is limited by the local storage constraints of the front-end application. Client-side caching primarily stores the user's most recent query requests and their corresponding query results, in JSON, key-value pairs, or other easily readable data structures. When a user queries the same conditions again, this content can be directly retrieved from the cache without sending another request to the server, significantly improving query response speed.
[0058] A non-empty first access result indicates that the data requested by the user's current query exists in the front-end client cache. No subsequent server-side cache checks or deep queries in server memory are needed; the cached data can be directly used to generate the user's desired query results, significantly reducing query response time. Typically, the first access result contains a set of pre-retrieved data records matching the user's query criteria. This data includes record summary information, IDs, and other key attributes. Returning this as the query result allows the user to gain an initial understanding of the query outcome, and further detailed database access can be performed to obtain complete information if necessary.
[0059] During the process of generating data query results, the front-end application can directly assemble and present the query results to the user locally based on the first access result. This process only involves the front-end logic processing and does not require sending another request to the back-end service, thereby significantly improving the smoothness and satisfaction of user interaction.
[0060] Optionally, in the data query method provided in this embodiment of the invention, the step of accessing the client cache based on query conditions includes: traversing the client cache, matching each piece of client cache data with the query conditions; copying the successfully matched client cache data to obtain a first access result; and in the case of a failed match, setting the first access result to null and sending the data query request and query conditions to the server.
[0061] It's important to note that client-side caching is implemented using the browser's local storage technology, and the storage structure may be key-value pairs, arrays, or lists of objects. The traversal process involves reading all data entries in this local storage and then comparing each entry with the current query conditions. Specifically, the matching operation is based on the similarity between the query conditions and the query records stored in the cache. This involves string comparison or pattern matching techniques (such as fuzzy string matching, regular expression matching, etc.). For example, if the query condition is a partial name or account number, then when traversing each cached data entry, the corresponding query record is checked to see if it contains the same or similar part as the current query condition.
[0062] During the traversal and comparison process, if a query record in the cached data completely or partially matches (i.e., satisfies the fuzzy search conditions) the current query conditions, it is considered a successful match. This means that the query has been executed recently, and the result can be retrieved directly from the cache. Typically, array or object copy methods are used to copy the successfully matched cached data to the first access result. For example, in JavaScript, JSON.parse(JSON.stringify(data)) or Object.assign() can be used to copy data objects, ensuring the independence of operations and data security.
[0063] A match failure means that no matching record was found in the client cache for the current query conditions. In order to ensure the accuracy of subsequent operations, the first access result needs to be nulled. The nulling operation can be achieved by directly setting the result variable to null or an empty array [] to prevent unexpected data from being transmitted by mistake.
[0064] The above steps, through multi-layered caching strategies and in-memory keyword fast lookup, reduce user waiting time and achieve rapid response for large-scale front-end queries. In particular, they can significantly improve query efficiency and system performance when processing large-scale datasets, thereby enhancing the user experience.
[0065] When client-side cache matching fails, data needs to be retrieved from the source, i.e., a data query request needs to be sent to the server. It's important to note that servers typically have more powerful computing capabilities and storage resources, enabling them to handle more complex and larger-volume query tasks, while client-side resources are limited and primarily used for quickly accessing and displaying recent or frequently used data. Regarding data real-time performance, servers can provide the most recently updated data, ensuring the timeliness and accuracy of query results, while client-side cached data may not be the latest. However, in high-concurrency and frequent query scenarios, using caching can significantly alleviate server pressure and improve response speed. In terms of query depth and breadth, server processing can support deeper data mining and a wider range of data queries, while client-side processing focuses more on quickly returning data that the user has previously accessed or is very close to accessing, in order to achieve a fast response.
[0066] Optionally, in the data query method provided in the embodiments of the present invention, after generating the data query result based on the first access result, the data query method further includes: if the first access result is not empty, locating the first type of access timestamp of the client cache data corresponding to the first access result in the client cache, and updating the first type of access timestamp based on the current timestamp.
[0067] It should be noted that after generating the data query results based on the first access result, the first type of access timestamp can be located through the mapping relationship between the query conditions and the cached data. For example, if the client cache is stored based on key-value pairs, where the key contains the query conditions, then the corresponding cache key can be directly located through the query conditions, and then the associated first type of access timestamp can be accessed.
[0068] In practice, each entry in the client-side cache structure may contain query conditions, query results, and metadata (such as a first-type access timestamp). When a query hits the cache, the system not only returns the query results but also extracts the first-type access timestamp from the entries matching the query conditions and updates the timestamp based on the current actual time. The current timestamp is a value reflecting the actual moment the query occurred, typically expressed in milliseconds or more precise time units, generated by a client or server time function. Updating the first-type access timestamp aims to maintain a caching strategy prioritizing access frequency or access time, ensuring that the most frequently accessed or most recently accessed data entries are retained, while less frequently accessed or older data entries are appropriately evicted, thereby optimizing memory usage and improving query efficiency.
[0069] By continuously updating access timestamps, client-side caching can dynamically adapt to changes in data query patterns. For example, if a query suddenly becomes popular, the client-side caching system can quickly move the query result to the "front edge" of the cache by updating the timestamp, ensuring that the next query can quickly hit the cache, reducing query latency and enhancing user experience.
[0070] In addition to updating timestamps, the access frequency of query conditions can be recorded to align with a frequency-based caching strategy. This involves adding or modifying metadata for cached entries, ensuring that each query condition has a counter related to its access frequency. In some cases, it's also necessary to check the validity of cached results, such as the last synchronization time with the database, to ensure that the data returned to the user is up-to-date. If cached data is outdated, it needs to be retrieved from the server again and the cache updated. To conserve client-side storage resources, data compression or simplification can be performed when storing cached data, retaining only key information from the query results while delaying the retrieval of complete data from the server until it is actually needed.
[0071] The above steps, through multi-layered caching strategies and timestamp maintenance, not only improve query speed but also ensure the rational utilization of cache space and the timeliness of data, achieving rapid response and efficient management of front-end data queries. Especially in scenarios with large data volumes, optimizing the front-end query processing flow enables rapid response to query requests while ensuring efficient resource utilization and enhancing user experience. The timestamp update operation further strengthens the intelligence of cache management, adapting to constantly changing query needs and maintaining the relevance and freshness of cached content.
[0072] Step S203: If the first access result is empty, access the server cache based on the query conditions; if the returned second access result is not empty, generate a data query result based on the second access result.
[0073] It's important to note that server-side caching offers a more stable storage environment and larger storage capacity compared to client-side caching. Client-side caching resides on user devices, while server-side caching resides in data centers or cloud servers. It is typically not limited by a single user device and can support high-concurrency read / write operations and massive data storage. Server-side caching has a more complex data storage mechanism, often designed as a distributed cache to share or distribute data across multiple servers, improving overall access efficiency and fault tolerance. The content stored in server-side caching primarily consists of user query results, including but not limited to: query keywords and their corresponding matching records, recently queried popular data fragments, and some pre-calculated statistical data. Compared to client-side caching, server-side caching provides more comprehensive and broader data coverage, handling more diverse query needs. Furthermore, due to the powerful computing capabilities of the server, it can store and process more complex and larger volumes of data than client-side caching.
[0074] Another point to note is that a non-empty second access result indicates that data matching the user's query criteria was found in the server cache. This means that although the user's query did not directly retrieve results from the fast-responding client cache, the system was still able to find the desired query results from the server cache relatively quickly. The second access result typically contains complete query results, including details of all records matching the query criteria. The system can directly use this data to generate the final query results without further database access, thus significantly improving query response speed.
[0075] Once a matching second access result is found in the server cache, the implementation system can immediately use this data to generate a data query result and return it directly to the client, without requiring the client to wait for further database queries. The process of generating the data query result involves converting the data into a specific data structure or format to suit the needs of the front-end display; for example, converting the query result into JSON format for easier front-end parsing and rendering.
[0076] Optionally, in the data query method provided in this embodiment of the invention, the step of accessing the server cache based on query conditions includes: traversing the server cache and matching each piece of server cache data with the query conditions; constructing a second access result in the form of key-value pairs using the successfully matched server cache data as the value and the query conditions as the key; and setting the second access result to null if the matching fails.
[0077] It's important to note that traversing server caches typically employs a dedicated cache management system or data structure. These systems or structures can be in-memory databases that provide efficient key-value pair storage and retrieval capabilities. The traversal operation may involve scanning all keys in the cache database or searching for key-value pairs that match the query criteria in a specific data structure, such as a hash table (HashMap).
[0078] Data stored in the server cache is typically in key-value pair format, with the query condition as the key and the query result as the value. During traversal, the system of this invention compares the keys in the cache with the current query condition, using techniques such as string matching or regular expressions to determine whether the cached data matches the query condition. A successful match is determined when the key in the cache fully or partially conforms to the fuzzy query rules. For example, if the query condition is "customer name contains 'Zhang'", then any customer name key in the server cache containing the character "Zhang" will be considered a successful match. Furthermore, the key-value pair storage mechanism in the caching system can be utilized to construct a second access result in key-value pair format by using the query condition as the key and the successfully matched server cache data as the value. Technically, this involves using hash tables or other dictionary data structures to map query conditions to results for fast retrieval and return of results.
[0079] This invention, through constructing a second access result in the form of key-value pairs, can quickly locate specific query results without traversing the entire cached dataset again. The use of key-value pairs (especially hash tables) provides a time complexity close to O(1), allowing query operations to be completed almost instantly, greatly improving query efficiency. Although key-value pairs are a common cached data structure, in certain scenarios (e.g., when dealing with extremely large datasets and high-concurrency queries), other more suitable data structures (such as Bloom filters or inverted indexes) can be used.
[0080] A match failure indicates that the current query condition did not find any matching records in the server cache. In the event of a match failure, setting the second access result to null is for the accuracy and completeness of subsequent data retrieval processes, ensuring that invalid or mismatched data is not returned to the front end. The nulling operation can be achieved by directly setting the second access result variable to null or an empty array [], depending on the specific data structure and programming language.
[0081] The above steps significantly improve the response speed of front-end fuzzy queries with large amounts of data through multi-level caching and in-memory keyword fast lookup mechanisms, while maintaining the accuracy and reliability of query results. In particular, they provide users with a smooth and uninterrupted query experience in big data scenarios with query data volumes exceeding 100,000.
[0082] Optionally, in the data query method provided in this embodiment of the invention, after generating the data query result based on the second access result, the data query method further includes: if the second access result is not empty, locating the second type of access timestamp of the server cache data corresponding to the second access result in the server cache, and updating the second type of access timestamp based on the current timestamp; updating the access frequency counter related to the server cache data corresponding to the second access result; copying the second access result as new client cache data, and determining the current timestamp as the first type of access timestamp of the new client cache data, and storing it in the client cache; if the client cache exceeds the storage capacity, removing the client cache data with the earliest first type of access timestamp.
[0083] It's important to note that in the server cache data structure, each cache entry includes not only query conditions and results, but also metadata such as a second type of access timestamp and an access frequency counter. When the second access result is not empty, the corresponding server cache data entry can be located using the query conditions, and its second type of access timestamp can be read and updated. Server caches typically use a key-value pair storage structure, with the query conditions serving as the keys. Therefore, the primary method for locating entries is key lookup, which can be implemented using hash tables or similar efficient data structures to ensure fast location and updates. The server cache system records the most recent access time for each cache entry. When an entry is accessed, the corresponding second type of access timestamp is updated to the current timestamp, ensuring that the most recently accessed cache entry is tracked, thus implementing a time-priority caching strategy.
[0084] Furthermore, the access frequency counter is used to record the number of times each cached entry is accessed. Whenever an entry is hit, the corresponding access frequency counter is incremented to implement a frequency-based caching strategy, meaning that more frequently accessed entries should be retained first.
[0085] Furthermore, when a user retrieves the query results from the server cache (i.e., the second access result), to accelerate subsequent query requests, these results can be copied to the client-side cache. The copying operation involves creating a new cache entry containing the query conditions and result data, and adding a Type I access timestamp as metadata. By copying data from the server cache to the client-side cache, future network requests can be reduced, especially for high-frequency queries, significantly improving response speed and providing a faster user experience. The copied data is stored in the client-side cache as key-value pairs, with the key representing the query conditions and the value representing the query results and metadata. This ensures that the client can quickly access recently queried data, improving the user experience.
[0086] In addition to updating timestamps and access frequency counters, server caching can employ other dynamic update mechanisms, such as data validity checks and automatic synchronization mechanisms, to ensure data accuracy and timeliness. Client-side caching can perform periodic storage capacity checks, and when the preset limit is exceeded, measures must be taken to release space, involving eviction mechanisms such as the LRU (Least Recently Used) strategy, which removes the entry with the earliest access timestamp in the first category.
[0087] It's important to note that the storage capacity of a client-side cache is typically determined by the maximum data size or the number of entries. When new data causes the total cache size to exceed the predetermined maximum, or when the number of cache entries exceeds the limit, a capacity management mechanism is triggered, initiating data removal. This removal mechanism can involve removing the oldest entry; that is, when the storage capacity limit is reached, the client-side cached data with the earliest access timestamp is removed. This strategy is based on the assumption that the earliest accessed data entry is also the least frequently used. Removing entries based on timestamps ensures that the cache retains only the most recently used or most frequently used data, thereby maximizing cache effectiveness.
[0088] The steps described above enable fast fuzzy queries on large datasets by optimizing front-end and back-end caching management strategies. This includes utilizing multi-level caching (client-side caching, server-side caching, and in-memory keyword lookup) to reduce query latency, improve data query efficiency and user experience, while intelligently managing cache space to avoid resource waste while ensuring data timeliness and accuracy.
[0089] Throughout the cache management process, steps such as updating timestamps and access frequency counters, copying server cache data to client caches, and controlling client cache capacity work together to achieve the aforementioned technical goals. This enables the implemented system to maintain high efficiency and responsiveness when processing large amounts of data, providing users with a smooth query experience.
[0090] Step S204: If the second access result is empty, access the server memory based on the query conditions and generate a data query result based on the returned third access result.
[0091] It should be noted that server memory refers to RAM (Random Access Memory) used for high-speed data access on the server. In this embodiment of the invention, server memory is mainly used to store preprocessed keywords and related records, which are the primary basis for fuzzy queries. The stored content can be a pre-built index structure, an inverted index, or data fragments divided according to specific rules.
[0092] Compared to server caching and client-side caching, server caching is typically optimized using cache management software or data structures (such as HashMaps) on top of RAM to store frequently accessed or recently retrieved data results. It focuses on the frequency and timing of data access for fast responses to repeated queries. Client-side caching is stored on the user's device to store recently accessed data, reducing network transmission overhead and improving response speed. Its storage capacity is relatively small and limited by the user's device performance. Server memory tends to store pre-processed datasets to support fast data queries and processing, but it does not store query results long-term, focusing more on real-time data processing capabilities.
[0093] In this embodiment of the invention, the third access result refers to the data returned after a fuzzy search in the server's memory. When generating data query results based on the third access result, the matched keywords and related identifiers can be converted into the data format required for front-end display. Theoretically, the third access result is not empty because the data in the server's memory is fully preloaded, which is sufficient to handle various query requirements. The third access result contains all records that match the query conditions, but it may only contain some fields of the keywords, or the identifier of the complete record associated with the keywords, allowing users to initially understand the query results. If necessary, further complete information can be obtained from the database. This can minimize the amount of computation and resource consumption, and improve response speed and user experience.
[0094] Optionally, in the data query method provided in this embodiment of the invention, the step of accessing server memory based on query conditions includes: dividing the server memory into N memory shards based on query conditions, and obtaining a set of memory keywords for each memory shard, where N is a positive integer; for each memory shard, performing keyword retrieval in each set of memory keywords based on query conditions, and locating target memory data from the memory shard based on the retrieved target keywords; copying the target memory data to obtain a third access result.
[0095] In this embodiment of the invention, the main reason for sharding the server memory is to improve data retrieval efficiency and fully utilize the server's multi-core computing power. When the data volume reaches a certain scale, if queries on server memory are not optimized, it may lead to excessively long query times, affecting user experience. The sharding strategy can divide the dataset into smaller, more easily parallelizable parts, thereby accelerating the query process.
[0096] Sharding strategies are typically based on factors including data distribution characteristics, statistical analysis of query patterns, and server hardware configuration (such as the number of CPU cores and memory size). Implementable sharding strategies include: a) Hash-based sharding: Query conditions are mapped to specific memory shards using a hash function, placing data with the same or similar query conditions within the same shard. For example, if the query condition involves a user ID, the user ID can be hashed, and the memory shard where the data resides can be determined based on the hash value. b) Data range-based sharding: Data is divided into different memory shards based on its natural range. For example, if the data contains timestamps, it can be sharded by time period, such as by year, month, or day. c) Data attribute-based sharding: Data is sharded based on key attributes, ensuring that data with the same attribute is grouped into the same shard for quick location. For example, if the data involves geographical location, it can be sharded according to geographical location.
[0097] Furthermore, the memory keyword set refers to the set of keywords related to fuzzy queries contained in each shard of server memory. Obtaining the memory keyword set for each memory shard is typically achieved during system initialization or data updates by analyzing and extracting keywords from the data in each shard. Memory keywords are the core basis for fuzzy queries, used to quickly determine whether data matches the query conditions. Memory keywords allow for rapid location of memory shards that may contain query results, thereby reducing unnecessary full data traversal and improving query speed. The process involves retrieving the target keyword from the memory keyword set; if a match is found, the storage location of the original data is located based on the keyword's position information within the memory shard, thus retrieving the target memory data.
[0098] The method for copying target memory data can be either shallow copy or deep copy, the specific choice depending on the complexity of the data and the purpose of the copy. It should be noted that a shallow copy only copies the reference to the data, while a deep copy copies the entire data content. In this embodiment of the invention, since the goal is to pass the query results to the front end, a deep copy can be used to ensure that the data received by the front end is completely independent and unaffected by changes in the server-side data.
[0099] The above steps significantly improve query response speed through multi-level caching and server memory sharding queries, while ensuring the accuracy of data retrieval and the stability of system operation, thus realizing a method for fast fuzzy querying of large amounts of data on the front end.
[0100] In this embodiment of the invention, preprocessing, such as data cleaning, keyword extraction, and word segmentation, can be performed before data is loaded into server memory to reduce the amount of data processing during subsequent queries. Data in memory can also be compressed for storage, reducing memory usage while ensuring rapid decompression during queries, without affecting query speed. Furthermore, asynchronous mechanisms can be used to update data in server memory and cache, preventing data update operations from blocking the query process and ensuring the continuity and speed of system response.
[0101] Optionally, in the data query method provided in this embodiment of the invention, after generating the data query result based on the returned third access result, the data query method further includes: copying the third access result into new server-side cache data and new client-side cache data, and determining the current timestamp as a first type of access timestamp and a second type of access timestamp; associating the new client-side cache data with the first type of access timestamp and storing it in the client cache, associating the new server-side cache data with the second type of access timestamp and storing it in the server cache, and setting an access frequency counter for the new server-side cache data; if the server cache exceeds the storage capacity, removing the server-side cache data with the earliest second type of access timestamp, or removing the server-side cache data with the least access frequency based on the access frequency counter.
[0102] In this embodiment of the invention, the third access result obtained based on the memory query can also be copied to both the server-side cache and the client-side cache. Copying means creating a copy of the query result and attaching necessary metadata, such as timestamps and access frequency counters. By storing the query result in both the client-side and server-side caches, the response time for future identical or similar queries can be significantly reduced. Updating the client-side cache can speed up queries on the user side, while updating the server-side cache can reduce the server load and improve overall response performance.
[0103] Furthermore, the first and second types of access timestamps are used for client-side and server-side caching management, respectively. By associating the current timestamp with the data, the caching system can accurately track the frequency and freshness of data usage and maintain a time-based caching strategy. New client-side cached data, along with the first type of access timestamp, is stored in the client-side cache, ensuring that subsequent identical queries can retrieve results directly from the local cache, reducing network latency. New server-side cached data, also accompanied by the second type of access timestamp and access frequency counter, is stored in the server-side cache. The server-side cache update mechanism can also include data validity checks and update strategies.
[0104] Furthermore, an access frequency counter can be set for each server-side cached entry. The counter increments each time an entry is queried, implementing a frequency-based caching strategy that retains the most frequently queried entries. The server cache has a storage capacity limit. When the total amount of data or the number of entries in the cache exceeds a predetermined threshold, a cache cleanup mechanism needs to be triggered. Exceeding the storage capacity can be indicated by a set number of entries or the total data size. Once cache over-capacity is detected, data removal is performed to free up space.
[0105] Some optional cleanup strategies include: a) Earliest timestamp cached data: Timestamp-based cleanup removes the earliest accessed cache entries, ensuring that the cache retains only the most recently used data. This is a typical practice of time-priority strategies. b) Least frequently accessed cached data: Frequency-based cleanup prioritizes removing the least frequently accessed cache entries to free up space for data more likely to be accessed again. c) Random replacement: Cached entries are randomly selected for replacement. This can provide simple replacements but may not be efficient or intelligent. d) Popularity threshold: A threshold is set based on data popularity (possibly a combination of access frequency and time). Data below this threshold will be cleaned up. e) Data lifecycle: A fixed or dynamic lifecycle is set for data. Expired data is automatically removed. This works well when processing time-sensitive data.
[0106] The above steps achieve high efficiency and low latency in front-end data querying through a multi-level caching mechanism and a fast fuzzy query algorithm that supports large-scale data. Especially when dealing with big data of 100,000 or more, the collaborative work of client-side caching, server-side caching, and server memory keyword fast query, along with intelligent cache update and capacity management strategies, can ensure high system performance and optimized user experience.
[0107] Figure 3 This is a schematic diagram of an optional three-layer fuzzy data query matching mechanism according to an embodiment of the present invention, such as... Figure 3 As shown, the first layer is the client-side cache. The client caches the client's most recent query records, so repeated queries by the client within a short period of time can return results without accessing the backend server.
[0108] The second layer is the server-side cache. It stores all customer query records from the most recent period. If the query content matches the cache, the query result is returned directly. It supports maintaining the cache set content based on strategies such as access time priority and access frequency priority.
[0109] The third layer: In-memory keyword fast search. The combination of the fields to be searched plus the record's primary key is preloaded into memory. A specific algorithm is used to traverse and return matching records. To improve query efficiency, data sharding, multi-threaded concurrent queries, and limiting the number of records returned by the query can be used to shorten the data query time.
[0110] Through the above steps S201 to S204, a data query request and query conditions can be received first, and then the client cache can be accessed based on the query conditions. If the first access result is not empty, a data query result can be generated based on the first access result. If the first access result is empty, the server cache can be accessed based on the query conditions. If the second access result is not empty, a data query result can be generated based on the second access result. Finally, if the second access result is empty, the server memory can be accessed based on the query conditions, and a data query result can be generated based on the returned third access result.
[0111] In this embodiment of the invention, a multi-level caching query combined with intelligent retrieval is adopted. Through a carefully designed client-side and server-side caching mechanism and an efficient memory keyword fast search method, the front-end data query response speed is significantly improved. This achieves the technical effect of maintaining consistent query performance and user experience in a big data environment, and solves the technical problem of slow response speed for large-scale front-end queries in related technologies.
[0112] Specifically, upon receiving a data query request and its accompanying query conditions, this embodiment of the invention first searches for matching records using the client's local storage. If a match is found, the query result can be directly fed back to the user in a very short time, avoiding lengthy network transmission and server processing time. If the initial match fails, a secondary search is performed using the server-side cache, attempting to match through the server-side cache of recently popular queries. If the secondary match is successful, the query result can also be fed back to the user in a short response time. Only when both caches fail is the fuzzy query index in the server's memory triggered. Through algorithm optimization and data structure design, the final query is ensured to be as efficient and fast as possible, minimizing the latency of traditional database queries. This progressive query strategy shortens the data search path, improves query speed, and ultimately provides users with an instant response experience, significantly improving the performance of front-end applications in high-data-traffic scenarios and overcoming the bottlenecks of existing technologies.
[0113] The invention will now be described in conjunction with another alternative embodiment.
[0114] Example 2
[0115] This invention also provides a data query device. It should be noted that the data query device of this invention includes multiple implementation units, which can be used to execute the data query method provided in the first embodiment above. Each implementation unit corresponds to each implementation step in the first embodiment above.
[0116] Figure 4 This is a schematic diagram of an optional data query device according to an embodiment of the present invention, such as... Figure 4 As shown, the device may include: a receiving unit 41, a first generating unit 42, a second generating unit 43, and a third generating unit 44.
[0117] The receiving unit 41 is used to receive data query requests and query conditions.
[0118] The first generation unit 42 is used to access the client cache based on the query conditions, and generate a data query result based on the first access result if the returned first access result is not empty.
[0119] The second generation unit 43 is used to access the server cache based on the query conditions when the first access result is empty, and to generate a data query result based on the second access result when the returned second access result is not empty.
[0120] The third generation unit 44 is used to access the server memory based on the query conditions and generate a data query result based on the returned third access result when the second access result is empty.
[0121] The aforementioned data query device can first receive a data query request and query conditions through the receiving unit 41, then access the client cache based on the query conditions through the first generation unit 42, and generate a data query result based on the first access result if the returned first access result is not empty. Then, if the first access result is empty, access the server cache based on the query conditions through the second generation unit 43, and generate a data query result based on the second access result if the returned second access result is not empty. Finally, if the second access result is empty, access the server memory based on the query conditions through the third generation unit 44, and generate a data query result based on the returned third access result.
[0122] In this embodiment of the invention, a multi-level caching query combined with intelligent retrieval is adopted. Through a carefully designed client-side and server-side caching mechanism and an efficient memory keyword fast search method, the front-end data query response speed is significantly improved. This achieves the technical effect of maintaining consistent query performance and user experience in a big data environment, thereby solving the technical problem of slow response speed for large-scale front-end queries in related technologies.
[0123] Specifically, upon receiving a data query request and its accompanying query conditions, this embodiment of the invention first searches for matching records using the client's local storage. If a match is found, the query result can be directly fed back to the user in a very short time, avoiding lengthy network transmission and server processing time. If the initial match fails, a secondary search is performed using the server-side cache, attempting to match through the server-side cache of recently popular queries. If the secondary match is successful, the query result can also be fed back to the user in a short response time. Only when both caches fail is the fuzzy query index in the server's memory triggered. Through algorithm optimization and data structure design, the final query is ensured to be as efficient and fast as possible, minimizing the latency of traditional database queries. This progressive query strategy shortens the data search path, improves query speed, and ultimately provides users with an instant response experience, significantly improving the performance of front-end applications in high-data-traffic scenarios and overcoming the bottlenecks of existing technologies.
[0124] Furthermore, the first generation unit includes: a first matching module, used to traverse the client cache and match each piece of client cache data with the query conditions; a first copying module, used to copy the successfully matched client cache data to obtain the first access result; and a first emptying module, used to empty the first access result and send the data query request and query conditions to the server if the matching fails.
[0125] Furthermore, the data query device includes: a first update module, used to, after generating a data query result based on the first access result, locate the first type of access timestamp of the client cache data corresponding to the first access result in the client cache if the first access result is not empty, and update the first type of access timestamp based on the current timestamp.
[0126] Furthermore, the second generation unit includes: a second matching module, used to traverse the server cache and match each piece of server cache data with the query conditions; a construction module, used to construct a second access result in key-value pair form using the successfully matched server cache data as the value and the query conditions as the key; and a second emptying module, used to empty the second access result in the event of a matching failure.
[0127] Furthermore, the data query device also includes: a second update module, used to locate the second type of access timestamp of the server cache data corresponding to the second access result in the server cache when the second access result is not empty after generating the data query result based on the second access result; and update the second type of access timestamp based on the current timestamp; a third update module, used to update the access frequency counter related to the server cache data corresponding to the second access result; a second copy module, used to copy the second access result as new client cache data, and determine the current timestamp as the first type of access timestamp of the new client cache data, and associate and store it in the client cache; and a first removal module, used to remove the client cache data with the earliest first type of access timestamp when the client cache exceeds the storage capacity.
[0128] Furthermore, the third generation unit includes: a sharding module, used to shard the server memory based on query conditions to obtain N memory shards, and obtain the memory keyword set for each memory shard, where N is a positive integer; a retrieval module, used to perform keyword retrieval in each memory keyword set based on query conditions for each memory shard, and locate the target memory data from the memory shard based on the retrieved target keyword; and a third copying module, used to copy the target memory data to obtain the third access result.
[0129] Furthermore, the data query device also includes: a determining module, used to copy the third access result as new server-side cache data and new client-side cache data after generating the data query result based on the returned third access result, and determine the current timestamp as the first type of access timestamp and the second type of access timestamp; a setting module, used to associate the new client-side cache data with the first type of access timestamp and store it in the client cache, associate the new server-side cache data with the second type of access timestamp and store it in the server cache, and set an access frequency counter for the new server-side cache data; and a second removal module, used to remove the server-side cache data with the earliest second type of access timestamp when the server cache exceeds the storage capacity, or to remove the server-side cache data with the least access frequency based on the access frequency counter.
[0130] It should be noted that the receiving unit 41, the first generating unit 42, the second generating unit 43, and the third generating unit 44 mentioned above correspond to steps S201 to S204 in Embodiment 1. The instances and application scenarios implemented by the above units and the corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules or units can also be part of a device and run in the computer terminal 10 provided in Embodiment 1.
[0131] The invention will now be described in conjunction with another alternative embodiment.
[0132] Example 3
[0133] The present invention can also provide an electronic device. Figure 5 This is a structural block diagram of an electronic device for performing a data query method according to an embodiment of the present invention, such as... Figure 5 As shown, the electronic device may include: one or more ( Figure 5 (Only one is shown) processor 502, memory 504, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0134] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the data query method and apparatus in this application embodiment. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the aforementioned data query method. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0135] The processor can invoke information and applications stored in memory via a transmission device to perform the following steps: receiving a data query request and query conditions; accessing the client cache based on the query conditions, and generating a data query result based on the first access result if the first access result is not empty; accessing the server cache based on the query conditions if the first access result is empty, and generating a data query result based on the second access result if the second access result is not empty; accessing the server memory based on the query conditions if the second access result is empty, and generating a data query result based on the third access result.
[0136] The processor can also access information and applications stored in memory via a transmission device to perform the following steps: traverse the client cache, match each piece of client cache data with the query conditions; copy the successfully matched client cache data to obtain the first access result; in the case of a failed match, set the first access result to null and send the data query request and query conditions to the server.
[0137] The processor can also invoke information and applications stored in the memory through the transmission device to perform the following steps: if the first access result is not empty, locate the first type of access timestamp of the client cache data corresponding to the first access result in the client cache, and update the first type of access timestamp based on the current timestamp.
[0138] The processor can also invoke information and applications stored in memory via the transmission device to perform the following steps: traverse the server cache, match each piece of server cache data with the query conditions; construct a second access result in the form of key-value pairs using the successfully matched server cache data as the value and the query conditions as the key; and set the second access result to null if the match fails.
[0139] The processor can also invoke information and applications stored in the memory via the transmission device to perform the following steps: if the second access result is not empty, locate the second type of access timestamp of the server cache data corresponding to the second access result in the server cache, and update the second type of access timestamp based on the current timestamp; update the access frequency counter related to the server cache data corresponding to the second access result; copy the second access result as new client cache data, and determine the current timestamp as the first type of access timestamp of the new client cache data, and store it in the client cache; if the client cache exceeds the storage capacity, remove the client cache data with the earliest first type of access timestamp.
[0140] The processor can also invoke information and applications stored in the memory through the transmission device to perform the following steps: shard the server memory based on query conditions to obtain N memory shards, and obtain the memory keyword set for each memory shard, where N is a positive integer; for each memory shard, perform keyword retrieval in each memory keyword set based on query conditions, and locate the target memory data from the memory shard based on the retrieved target keyword; copy the target memory data to obtain the third access result.
[0141] The processor can also invoke information and applications stored in memory via the transmission device to perform the following steps: copy the third access result as new server cache data and new client cache data, and determine the current timestamp as the first type of access timestamp and the second type of access timestamp; associate the new client cache data with the first type of access timestamp and store it in the client cache, associate the new server cache data with the second type of access timestamp and store it in the server cache, and set an access frequency counter for the new server cache data; if the server cache exceeds the storage capacity, remove the server cache data with the earliest second type of access timestamp, or remove the server cache data with the least access frequency based on the access frequency counter.
[0142] This invention provides a data query solution. By employing a multi-level caching query combined with intelligent retrieval, and through a carefully designed client-side and server-side caching mechanism and efficient in-memory keyword search, it significantly improves the front-end data query response speed. This achieves the technical effect of maintaining consistent query performance and user experience in a big data environment, thereby solving the technical problem of slow response speed for large-scale front-end data queries in related technologies.
[0143] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, handheld computers, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 5 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 5 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 5 The different configurations shown.
[0144] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0145] The invention will now be described in conjunction with another alternative embodiment.
[0146] Example 4
[0147] This invention also provides a computer-readable storage medium. Optionally, in this invention, the computer-readable storage medium can be used to store the program code executed by the data query method provided in Embodiment 1.
[0148] Optionally, in this embodiment of the invention, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0149] This invention also provides a computer program product, which, when executed on a data processing device, is suitable for performing the steps of a data query method: receiving a data query request and query conditions; accessing the client cache based on the query conditions, and generating a data query result based on the first access result if the first access result is not empty; accessing the server cache based on the query conditions if the first access result is empty, and generating a data query result based on the second access result if the second access result is not empty; and accessing the server memory based on the query conditions if the second access result is empty, and generating a data query result based on the third access result.
[0150] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0151] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0152] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0153] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0154] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0155] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0156] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A data query method, characterized in that, include: Receive data query requests and query conditions; Access the client cache based on the query conditions, and generate a data query result based on the first access result if the first access result is not empty. If the first access result is empty, the server cache is accessed based on the query conditions. If the returned second access result is not empty, a data query result is generated based on the second access result. If the second access result is empty, the server memory is accessed based on the query conditions, and a data query result is generated based on the returned third access result.
2. The data query method according to claim 1, characterized in that, The steps for accessing the client cache based on the query conditions include: Iterate through the client cache and match each piece of client cached data with the query conditions; Copy the successfully matched client cached data to obtain the first access result; If a match fails, the first access result is set to null, and the data query request and query conditions are sent to the server.
3. The data query method according to claim 1, characterized in that, After generating the data query result based on the first access result, the data query method further includes: If the first access result is not empty, locate the first type of access timestamp of the client cache data corresponding to the first access result in the client cache, and update the first type of access timestamp based on the current timestamp.
4. The data query method according to claim 1, characterized in that, The steps for accessing the server cache based on the query conditions include: Iterate through the server cache and match each cached data entry with the query conditions; Using the successfully matched server cached data as the value and the query condition as the key, construct the second access result in key-value pair form; If a match fails, the second access result will be set to null.
5. The data query method according to claim 1, characterized in that, After generating the data query result based on the second access result, the data query method further includes: If the second access result is not empty, locate the second type of access timestamp of the server cache data corresponding to the second access result in the server cache, and update the second type of access timestamp based on the current timestamp; Update the access frequency counter associated with the server cache data corresponding to the second access result; The second access result is copied as new client cache data, and the current timestamp is determined as the first type of access timestamp of the new client cache data and stored in the client cache accordingly; If the client cache exceeds the storage capacity, the client cache data with the earliest access timestamp of the first type will be removed.
6. The data query method according to claim 1, characterized in that, The steps for accessing server memory based on the query conditions include: The server memory is sharded based on the query conditions to obtain N memory shards, and the memory key set of each memory shard is obtained, where N is a positive integer; For each memory shard, keyword retrieval is performed in each memory keyword set based on the query conditions, and the target memory data is located from the memory shard based on the retrieved target keyword; The target memory data is copied to obtain the third access result.
7. The data query method according to claim 1, characterized in that, After generating the data query results based on the returned third access results, the data query method further includes: The third access result is copied as new server-side cache data and new client-side cache data, and the current timestamp is determined to be the first type of access timestamp and the second type of access timestamp; The new client cache data is associated with the first type of access timestamp and stored in the client cache; the new server cache data is associated with the second type of access timestamp and stored in the server cache; and an access frequency counter is set for the new server cache data. If the server cache exceeds the storage capacity, the server cache data with the earliest access timestamp of the second type will be removed, or the server cache data with the least access frequency will be removed based on the access frequency counter.
8. A data query device, characterized in that, include: The receiving unit is used to receive data query requests and query conditions; The first generation unit is used to access the client cache based on the query conditions, and generate a data query result based on the first access result if the returned first access result is not empty. The second generation unit is used to access the server cache based on the query conditions when the first access result is empty, and to generate a data query result based on the second access result when the returned second access result is not empty. The third generation unit is used to access the server memory based on the query conditions when the second access result is empty, and generate a data query result based on the returned third access result.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the data query method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the data query method according to any one of claims 1 to 7.
11. A computer program product, characterized in that, It includes computer instructions, wherein when executed by a processor, the computer instructions implement the steps of the data query method according to any one of claims 1 to 7.