Shared data retrieval method and device, server, and medium
By maintaining a shared data pool for each target object and generating reusable query keys, the problem of repeated queries on the dataset is solved, thereby reducing database load, improving user experience, and ensuring the efficiency and security of the data interaction system.
Patent Information
- Application Number
- CN202611369983.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-04
- Publication Date
- 2026-11-24
AI Technical Summary
In enterprise data analysis and decision support scenarios, repeated queries on the same dataset lead to wasted database resources, excessively long initial loading times, and delayed user interaction responses, affecting system performance and user experience.
By using a shared data retrieval method, the server maintains a shared data retrieval pool for each target object, caches historical query data, and generates reusable query keys to hit the cache or database. It relies on dataset identifiers, query filtering parameters, and query control parameters to ensure data access security and reduce duplicate queries.
It effectively reduces repetitive database query operations, lowers database load, improves the performance and user experience of the data interaction system, and ensures data accuracy and access security.
Smart Images

Figure CN123157776A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of data interaction technology, and more specifically, relates to a shared data retrieval method and device, server, and medium. Background Technology
[0002] In enterprise data analysis and decision support scenarios, user interactions with data display pages are frequent. During an interaction with a specific target object (such as reports, dashboards, or other data display entities), a single user action, such as previewing, linked filtering, or refreshing, is often broken down into multiple backend data query requests. Simultaneously, the page corresponding to this target object may contain multiple data display components (such as charts, tables, indicator cards, and filter controls), each independently initiating data retrieval requests to the backend. This results in the same dataset being repeatedly queried within the same business scenario, creating a large number of redundant Structured Query Language (SQL) execution records on the database side. This problem is further exacerbated by the increase in concurrent users and the complexity of the target object, not only causing a serious waste of database resources but also resulting in excessively long initial screen loading times and significant delays in linked responses after user interactions, severely impacting overall system performance and user experience. Therefore, how to effectively reduce repeated database query operations during the interaction with the same target object without changing users' existing operating habits, reduce database load pressure, and shorten the overall time of first screen loading and linkage response has become an important technical problem that urgently needs to be solved in the performance optimization of current data interaction systems. Summary of the Invention
[0003] The purpose of this application is to provide a shared data retrieval method, device, server, and medium that effectively reduces repetitive database query operations and lowers database load while ensuring data correctness and access security.
[0004] A first aspect of this application provides a shared data retrieval method, executed by a server, comprising: Receive data query requests for a target object sent by the client. The data query request carries an object identifier, a dataset identifier, query filtering parameters, and query control parameters. The dataset identifier is used to characterize the data type of the data requested in the data query request. The query control parameters are used to control the data query permissions for the target object. The query filtering parameters characterize the business filtering conditions applied when querying data for the target object. The business filtering conditions are used to determine the range of data to be queried from the associated data of the target object. Find the shared data pool corresponding to the object identifier. One object identifier corresponds to one shared data pool, which is used to cache historical query data for the target object. If a shared data pool is found, a reusable query key is generated based on the dataset identifier, query filtering parameters, and query control parameters. The system searches for target data that matches the reused query key in the shared data pool. If the target data is found, it retrieves the target data from the shared data pool and generates the corresponding query result, which is then returned to the client. If the target data is not found, it searches for data that matches the object identifier in the target database, writes the found data into the shared data pool using the reused query key as an index, and generates the corresponding query result, which is then returned to the client.
[0005] A second aspect of this application provides a shared data retrieval device, comprising: The query request receiving module is used to receive data query requests for a target object sent by the client. The data query request carries an object identifier, a dataset identifier, query filtering parameters, and query control parameters. The dataset identifier is used to characterize the data type of the data requested in the data query request. The query control parameters are used to control the data query permissions for the target object. The query filtering parameters characterize the business filtering conditions applied when querying data for the target object. The business filtering conditions are used to determine the range of data to be queried from the associated data of the target object. The shared data pool lookup module is used to find the shared data pool corresponding to the object identifier. One object identifier corresponds to one shared data pool, and it is also used to cache historical query data for the target object. The reuse query key generation module is used to generate a reuse query key based on the dataset identifier, query filtering parameters, and query control parameters if a shared data retrieval pool is found. The data retrieval module is used to search for target data that matches the reused query key from the shared data retrieval pool. If the target data is found, it retrieves the target data from the shared data retrieval pool and generates the corresponding query result to return to the client. If the target data is not found, it searches for data that matches the object identifier from the target database, writes the found data into the shared data retrieval pool with the reused query key as the index, and generates the corresponding query result to return to the client.
[0006] A third aspect of this application provides a server, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the steps of the shared data retrieval method described above.
[0007] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the shared data retrieval method described above.
[0008] The beneficial effects of the shared data retrieval method, apparatus, server, and medium provided in this application embodiment are as follows: This application embodiment finds the shared data retrieval pool corresponding to the object identifier, and one object identifier corresponds to one shared data retrieval pool, which is used to cache historical query data for the target object. This allows multiple data query requests for the same target object to share the same cache container, thus providing a container foundation for subsequent data reuse. Furthermore, since the generation of the reuse query key depends on the dataset identifier, query filtering parameters, and query control parameters, where the query filtering parameters limit the business filtering scope and the query control parameters limit the permission boundaries, the same cache result will only be hit when the dataset type, business filtering conditions, and data query permissions are the same. This avoids permission penetration and data corruption problems that may be caused by coarse-grained reuse at the source. On this basis, by first searching the shared data retrieval pool, returning directly if a match is found, and querying the database and backfilling the cache if no match is found, only the first request will actually access the database among multiple requests for the same dataset identifier, the same query filtering parameters, and the same query control parameters. Therefore, this application embodiment effectively reduces repetitive database query operations and lowers the database load while ensuring data correctness and permission security. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 A flowchart illustrating a shared data retrieval method provided in an embodiment of this application; Figure 2 This is a structural block diagram of a shared data retrieval device provided in an embodiment of this application; Figure 3 This is a schematic block diagram of a server provided in one embodiment of this application. Detailed Implementation
[0011] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0012] Please refer to Figure 1 , Figure 1This is a flowchart illustrating a shared data retrieval method provided in an embodiment of this application. This method can be executed by a server and may include: S101: Receive a data query request for a target object sent by the client. The data query request carries an object identifier, a dataset identifier, query filtering parameters, and query control parameters. The dataset identifier is used to characterize the data type of the data requested in the data query request. The query control parameters are used to control the data query permissions for the target object. The query filtering parameters characterize the business filtering conditions applied when querying data for the target object. The business filtering conditions are used to determine the range of data to be queried from the associated data of the target object.
[0013] In this embodiment, the target object can be a report. In this embodiment, after the client detects user actions such as previewing, linked filtering, refreshing, or pre-calculating on the report page, it constructs a data query request based on the user's current operation object and operation context. This request carries at least four core pieces of information. The object identifier uniquely identifies the report entity currently being operated on by the user. This identifier can be a unique code assigned by the system to each report or dashboard, which remains unchanged throughout the user's interaction session, used to group subsequent discrete data requests into the same interaction boundary. The dataset identifier indicates which data type or data view the requested data belongs to. For example, when a user views sales details, it corresponds to an order dataset; when viewing product rankings, it corresponds to a product statistics dataset. Different dataset identifiers typically map to different data tables or materialized views in the backend database. Query filter parameters represent the business filtering conditions actively set by the user on the report side through interactive controls such as filters, date pickers, and drop-down menus, such as time range, product category, and region name. These parameters collectively limit the range of data actually needed for this query from all data associated with the target object. Query control parameters differ from user-defined query filtering parameters. They are typically automatically appended by the client when constructing a request, based on the currently logged-in user's identity, role, organizational level, and permission level. Examples include user ID, role code, department number, and access level. These parameters are used to implement access control at the data level, ensuring that users with different permissions, even using the same dataset identifier and query filtering parameters, can only view a subset of data within their authorized scope. The client encapsulates these four pieces of information according to the system's agreed-upon communication protocol and sends them to the server over the network to trigger subsequent data query processing.
[0014] S102: Find the shared data pool corresponding to the object identifier. One object identifier corresponds to one shared data pool, which is used to cache historical query data for the target object.
[0015] In this embodiment, after receiving a data query request from the client, the server first parses the request and extracts the object identifier. The server internally maintains a cache pool mapping table, which uses the object identifier as an index and the corresponding shared data retrieval pool instance as the value. This table is stored in the server's memory space and can be implemented using a hash table structure that supports high-concurrency read and write operations. The server uses the extracted object identifier as the search key to search the mapping table for the existence of a corresponding shared data retrieval pool. A shared data retrieval pool is essentially a cache container bound to a specific target object, used to temporarily store historical query data acquired during the current interaction session of that target object. Its boundaries correspond one-to-one with the object identifier, thereby ensuring that cached data between different target objects is isolated and does not interfere with each other.
[0016] In this embodiment, if the server finds a shared data retrieval pool instance with the object identifier as the key in the mapping table, it indicates that a shared cache pool has already been established for the current target object, and subsequent data query operations can attempt to retrieve reused data from this pool. Conversely, if no corresponding shared data retrieval pool instance is found, it indicates that the current target object is being accessed for the first time, and the server can create a new shared data retrieval pool instance as needed and bind it to the object identifier for subsequent queries. From the time of its creation, the shared data retrieval pool continuously provides caching services for each data query request of the target object throughout its entire lifecycle, until the cache pool is actively or passively cleaned up and released.
[0017] S103: If a shared data pool is found, a reused query key is generated based on the dataset identifier, query filtering parameters, and query control parameters.
[0018] In this embodiment, after the server locates the shared data pool corresponding to the object identifier, the server needs to generate a reusable query key that can accurately locate the cached data in the shared data pool for the current data query request. The generation of this reusable query key is based on three parts of information carried in the current request: the dataset identifier, the query filtering parameters, and the query control parameters.
[0019] In one embodiment of this application, a reusable query key is generated based on the dataset identifier, query filtering parameters, and query control parameters, including: Normalize and hash the query filtering parameters to generate parameter signatures; The query control parameters are normalized and hashed to generate a query control signature; A reusable query key is generated by concatenating the dataset identifier, parameter signature, and query control signature.
[0020] In this embodiment, normalization refers to standardizing the key-value pairs in the query filtering parameters or query control parameters according to unified sorting and formatting rules. This ensures that even when the query filtering parameters have the same semantics but slightly different expressions, the normalized string will be identical. Hash calculation refers to converting the normalized string into a fixed-length hash value using a cryptographic hash algorithm. This hash value serves as a digital digest of the parameter semantics for subsequent reuse of query keys. Its function is to convert potentially long and inconsistently formatted parameter strings into key-value components of uniform length and fixed format.
[0021] In this embodiment, query filtering parameters and query control parameters may appear in different orders and formats in requests initiated by different components at different times. If the original parameters are directly used as components of the reused query key, it may result in query requests with the same semantics but different formats generating different key values, thus failing to hit the same data already cached in the shared data pool. For example, two query requests may both have query filtering parameters of "time range: first quarter of 2026, product category: electronic products", but the parameter order in the first request is "category=electronics&startDate=2026-01-01&endDate=2026-03-31", while the parameter order in the second request is "startDate=2026-01-01&endDate=2026-03-31&category=electronics". The parameters have the same semantics, but the form of the parameter strings differs due to the different field order. To solve this problem, the server first normalizes the query filtering parameters when generating the reused query key. The specific normalization process is as follows: The server sorts all key-value pairs in the query filter parameters lexicographically, and then concatenates the sorted key-value pairs into a normalized parameter string using the fixed format "key1=value1&key2=value2&key3=value3". For the two requests in the example above, after lexicographical sorting, they both result in the exact same normalized string: "category=electronics&endDate=2026-03-31&startDate=2026-01-01".
[0022] Subsequently, the server performs a hash calculation on the normalized string, for example, using the SHA-256 algorithm to obtain a 64-bit hexadecimal hash value. To facilitate the storage and comparison of the reused query key, the first 16 bits of this hash value can be extracted as the final parameter signature. Similarly, the server processes the query control parameters according to the exact same rules, concatenating the various query control parameters into a normalized string after lexicographically ordering the field names, and then performing a hash calculation on this string to obtain the query control signature. Finally, the server concatenates the dataset identifier, parameter signature, and query control signature into a complete string in the format "dataset identifier|parameter signature|query control signature", which serves as the final reused query key.
[0023] As can be seen from the above, this embodiment effectively eliminates the impact of differences in parameter arrangement order on the consistency of reused query keys by sorting the query filtering parameters and query control parameters in lexicographical order, normalizing the concatenation, and performing hash calculations. This ensures that query requests with the same semantics can generate the same reused query key, thereby correctly hitting the cached data in the shared data pool, significantly improving the cache hit rate, and also avoiding the problem of duplicate data retrieval caused by differences in parameter format.
[0024] S104: Search for target data that matches the reuse query key in the shared data pool. If the target data is found, retrieve the target data from the shared data pool and generate the corresponding query result to return to the client. If the target data is not found, search for data that matches the object identifier in the target database, write the found data into the shared data pool with the reuse query key as the index, and generate the corresponding query result to return to the client.
[0025] In this embodiment, after generating a reused query key, the server uses this key as an index to perform a search operation for the target data in the shared data retrieval pool. The shared data retrieval pool can internally employ a key-value pair storage structure, where the key is the reused query key and the value is the corresponding historical query result data. This structure enables fast location and retrieval of cached data. If the server successfully finds the target data matching the reused query key in the shared data retrieval pool, it indicates that the data requested by the current data query request has already been retrieved and cached in the pool during this interaction. In this case, the server directly reads the target data from the shared data retrieval pool, encapsulates it into a query result conforming to a predetermined data format, and returns it to the client via the network. No access to the target database is required throughout this process. Conversely, if the server fails to find the target data matching the reused query key in the shared data retrieval pool, it indicates that the data corresponding to the current request has not yet been cached. In this case, the server needs to retrieve the data from the target database.
[0026] Specifically, the server constructs a corresponding data query instruction based on the object identifier, dataset identifier, query filtering parameters, and query control parameters carried in the data query request and sends the request to the target database. After executing the query, the target database returns the matching data result set to the server. Upon receiving the data returned by the database, the server writes the data to a shared data pool using a reused query key as an index, so that subsequent query requests carrying the same object identifier and generating the same reused query key can directly reuse this data. After the data is successfully written to the shared data pool, the server also encapsulates the query results and returns them to the client.
[0027] As can be seen from the above, this embodiment finds the shared data pool corresponding to the object identifier, with one object identifier corresponding to one shared data pool used to cache historical query data for the target object. This allows multiple data query requests for the same target object to share the same cache container, thus providing a container foundation for subsequent data reuse. Furthermore, since the generation of the reuse query key depends on the dataset identifier, query filtering parameters, and query control parameters—where the query filtering parameters limit the business filtering scope and the query control parameters limit the permission boundaries—the same cache result will only be hit when the dataset type, business filtering conditions, and data query permissions are the same. This avoids permission penetration and data corruption issues that may result from coarse-grained reuse at the source. Based on this, the execution logic of first searching the shared data pool, returning directly if a match is found, and querying the database and backfilling the cache if no match is found ensures that only the first request among multiple requests for the same dataset identifier, the same query filtering parameters, and the same query control parameters will actually access the database. Therefore, this embodiment effectively reduces redundant database query operations, lowers database load, and improves user experience while ensuring data correctness and permission security.
[0028] In one embodiment of this application, if multiple data query requests for a target object are received, the method further includes: The client sends a reuse list, which carries the identifier of reusable data, query filtering parameters, query control parameters and dataset identifier. The identifier of reusable data is used to characterize the reusable data in the data requested by each query request. Retrieve data from the target database corresponding to the identifier of reusable data, and generate a reuse query key based on the dataset identifier, query filtering parameters, and query control parameters; The data corresponding to the identifier of reusable data is written into the shared data retrieval pool using the reuse query key as an index.
[0029] In this embodiment, when the server receives multiple data query requests for the same target object (for example, when the client needs to load a target object page containing multiple data display components), to reduce redundant queries, the client generates a reuse list before initiating these multiple data query requests by analyzing the datasets on which each component (e.g., charts, tables, indicator cards, and filter controls) in the current target object (e.g., a report page or dashboard) depends, along with their corresponding query filtering parameters and query control parameters. This reuse list carries identifiers of reusable data, corresponding query filtering parameters, query control parameters, and dataset identifiers, used to indicate to the server which data has the value of being pre-loaded and stored in the shared data pool during the current interaction with the target object.
[0030] In this embodiment, when a user opens a complex target object (such as a dashboard) containing multiple components, the target object may simultaneously contain a sales trend line chart, a product sales ranking table, a total sales revenue indicator card, and a region filter dropdown. Before sending data retrieval requests for each component to the server (i.e., the aforementioned multiple data query requests), the client first analyzes the computational attribute dependencies of the entire target object to identify which datasets each component depends on, as well as the query filtering parameters and query control parameters used by each component. For example, by parsing the configuration information of each component, the client finds that the line chart and indicator card both depend on a dataset named "DS_ORDER_SUMMARY" and the query filtering parameter for both is "timeRange=2026Q1", while the table depends on a dataset named "DS_PRODUCT_RANKING" and the query filtering parameter is "timeRange=2026Q1&topN=10". The client summarizes the above dependency information to generate a reuse list. This list records the identifier of reusable data (e.g., "DS_ORDER_SUMMARY"), the corresponding query filter parameters ("timeRange=2026Q1"), query control parameters ("userId=10086&role=region_manager"), and dataset identifier. The client then sends the reuse list along with the data retrieval requests for each component to the server. Upon receiving the reuse list, the server parses each record and sends a query request to the target database for each record to prefetch data.
[0031] Taking the "DS_ORDER_SUMMARY" record in the reuse list as an example, the server generates a corresponding reuse query key based on the dataset identifier, query filtering parameters, and query control parameters in this record, following the same method as in the previous embodiment (i.e., normalizing and hashing the query filtering parameters and query control parameters to generate a signature before concatenation). The server then writes the data retrieved from the target database into the shared data retrieval pool using this reuse query key as an index. Subsequently, when the line chart component and the indicator card component initiate data retrieval requests, the server can find the pre-fetched cached data in the shared data retrieval pool and directly return the results without accessing the target database again. The generation trigger condition of the reuse list can be dynamically determined based on the page complexity. For example, the reuse list pre-fetching mechanism can be enabled when the number of components contained in the page exceeds 5. This threshold can be adjusted by the system administrator in the configuration file based on the server's processing capacity and network transmission bandwidth.
[0032] As can be seen from the above, this embodiment pre-analyzes component dependencies and generates a reuse list, which is then sent to the server. This allows the server to complete data loading and caching before receiving the actual data retrieval requests from each component, effectively eliminating the accumulated waiting time caused by each component retrieving data sequentially. This is particularly suitable for complex target object scenarios containing a large number of charts and tables, significantly improving the overall rendering efficiency of the target object page. In one embodiment of this application, before writing the found data into the shared data retrieval pool using the reused query key as an index, the method further includes: determining whether the found data meets the preset cache writing conditions; The process of writing the retrieved data into the shared data pool using the reused query key as an index includes: if the cache write conditions are met, then the retrieved data is written into the shared data pool using the reused query key as an index. The preset cache write conditions include at least one of the following: The amount of data found is less than the preset data volume threshold; The query time for the retrieved data exceeds the preset time threshold. The data found was queried more frequently than a preset frequency threshold within a preset historical time window.
[0033] In this embodiment, the cache write condition refers to the server's requirement to determine whether the data retrieved from the target database meets a series of preset filtering conditions before writing it into the shared data pool. Only data that meets the conditions will be actually written into the shared data pool. The purpose of this mechanism is to avoid storing low-value data with low query frequency, large data volume, or short query time in the cache, thereby preventing memory resources from being wasted on invalid data.
[0034] In this embodiment, not all data retrieved from the target database is suitable for writing to the shared data retrieval pool. For example, some queries may return extremely large result sets of hundreds of thousands of rows, and storing them in the cache would consume a large amount of memory; some queries execute very quickly (e.g., millisecond-level response), and repeated execution has a negligible impact on system performance, so caching them would only increase the overhead of cache management; while some data, although retrieved in the current query, has a very low probability of being queried again, and the benefit of caching this data is very limited. Therefore, before writing the retrieved data to the shared data retrieval pool using the reused query key as an index, the server needs to determine whether the retrieved data meets the preset cache writing conditions.
[0035] Specifically, the preset cache write conditions include at least one of the following three: The first condition is that the amount of data retrieved is less than a preset data volume threshold. After retrieving query results from the target database, the server can count the number of records in the result set or the number of bytes of memory occupied by the data. For example, a data volume threshold of 10,000 records can be set. This threshold can be dynamically calculated based on the server's available memory capacity. For instance, 5% of the server's available memory can be used as an upper limit reference value, and an absolute upper limit can be set in conjunction with the business scenario to avoid a single cached record consuming too much memory. For a server configured with 16GB of memory, this threshold can be set to around 10MB. The technical logic behind this condition is that writing query results with excessively large data volumes to the cache will occupy a large amount of memory space and may even crowd out other high-value cached data. Therefore, only query results with smaller data volumes are cached to protect the overall availability of the shared data retrieval pool.
[0036] The second condition is that the query time corresponding to the found data is greater than a preset time threshold. The server can record the current timestamp before sending the target database query request and record the current timestamp again after receiving the result from the target database. The difference between the two timestamps is the query time. For example, the time threshold can be set to 500 milliseconds. This threshold can be obtained based on the historical average response time of the target database, such as taking twice the average response time of the past 1000 queries as a dynamic threshold. The technical logic of this condition is that for simple queries with extremely fast execution speeds (such as millisecond-level responses), the overhead of directly querying the target database may be lower than the serialization and deserialization overhead of caching, so caching does not benefit anything; therefore, only the results of "slow queries" with long query times and high database computation costs are cached.
[0037] The third condition is that the frequency of the retrieved data being queried within a preset historical time window is greater than a preset frequency threshold. The server can maintain a query access counter for each reused query key, recording the number of times that key has been queried within a recent time window (e.g., the last 10 minutes). For example, the frequency threshold can be set to more than 10 times per minute, which can be derived from historical statistics of business access patterns. The technical logic behind this condition is that frequently queried data has higher reuse value, and caching this type of "hot data" can significantly reduce the pressure of repeated queries on the target database; while data with extremely low query frequency has a very low probability of being accessed again, and its caching value is limited. Furthermore, for a reused query key appearing for the first time (i.e., when the historical query frequency is zero), it can be considered to meet the frequency condition by default and forced to be written to the cache to solve the problem of cache cold start.
[0038] When the retrieved data meets one or more of the above cache write conditions, the server writes the retrieved data to the shared data pool using the reused query key as an index. When the retrieved data does not meet all of the above cache write conditions, the server does not write the retrieved data to the shared data pool, but instead returns the retrieved data directly to the client as the query result to ensure that the normal response to the current query request is not affected.
[0039] As can be seen from the above, this embodiment filters the data entering the shared data pool by setting cache write conditions, so that only data with reuse value will be stored in the cache. This effectively avoids the invalid occupation of cache space by low-value data, achieves a good balance between cache reuse benefits and memory consumption, and improves the overall utilization efficiency of cache resources.
[0040] In one embodiment of this application, the method further includes determining whether the found data meets preset cache write conditions, and then: If the cache write conditions are not met, the corresponding query results will be generated and returned to the client directly.
[0041] In this embodiment, based on the judgment of cache write conditions, when the server determines that the data found from the target database does not meet the preset cache write conditions, the server will not write the data to the shared data pool, but will directly generate the corresponding query results based on the found data and return them to the client.
[0042] In this embodiment, suppose a query returns a result set containing 150,000 records, which significantly exceeds the system's threshold of 10,000 records. Simultaneously, the target database execution time is only 60 milliseconds, far less than the 500 millisecond threshold. Furthermore, the reused query key has only been queried 3 times in the past hour, or 0.05 times per minute, less than the frequency threshold of 10 times per minute. If all three conditions are not met, the server determines that the data has no caching value. In this case, the server directly encapsulates the 150,000 records retrieved from the target database into the query result and returns it to the client, without performing any data writing operations to the shared data pool. Through this processing method, the server effectively avoids a very large result set occupying valuable cache memory space, and also avoids the additional management overhead of creating cache indexes for data with extremely short query times and extremely low reuse probability.
[0043] In this embodiment, it should be noted that although data that does not meet the cache write condition will not be written to the shared data pool, the client can still obtain the query results normally, and the response process of the current query request is not affected in any way. The judgment of the cache write condition only affects the step of "whether to write data to the cache", and does not affect the core process of "whether to return data to the client". In other words, cache writing is an "optional additional operation" whose purpose is to provide accelerated support for subsequent possible repeated queries; while returning the query results to the client is a "necessary regular operation" that must be performed regardless of whether the data is cached.
[0044] As can be seen from the above, this embodiment further optimizes the cache resource allocation strategy by skipping the cache write step when the cache write condition is not met, ensuring that the data stored in the shared data pool is all high-value and highly reusable data, effectively reducing the risk of cache pollution and improving cache hit rate and memory utilization efficiency.
[0045] In one embodiment of this application, the data query request for the target object is generated by the client after detecting a user's selection operation on the target object; further, the method also includes: Receive proactive cleanup requests for an object identifier sent by the client. The proactive cleanup requests are generated after the client detects a user's selection operation on another target object. In response to an active cleanup request, delete the shared data pool corresponding to the object identifier.
[0046] In this embodiment, the data query request for the target object is generated by the client after detecting the user's selection operation on the target object. For example, when the user clicks on the name or thumbnail of a report in the report portal, the client generates a data query request for that report. The proactive cleanup request is a cleanup instruction generated by the client when it detects that the user leaves the current target object and selects another target object. It is used to notify the server to proactively delete the shared data pool corresponding to the current target object in order to release the memory resources it occupies in an immediate manner. For example, when the user is currently browsing the "Monthly Sales Summary Table" which is the current target object, and then clicks to switch to the "Real-time Inventory Monitoring Dashboard" which is another target object in the interface navigation bar, or directly clicks the close button on the "Monthly Sales Summary Table" page tab, the client detects that the user's interaction focus has left the "Monthly Sales Summary Table" and generates a proactive cleanup request for the "Monthly Sales Summary Table".
[0047] In this embodiment, user actions typically exhibit clear session switching characteristics. A user opens a report for viewing, performs several linked filtering operations, closes the report, and opens another different report. When the user opens the first report (e.g., the "RPT_SALES_2026" sales report), the client generates a data query request for that report and sends it to the server. The server establishes a shared data pool corresponding to that report using the aforementioned method and continuously writes and reads data into the pool during subsequent queries. When the user finishes viewing the report and clicks to close the report's tab, open another report, or navigates to other functional modules on the client interface, the client detects that the user has left the current target object. Specific detection methods can include listening for browser tab closing events, route switching events, or user clicks on other report entry points. Once the client detects such a departure event, it immediately generates an active cleanup request for the current target object, which carries the object identifier of that target object. After receiving the proactive cleanup request, the server parses out the object identifier, finds the corresponding shared data retrieval pool instance in the cache pool mapping table based on the object identifier, and then performs a deletion operation to clear the shared data retrieval pool and all cached data therein.
[0048] For example, a user first opens a sales report with the object identifier "RPT_SALES_2026", performs a series of data viewing operations, closes the report, and opens an inventory report with the object identifier "RPT_INVENTORY_2026". The moment the user closes the sales report, the client sends a proactive cleanup request to the server for "RPT_SALES_2026". Upon receiving the request, the server immediately deletes the shared data pool instance corresponding to that report. The timing of the proactive cleanup request can be flexibly controlled by the client based on user behavior. For example, it can be triggered when the user closes a report tab, when the user switches to another report, or after the user has stayed on the current page for more than a predetermined time. This time threshold can be adjusted based on user behavior statistics. For example, if the average time a user spends opening and closing a report in historical data is 8 minutes, the idle trigger threshold can be set to 10 minutes.
[0049] As can be seen from the above, this embodiment achieves timely release of the shared data pool by having the client actively send a cleanup request when the user leaves the target object. This avoids cached data that has completed the interaction occupying memory resources for a long time, effectively improving the turnover efficiency of memory resources and the server's carrying capacity in high-concurrency user scenarios.
[0050] In one embodiment of this application, the method further includes: recording the most recent access time of the shared data retrieval pool; if the difference between the current time and the most recent access time exceeds a preset maximum idle time, then cleaning up the shared data retrieval pool corresponding to the object identifier; and / or, if the system load of the server is detected to exceed a preset load threshold, then cleaning up the shared data retrieval pool corresponding to the object identifier.
[0051] In this embodiment, in addition to the client-triggered cleanup mechanism, a passive cleanup mechanism is also required to handle abnormal situations such as client crashes, network connection interruptions, unexpected browser closures, or prolonged user inactivity preventing the client from sending proactive cleanup requests. This embodiment provides two cleanup strategies, which can be used individually or in combination.
[0052] In this embodiment, the first strategy is cleanup based on maximum idle time. The server records a recent access timestamp for each shared data pool instance. This timestamp is updated to the current system time each time data is read from or written to the shared data pool. A background daemon thread runs on the server. This thread iterates through all currently active shared data pool instances according to a predetermined check cycle, checking the difference between the current system time and the recent access time of each instance. If the difference exceeds a preset maximum idle time threshold, it is determined that the shared data pool has not been accessed for a long time, and the server then performs a cleanup operation to delete the instance. For example, the maximum idle time can be set to 10 minutes. This threshold can be calculated based on the average dwell time of users viewing a single report in the business scenario. For example, if the average time from opening to leaving a report for all users in the past month is 8.5 minutes, then 1.2 times this average time can be taken as the maximum idle time threshold, which is approximately 10 minutes. Suppose the last access time of a shared data pool was 14:30:00. When the background daemon thread checks at 14:41:30, the time difference is 11 minutes and 30 seconds, exceeding the maximum idle time threshold of 10 minutes. The server then deletes the shared data pool instance. The check cycle of the background daemon thread can be set according to the system scale and performance requirements; for example, it can be set to execute every 30 seconds. This cycle value can be adjusted in the system configuration file.
[0053] In this embodiment, the second strategy is system load-based cleanup. The server continuously monitors its own system load status, and the monitoring indicators include, but are not limited to, memory usage, CPU usage, and the total number of currently active shared data pools. When the server's system load exceeds a preset load threshold, the server proactively initiates an emergency cleanup process to clean up some or all of the shared data pools to release memory resources. For example, the memory usage load threshold can be set to 85%. This threshold can be determined based on the server's total memory capacity and the operating system's recommended safe memory level. For a server with 32GB of memory, the operating system typically recommends reserving at least 15% to 20% of free memory to ensure stable system operation. Therefore, setting the memory usage threshold between 80% and 85% is reasonable. When the server detects that the current memory usage has reached 87% and exceeded the 85% threshold, the server immediately initiates an emergency cleanup process. The specific cleanup strategy can be to clean up each shared data pool sequentially according to its most recent access time, from earliest to latest, until the memory usage drops below the 75% recovery level.
[0054] As can be seen from the above, this embodiment establishes a dual fallback cleanup mechanism based on maximum idle time and system load. Even when the client is unable to send an active cleanup request due to abnormal conditions, it can still ensure the timely release of the shared data pool, effectively preventing the risk of memory overflow caused by the infinite accumulation of cached data, and significantly improving the stability and reliability of the system under abnormal conditions.
[0055] Corresponding to the shared data retrieval method in the above embodiments, Figure 2 This is a structural block diagram of a shared data retrieval device provided according to an embodiment of this application. For ease of explanation, only the parts relevant to the embodiment of this application are shown. References Figure 2 The shared data retrieval device 20 includes: a query request receiving module 21, a shared data retrieval pool search module 22, a multiplexed query key generation module 23, and a data retrieval module 24.
[0056] The query request receiving module 21 is used to receive data query requests for a target object sent by the client. The data query request carries an object identifier, a dataset identifier, query filtering parameters, and query control parameters. The dataset identifier is used to characterize the data type of the data requested in the data query request. The query control parameters are used to control the data query permissions for the target object. The query filtering parameters characterize the business filtering conditions applied when querying data for the target object. The business filtering conditions are used to determine the range of data to be queried from the associated data of the target object. The shared data pool lookup module 22 is used to look up the shared data pool corresponding to the object identifier. One object identifier corresponds to one shared data pool, and it is also used to cache historical query data for the target object. The reuse query key generation module 23 is used to generate a reuse query key based on the dataset identifier, query filtering parameters, and query control parameters if a shared data retrieval pool is found. The data retrieval module 24 is used to search for target data that matches the reuse query key from the shared data retrieval pool. If the target data is found, it retrieves the target data from the shared data retrieval pool and generates the corresponding query result to return to the client. If the target data is not found, it searches for data that matches the object identifier from the target database, writes the found data into the shared data retrieval pool with the reuse query key as the index, and generates the corresponding query result to return to the client.
[0057] In one embodiment of this application, if multiple data query requests for a target object are received, the shared data retrieval device 20 further includes: a reuse list module, used for: The client sends a reuse list, which carries the identifier of reusable data, query filtering parameters, query control parameters and dataset identifier. The identifier of reusable data is used to characterize the reusable data in the data requested by each query request. Retrieve data from the target database corresponding to the identifier of reusable data, and generate a reuse query key based on the dataset identifier, query filtering parameters, and query control parameters; The data corresponding to the identifier of reusable data is written into the shared data retrieval pool using the reuse query key as an index.
[0058] In one embodiment of this application, before writing the retrieved data into the shared data retrieval pool using a reused query key as an index, the shared data retrieval device 20 further includes: a cache writing module, used for: Determine whether the found data meets the preset cache write conditions; Among them, the data retrieval module 24 is specifically used for: If the cache write conditions are met, the retrieved data will be written to the shared data pool using the reused query key as an index. The preset cache write conditions include at least one of the following: The amount of data found is less than the preset data volume threshold; The query time for the retrieved data exceeds the preset time threshold. The data found was queried more frequently than a preset frequency threshold within a preset historical time window.
[0059] In one embodiment of this application, the shared data retrieval device 20 further includes: a direct generation module, used for: If the cache write conditions are not met, the corresponding query results will be generated and returned to the client directly.
[0060] In one embodiment of this application, the data query request for the target object is generated by the client after detecting the user's selection operation for the target object; The shared data retrieval device 20 also includes: a first cleaning module, used for: Receive proactive cleanup requests for an object identifier sent by the client. The proactive cleanup requests are generated after the client detects a user's selection operation on another target object. In response to an active cleanup request, delete the shared data pool corresponding to the object identifier.
[0061] In one embodiment of this application, the shared data retrieval device 20 further includes: a second cleanup module, used for: Record the last access time of the shared data pool. If the difference between the current time and the last access time exceeds the preset maximum idle time, clean up the shared data pool corresponding to the object identifier; and / or, If the system load of the server is detected to exceed the preset load threshold, the shared data retrieval pool corresponding to the object identifier will be cleaned up.
[0062] In one embodiment of this application, the query key generation module 23 is specifically used for: Normalize and hash the query filtering parameters to generate parameter signatures; The query control parameters are normalized and hashed to generate a query control signature; A reusable query key is generated by concatenating the dataset identifier, parameter signature, and query control signature.
[0063] See Figure 3 , Figure 3 This is a schematic block diagram of a server provided in one embodiment of this application. Figure 3 The server 300 in this embodiment may include one or more processors 301, one or more input devices 302, one or more output devices 303, and one or more memories 304. The processors 301, input devices 302, output devices 303, and memories 304 communicate with each other via a communication bus 305. The memories 304 store computer programs, including program instructions. The processors 301 execute the program instructions stored in the memories 304. Specifically, the processors 301 are configured to invoke the program instructions to perform the functions of the modules in the above-described device embodiments, for example... Figure 2 The functions of the query request receiving module 21, the shared data pool search module 22, the reuse query key generation module 23, and the data retrieval module 24 are shown.
[0064] It should be understood that, in the embodiments of this application, the processor 301 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0065] Input device 302 may include a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint orientation information), a microphone, etc., and output device 303 may include a display (LCD, etc.), a speaker, etc.
[0066] The memory 304 may include read-only memory and random access memory, and provides instructions and data to the processor 301. A portion of the memory 304 may also include non-volatile random access memory. For example, the memory 304 may also store historical query data, etc.
[0067] In specific implementations, the processor 301, input device 302, and output device 303 described in the embodiments of this application can execute the implementation method described in the shared data retrieval method provided in the embodiments of this application, or they can execute the server implementation method described in the embodiments of this application, which will not be repeated here.
[0068] In another embodiment of this application, a computer-readable storage medium is provided. This computer-readable storage medium stores a computer program, which includes program instructions. When executed by a processor, the program instructions implement all or part of the processes in the methods described above. Alternatively, the computer program can instruct related hardware to complete the process. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include any entity or device capable of carrying computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0069] The computer-readable storage medium can be an internal storage unit of the server in any of the foregoing embodiments, such as the server's hard drive or memory. The computer-readable storage medium can also be an external storage device of the server, such as a plug-in hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., installed on the server. Furthermore, the computer-readable storage medium can include both internal storage units and external storage devices of the server. The computer-readable storage medium is used to store computer programs and other programs and data required by the server. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0070] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0071] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the server and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0072] In the several embodiments provided in this application, it should be understood that the disclosed servers and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connections shown or discussed may be indirect coupling or communication connections through some interfaces or units, or they may be electrical, mechanical, or other forms of connection.
[0073] 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 the embodiments of this application, depending on actual needs.
[0074] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0075] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for sharing a result of taking data, performed by a server, the method comprising: include: The system receives a data query request for a target object sent by a client. The data query request carries an object identifier, a dataset identifier, query filtering parameters, and query control parameters. The dataset identifier is used to characterize the data type of the data requested in the data query request. The query control parameters are used to control the data query permissions for the target object. The query filtering parameters characterize the business filtering conditions applied when querying data for the target object. The business filtering conditions are used to determine the range of data to be queried from the associated data of the target object. Locate the shared data pool corresponding to the object identifier. One object identifier corresponds to one shared data pool, which is used to cache historical query data for the target object. If the shared data retrieval pool is found, a reused query key is generated based on the dataset identifier, the query filtering parameters, and the query control parameters; The system searches for target data that matches the reused query key in the shared data pool. If the target data is found, it retrieves the target data from the shared data pool and generates a corresponding query result, which is then returned to the client. If the target data is not found, it searches for data that matches the object identifier in the target database, writes the found data into the shared data pool using the reused query key as an index, and generates a corresponding query result, which is then returned to the client.
2. The method of claim 1, wherein, If multiple data query requests for a target object are received, the method further includes: The client sends a reuse list, which carries an identifier of reusable data, query filtering parameters, query control parameters, and dataset identifier. The identifier of reusable data is used to characterize the reusable data in the data requested by each query request. The system queries the target database for the data corresponding to the identifier of the reusable data, and generates a reuse query key based on the dataset identifier, the query filtering parameters, and the query control parameters. The data corresponding to the identifier of the reusable data is written into the shared data retrieval pool using the reuse query key as the index.
3. The method of claim 1, wherein, Before writing the retrieved data into the shared data retrieval pool using the reused query key as an index, the process also includes: Determine whether the found data meets the preset cache write conditions; The step of writing the retrieved data into the shared data retrieval pool using the reused query key as an index includes: If the cache write condition is met, the retrieved data will be written to the shared data retrieval pool using the reused query key as the index. The preset cache write conditions include at least one of the following: The amount of data found is less than the preset data volume threshold; The query time for the retrieved data exceeds the preset time threshold. The data found was queried more frequently than a preset frequency threshold within a preset historical time window.
4. The method of claim 3, wherein, The step of determining whether the found data meets the preset cache write conditions further includes: If the cache write conditions are not met, the corresponding query results are directly generated and returned to the client.
5. The method of claim 1, wherein, The data query request for the target object is generated by the client after detecting the user's selection operation for the target object; The method further includes: The system receives an active cleanup request for the object identifier sent by the client, the active cleanup request being generated after the client detects the user's selection operation for another target object; In response to the active cleanup request, the shared data retrieval pool corresponding to the object identifier is deleted.
6. The method of claim 1, wherein, Also includes: Record the most recent access time of the shared data retrieval pool. If the difference between the current time and the most recent access time exceeds the preset maximum idle time, then clean up the shared data retrieval pool corresponding to the object identifier. And / or, If the system load of the server is detected to exceed a preset load threshold, the shared data retrieval pool corresponding to the object identifier is cleaned up.
7. The shared data retrieval method as described in claim 1, characterized in that, The step of generating a reusable query key based on the dataset identifier, the query filtering parameters, and the query control parameters includes: The query filtering parameters are normalized and hashed to generate parameter signatures; The query control parameters are normalized and hashed to generate a query control signature; The reusable query key is generated by concatenating the dataset identifier, the parameter signature, and the query control signature.
8. A shared data retrieval device, characterized in that, include: The query request receiving module is used to receive data query requests for a target object sent by the client. The data query request carries an object identifier, a dataset identifier, query filtering parameters, and query control parameters. The dataset identifier is used to characterize the data type of the data requested in the data query request. The query control parameters are used to control the data query permissions for the target object. The query filtering parameters characterize the business filtering conditions applied when querying data for the target object. The business filtering conditions are used to determine the range of data to be queried from the associated data of the target object. The shared data retrieval pool lookup module is used to find the shared data retrieval pool corresponding to the object identifier. One object identifier corresponds to one shared data retrieval pool, and it is also used to cache historical query data for the target object. The reuse query key generation module is used to generate a reuse query key based on the dataset identifier, the query filtering parameters, and the query control parameters if the shared data retrieval pool is found. The data retrieval module is used to search for target data that matches the reused query key from the shared data retrieval pool. If the target data is found, the module retrieves the target data from the shared data retrieval pool and generates a corresponding query result, which is then returned to the client. If the target data is not found, the module searches for data that matches the object identifier from the target database, writes the found data into the shared data retrieval pool using the reused query key as an index, and generates a corresponding query result, which is then returned to the client.
9. A server comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.
