Multi-project data caching method, device, equipment and storage medium
By building cache center services and generating software development packages in a multi-project environment, the request dispersion and cache redundancy caused by traditional caching methods are solved, and efficient data access and intelligent cache management are achieved.
Patent Information
- Application Number
- CN202411125817.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-08-16
AI Technical Summary
In a multi-project environment, traditional data caching methods lead to data request dispersion and cache redundancy, increasing server load and response delay.
Build a cache center service to store and manage cached data and generate software development packages that allow clients to upload cached service data through standardized interfaces. The Cache Center service obtains matching target data from a preset data source and caches it in the Cache Center.
Through centralized management of cache center services, the data access speed of multiple projects is optimized, network bandwidth consumption is reduced, the pressure on data source server is reduced, and intelligent cache management is realized.
Smart Images

Figure CN118672806B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cache technology, and in particular to a multi-project data cache method, device, equipment and storage medium. Background Art
[0002] In modern Internet applications, with the surge in data volume and the diversification of user needs, there is a large amount of real-time and historical data that needs to be displayed. Without any caching, users need to wait a lot of time to click on query and refresh events, which results in a poor experience. The traditional data processing method is to implement data caching within each project, but when multiple projects or services are involved, each project may have different data access modes and requirements. The cache of each project needs to be maintained independently, which can easily lead to problems such as scattered data requests and cache redundancy, thereby increasing the load and response delay of the data source server.
[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present application is to provide a multi-project data caching method, device, equipment and storage medium, aiming to solve the technical problems of request dispersion and cache redundancy in multi-project data caching, resulting in heavy server load and long response delay.
[0005] To achieve the above purpose, the present application proposes a multi-project data caching method, which is applied to a server. The multi-project data caching method includes:
[0006] Building a cache center service, wherein the cache center service is used to store cache data and manage cache data;
[0007] Generate a software development kit corresponding to the cache center service, wherein the client introduces the software development kit in each application, determines a cache interface according to the software development kit, and uploads cache service data corresponding to each application to the server through the cache interface;
[0008] Receiving cache service data uploaded by the client, wherein the cache service data includes a request address, request parameters, cache time, and refresh time;
[0009] Target data matching the cache service data is acquired from a preset data source, and the target data is cached in a cache center based on the cache center service.
[0010] In one embodiment, the step of acquiring target data matching the cache service data from a preset data source includes:
[0011] Determining a request address and request parameters from the cache service data;
[0012] constructing a first data request according to the request address and the request parameters, and sending the first data request to the preset data source, wherein after receiving the first data request, the preset data source determines target data matching the request address and the request parameters, and sends the target data to the server;
[0013] Receive target data sent by the preset data source.
[0014] In one embodiment, after the step of determining the request address and request parameters from the cache service data, the method further includes:
[0015] Encoding the request address and the request parameters to generate a cache key, wherein the cache key is used as a unique identification code to locate a data entry corresponding to the request address and the request parameters in a cache center;
[0016] Query the cache center to see whether there is a data entry matching the cache key;
[0017] If so, obtaining a data entry matching the cache key from the cache center, and returning the historical target data corresponding to the data entry as the target data to the client;
[0018] If it does not exist, execute the step: construct a first data request according to the request address and the request parameters.
[0019] In one embodiment, after the step of obtaining the data entry matching the cache key from the cache center, the method further includes:
[0020] Get the validity time of the data entry matching the cache key;
[0021] Determining whether the data entry is expired according to the validity period;
[0022] If it is determined that the data entry is expired, construct a second data request according to the request address and the request parameters, send the second data request to the preset data source, receive the first target data returned by the preset data source based on the second data request, replace the corresponding historical target data in the data entry with the first target data, and return the first target data to the client;
[0023] If it is determined that the data entry is not expired, the step of returning the historical target data corresponding to the data entry as target data to the client is executed.
[0024] In one embodiment, the step of caching the target data in the cache center based on the cache center service includes:
[0025] Determine a cache time and a refresh time corresponding to each target data from the cache service data;
[0026] Encapsulate the target data, the cache key corresponding to the target data, the cache time corresponding to the target data, and the refresh time corresponding to the target data into a data entry;
[0027] The data entry is cached in the cache center based on the cache center service.
[0028] In one embodiment, after the step of caching the target data in the cache center based on the cache center service, the method further includes:
[0029] Creating a time wheel and initializing the time wheel, wherein the time wheel consists of a plurality of slots, each slot represents a preset time interval, the time wheel rotates once every preset time interval, and the pointer of the time wheel points to the next slot. After initialization, the pointer of the time wheel points to the first slot;
[0030] Calculate the next update time point of the data entry according to the refresh time corresponding to the target data in each data entry in the cache center, determine the slot in the time wheel that is closest to the current time point and greater than the update time point as the first slot according to the update time point, and store each of the data entries in each of the corresponding first slots;
[0031] Determine that the slot currently pointed to by the pointer is the second slot, and determine whether there is a data entry that needs to be updated in the second slot;
[0032] If so, determining that the data entry to be updated is the first data entry, acquiring first update data corresponding to the target data in the first data entry from a preset data source, and updating the first data entry according to the first update data;
[0033] When the pointer of the time wheel points to the next slot, the execution returns to the step of determining that the slot currently pointed to by the pointer is the second slot, and judging whether there is a data entry that needs to be updated in the second slot.
[0034] In one embodiment, after the step of receiving the cache service data uploaded by the client, the method further includes:
[0035] Inputting the cache service data into a preset prediction model to obtain a prediction probability value of each preset data set;
[0036] When the predicted probability value exceeds a preset threshold, the preset data set corresponding to the predicted probability value is determined to be a first data set, and predicted data corresponding to the first data set is obtained from a preset data source, and the predicted data is cached in a cache center.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a multi-item data caching device, the multi-item data caching device comprising:
[0038] A construction module, used to construct a cache center service, wherein the cache center service is used to store cache data and manage cache data;
[0039] A generation module, used to generate a software development kit corresponding to the cache center service, wherein the client introduces the software development kit in each application, determines a cache interface according to the software development kit, and uploads cache service data corresponding to each application to the server through the cache interface;
[0040] An acquisition module, configured to receive cache service data uploaded by the client, wherein the cache service data includes a request address, request parameters, cache time, and refresh time;
[0041] The cache module is used to obtain target data matching the cache service data from a preset data source, and cache the target data in a cache center based on the cache center service.
[0042] In addition, to achieve the above-mentioned purpose, the present application also proposes a multi-project data caching device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the multi-project data caching method described above.
[0043] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the multi-project data caching method described above are implemented.
[0044] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the multi-item data caching method described above are implemented.
[0045] The present application constructs a cache center service, wherein the cache center service is used to store cache data and manage cache data so as to efficiently process data requests and updates from various projects; generates a software development kit corresponding to the cache center service, wherein the client introduces the software development kit in each application, and determines the cache interface according to the software development kit, and uploads the cache service data corresponding to each application to the server through the cache interface, so as to conveniently use the cache service; receives the cache service data uploaded by the client, wherein the cache service data includes the request address, request parameters, cache time and refresh time, so as to understand the requirements and restrictions of each project; obtains the target data matching the cache service data from the preset data source, and caches the target data in the cache center based on the cache center service. For each project, the cache center service will identify the most frequently accessed data and store it in a fast-access cache to reduce the delay of subsequent requests and the server load. In the present application, by establishing a cache center service to simultaneously process data requests and updates of multiple projects, and caching the data of each project in the cache center service, it is possible to optimize the data access speed of multiple projects, reduce network bandwidth consumption, and reduce the pressure on the data source server, so that multiple projects can simultaneously apply cache technology to achieve centralized management of cache. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A flowchart of a method for caching multiple items of data provided in accordance with the present invention;
[0049] Figure 2 This is a flow chart of applying cache center service in the multi-project data caching method of this application;
[0050] Figure 3 A brief flowchart of the caching technology provided for this application;
[0051] Figure 4 This is a schematic diagram of the module structure of a multi-project data cache device according to an embodiment of the present application;
[0052] Figure 5 Schematic diagram of the device structure of the hardware operating environment involved in the multi-project data caching method in the embodiment of the present application.
[0053] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0054] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0055] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0056] Based on this, the present application embodiment provides a multi-project data caching method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the multi-item data caching method of the present application.
[0057] In this embodiment, the multi-project data caching method includes steps S10 to S40:
[0058] Step S10, constructing a cache center service, wherein the cache center service is used to store cache data and manage cache data;
[0059] It should be noted that this embodiment requires the establishment of a cache center service. The cache center service is used to store and manage data caches. There is a cache center in the cache center service for caching data, and the cache center service can be shared by multiple projects, and does not need to be independently established for each project. When the client or application requests the same data again, it can be quickly read from the cache, avoiding recalculation or retrieving data from the original data source, thereby improving system performance and response speed. Frequent data source queries increase the load on the data source server. By caching frequently accessed data, the number of direct requests to the data source can be significantly reduced, reducing the pressure on the data source and improving the overall system performance.
[0060] Optionally, the cache center service stores cache data from multiple sources, which are usually the most recently used, hot data or calculation results by the client or application to ensure fast access. The cache center service is responsible for managing the life cycle of cache data, including data updates, invalidation policies, consistency and security.
[0061] As the amount of data grows, the cache center service can be expanded horizontally by adding more nodes to share the load, ensuring that performance does not decrease due to the increase in data volume. In a distributed environment, the cache center needs to deal with data consistency issues to ensure that the data seen by all nodes is the latest or consistent according to predetermined rules.
[0062] Optionally, the specific construction process of the cache center service includes selecting a suitable cache center method (such as memory cache or distributed cache), configuring cache strategies and parameters, developing corresponding background management interfaces, etc. Among them, cache strategies can include data survival time, cache update strategy, cache elimination strategy, etc., and cache parameters can include the maximum capacity of the cache, the expiration time of the cache item, the concurrency level, the serialization method, etc. In the background management interface, you can set cache tasks and cache refresh strategies, such as writing cron expressions to determine how to refresh the cache, filling in jobhandler, a method for determining other projects to register with the cache center, and the redis cache database mainly used in this application.
[0063] Step S20, generating a software development kit corresponding to the cache center service, wherein the client introduces the software development kit into each application, determines a cache interface according to the software development kit, and uploads cache service data corresponding to each application to the server through the cache interface;
[0064] It should be noted that this embodiment needs to generate a software development kit (SDK) corresponding to the cache center service for other projects to introduce and use the cache service. The SDK package usually contains relevant interfaces, class libraries and sample codes to facilitate developers to use the cache service. Among them, the class library contains the node information and cache results of each cache node registered with the cache center. The node refers to other applications that have joined the cache center service.
[0065] In the client, add the SDK dependency declaration to the project, set the necessary parameters such as Url, parameters, cache time, refresh time, etc. according to the configuration requirements of the cache center, and then use the methods provided by the SDK to perform cache operations.
[0066] Optionally, design a series of interfaces or methods that allow client applications to perform cache operations, such as reading, writing, updating, and deleting cached data, and encapsulate the logic of the cache service inside the SDK, so that the application does not need to communicate directly with the cache server, but indirectly calls the service through the SDK. Developers add SDKs to applications, usually through dependency management tools (such as npm, Maven, CocoaPods, etc.), or manually add SDK library files to the project. When the application needs to cache data, it calls the corresponding cache write interface in the SDK, and the SDK is responsible for serializing the data and sending it to the cache server over the network.
[0067] It can be understood that encapsulating the core functions of the cache center service enables it to be integrated into client applications, providing a consistent API for developers to use, reducing integration complexity, improving development efficiency, and allowing clients to interact with the cache center service through standardized interfaces.
[0068] Step S30, receiving cache service data uploaded by the client, wherein the cache service data includes a request address, request parameters, cache time, and refresh time;
[0069] It should be noted that when the client project initializes the cache service, it actively reports its configuration information through the SDK's specific interface, collects each project's specific requirements and configurations for the cache service, so that the cache center can provide customized and optimized services.
[0070] Optionally, the configuration service data includes at least the request address (i.e., request URL), request parameters, cache time, and refresh time, among which the URL refers to the entry address of the service, i.e., the URL that the client uses to access the service through the HTTP(S) protocol. The request parameters are the information passed to the service in the HTTP request, which can be a query string, request body (in methods such as POST and PUT), or header information. The cache time (or TTL, Time To Live) refers to the length of time that the data remains valid in the cache. The refresh time indicates when the cached data should be forced to be updated, and the data should be updated even if the cache time limit has not yet been reached.
[0071] For details, please refer to Figure 2 , Figure 2 A flowchart of the application cache center service is provided. First, the cache center service is built and an SDK package is generated for the client project that needs the application cache service to introduce the SDK package. The client uses the SDK package, which has registered the cache interface. Developers use the SDK to integrate the cache service into their projects. Through the interface provided by the SDK, they can configure the relevant parameters of the cache service, including the access URL, request parameters, cache time, and refresh time. The cache center service provides the function of turning the cache service on and off. Through the corresponding interface or background management interface, the administrator can control the status of the cache service. In normal operation, the cache service will automatically update the data according to the configured cache time; when the cache service is turned off, the data will no longer be cached, and the latest data will be obtained directly from the data source.
[0072] Step S40, obtaining target data matching the cache service data from a preset data source, and caching the target data in the cache center based on the cache center service.
[0073] Optionally, the preset data source can be of various types, such as a remote API, a data source, a file system or other services. The required target data is extracted from the data source, and the extraction method includes initiating an HTTP request based on cached service data, executing an SQL query or reading a file.
[0074] Optionally, according to the cache time configured in the cache service data, set the life cycle of the cache data. After this time, the cache data will become invalid and the data will be retrieved from the data source again. Before the cache time is reached, according to the configuration of the refresh time, update the cache in advance to ensure the timeliness of the data.
[0075] Optionally, this embodiment may create a cache entry for each project, use a unique key for identification, and store target data of multiple projects in the cache center simultaneously.
[0076] In a feasible implementation, step S40 may include steps A10 to A30:
[0077] Step A10, determining the request address and request parameters from the cache service data;
[0078] It should be noted that the request URL is the source address of the target data, indicating the specific location or service endpoint of the data. The request parameters include any necessary query parameters, form data or header information to accurately locate and filter the required data.
[0079] In a feasible implementation manner, after step A10, steps B10 to B40 may also be included:
[0080] Step B10, encoding the request address and the request parameters to generate a cache key, wherein the cache key is used as a unique identification code for locating a data entry corresponding to the request address and the request parameters in a cache center;
[0081] It should be noted that the cache key is generated based on the request URL and request parameters, which means that the same request (that is, the same URL and parameters) will always generate the same cache key. Because the same request usually returns the same data, it is safe to store the data in the cache and referenced by the same key.
[0082] Optionally, methods for generating cache keys may include combining the request URL and all parameters by simple string concatenation or more complex serialization. The order of parameters may result in different string results, so the parameters should be sorted or organized in a fixed way to ensure that the same set of parameters always produces the same string. In order to avoid the cache key being too long or containing special characters, the combined string is usually encoded, such as using Base64 or URL encoding. Then, a hash function (such as MD5, SHA-1, or SHA-256) may be applied to further shorten the length of the key while maintaining its uniqueness. In order to avoid cache key conflicts between different types of requests, a prefix or namespace can be added to the cache key for each type or functional area.
[0083] Optionally, when data changes in the data source, the cached data corresponding to the associated cache key should also be updated or invalidated to prevent outdated information from being returned. This can be achieved by versioning the cache key or setting a reasonable cache lifetime (TTL).
[0084] It is understandable that the cache key must be unique so that a specific data entry in the cache center can be accurately located. If two different requests generate the same cache key, the result of one request may be incorrectly returned to the other request, resulting in inconsistent data. By caching frequently accessed data, reducing direct requests to the backend data source, thereby improving response speed and overall system performance, avoiding repeated calculations or data retrieval, and significantly saving computing resources, especially when processing complex or time-consuming queries.
[0085] Step B20, querying the cache center whether there is a data entry matching the cache key;
[0086] Optionally, the cache system looks for a value corresponding to a given cache key. If a match is found, the data exists in the cache. Even if a matching key is found, the status of the data entry needs to be checked, such as whether it has been marked as expired or invalid. If the data is valid, the system returns the data from the cache; if no match is found or the data has expired, this is called a "cache miss." If no data entry matching the cache key is found when querying the cache, the system sends a request to the data source or other data sources to obtain the required data or update expired data.
[0087] It can be understood that by checking the cache, the system can return the data immediately without having to fetch it again from the data source or other data sources, thereby speeding up the response time.
[0088] Step B30: if it exists, obtain the data entry matching the cache key from the cache center, and return the historical target data corresponding to the data entry as the target data to the client;
[0089] Optionally, when the cache is queried, a matching cache key is found, which means that the previously requested data is still stored in the cache and is available. This is a "cache hit" event, which means that the data in the cache can be used immediately to respond to the request without having to access the slower data source again. Once a cache hit is confirmed, the system extracts the data entry associated with the cache key from the cache center. The data entry may contain the following information: the data itself, that is, the actual content requested by the client, such as an HTML page, a piece of JSON data, or a binary file; metadata, which may include some information about the data, such as expiration time (TTL), creation time, last access time, etc.
[0090] Optionally, after obtaining the data entry, the system will check it to ensure its validity (for example, it has not expired). If the data entry is valid, the system will return the data entry as the target data to the client. This process usually includes the following steps: data preparation, ensuring that the data conforms to the client's request format, such as encoding, compression, etc.; building a response, packaging the data into an HTTP response or other protocol response packet, sending the response: sending the response back to the client through the network.
[0091] It is understandable that in the cache system, when receiving a request from a client and checking that a corresponding entry exists in the cache, the system will execute step B30, i.e. directly read the data from the cache and return it to the client. This process is usually much faster than directly querying the data source or other backend data sources because it avoids network latency, data source query time, and backend processing time.
[0092] In a feasible implementation manner, after the step S40 of acquiring the data entry matching the cache key from the cache center, steps C10 to C40 may also be included:
[0093] Step C10, obtaining the validity time of the data entry matching the cache key;
[0094] It should be noted that the validity period is a timestamp or time interval that indicates the maximum time that a data entry remains valid in the cache. Once the validity period of a data entry expires, the system will consider the data entry expired and no longer considered valid data, and the data needs to be retrieved from the backend data source again.
[0095] Optionally, first read the data entry that matches the cache key, including data content, cache key, validity time and other information, and extract the validity time information from the data entry. The validity time can be a relative time based on the current time or an absolute timestamp. Compare the current system time with the validity time of the data entry to determine whether the data has expired.
[0096] Step C20, determining whether the data entry is expired according to the validity period;
[0097] Step C30: if it is determined that the data entry is expired, construct a second data request according to the request address and the request parameters, send the second data request to the preset data source, receive the first target data returned by the preset data source based on the second data request, replace the corresponding historical target data in the data entry with the first target data, and return the first target data to the client;
[0098] It should be noted that when a data entry is determined to be expired, a data request needs to be sent to the preset data source based on the original request URL and request parameters. After receiving the request, the data source will process the request based on the request URL and parameters and return the latest target data. After receiving the target data, the system will re-cache it in the cache center, update the entry corresponding to the cache key, and set a valid time for the new data to determine when the data will expire again in the future.
[0099] Step C40: If it is determined that the data entry has not expired, the step of returning the historical target data corresponding to the data entry as the target data to the client is executed.
[0100] Since the data entry has not expired, the data entry in the cache can be directly returned to the client as the target data. This process is usually much faster than getting data from the backend data source.
[0101] By determining whether the data is expired and taking corresponding measures, the cache system can provide a fast response while maintaining the accuracy and consistency of the data, thereby optimizing the performance of the entire system and user experience.
[0102] Step B40, if it does not exist, execute the step: construct a data request according to the address and request parameters.
[0103] It should be noted that in the cache system, a cache miss refers to when the system tries to retrieve data from the cache and finds that there is no corresponding data entry. The reasons may be: the data has never been requested and therefore has not been cached; the previously cached data has expired, has been automatically cleared or has been eliminated due to cache space limitations; the request parameters have changed, resulting in a mismatch between the generated cache key and the key in the existing cache.
[0104] Optionally, when a cache miss occurs, the system needs to perform the following operations: Build a request. The system will build a complete data request based on the request URL and request parameters, including constructing an HTTP request (such as GET or POST), setting the request header, and preparing the request body (if applicable); Send a request to a preset data source. After building the request, the system will send the request to the preset data source or data source; Wait for a response. After sending the request, the system will wait for the response from the data source; Process the response. When the data source returns a response, the system needs to process the response data, including parsing the response body, converting the data format, or performing data cleaning, etc., to ensure that the data meets the requirements of the application; Store in cache. After processing the response data, the system will store the data entry in the cache so that the same request in the future can directly obtain the data from the cache, thereby avoiding accessing the data source again. When storing, an appropriate cache time (TTL) will also be set to determine the validity period of the data.
[0105] It is understandable that when there is no data entry in the cache that matches the request URL and request parameters, the system needs to take further action to obtain the required data and ultimately respond to the client's request. In the event of a cache miss, the system can still obtain the required data from the data source and optimize future request responses through the cache mechanism, thereby maintaining efficient system operation without affecting the user experience.
[0106] This embodiment generates a cache key by encoding according to the request URL and request parameters, wherein the cache key is used as a unique identification code to locate the data entry corresponding to the request URL and request parameters in the cache center. The cache keys generated based on the same request URL and the same request parameters are the same, ensuring the consistency and reusability of the data; querying whether there is a data entry matching the cache key in the cache center, reading data from the cache is much faster than reading from the data source, thus greatly reducing the data delay; if it exists, obtaining the data entry matching the cache key from the cache center, and returning the target data corresponding to the data entry to the client; if it does not exist, executing the step: sending a data request to the preset data source according to the request URL and request parameters. In this embodiment, by constructing a data acquisition and caching strategy, the burden on the data source can be effectively reduced, and the speed and efficiency of data access can be improved.
[0107] Step A20, constructing a first data request according to the request address and the request parameters, and sending the first data request to a preset data source, wherein after receiving the first data request, the preset data source determines target data matching the request address and the request parameters, and sends the target data to the server;
[0108] Step A30: receiving target data sent by a preset data source.
[0109] Optionally, build a complete data request based on the extracted request URL and parameters. This includes constructing an HTTP request (GET, POST, PUT, etc.), setting the request header, and preparing the request body (if any). For example, for a GET request, you may need to append query parameters to the URL; for a POST request, you may need to include the parameters as part of the request body.
[0110] The "preset data source" here can be any type of data storage, including relational data sources, NoSQL data sources, file systems, or remote API services. The correct data source is selected based on the request URL specified in the cache service data, and the constructed request is sent to the selected data source. To extract the target data from the response returned by the preset data source, it is necessary to parse the HTTP response body, process data in JSON or XML format, or directly read the file content.
[0111] This embodiment builds a cache center service, wherein the cache center service is used to store cache data and manage cache data, so as to efficiently process data requests and updates from various projects; generates a software development kit corresponding to the cache center service, wherein the client introduces the software development kit in each application, and determines the cache interface according to the software development kit, and uploads the cache service data corresponding to each application to the server through the cache interface, so as to conveniently use the cache service; receives the cache service data uploaded by the client, wherein the cache service data includes the request address, request parameters, cache time and refresh time, so as to understand the requirements and restrictions of each project; obtains the target data matching the cache service data from the preset data source, and caches the target data in the cache center based on the cache center service. For each project, the cache center service will identify the most frequently accessed data and store it in a fast-access cache to reduce the delay of subsequent requests and the server load. In this embodiment, by establishing a cache center service to simultaneously process data requests and updates of multiple projects, and caching the data of each project in the cache center service, it is possible to optimize the data access speed of multiple projects, reduce network bandwidth consumption, and reduce the pressure on the data source server, so that multiple projects can simultaneously apply cache technology to achieve centralized management and intelligent cache of cache.
[0112] In a feasible implementation, step S40 may further include steps D10 to D30:
[0113] Step D10, determining the cache time and refresh time corresponding to each target data from the cache service data;
[0114] It should be noted that the cache time defines the length of time that data remains valid in the cache. Once the data exceeds this time, it will be considered expired and will no longer be returned from the cache the next time it is requested, but will trigger the retrieval of the data. The refresh time is an optional parameter that specifies a point in time before the data officially expires, when the cache system will try to retrieval the data in order to update the data in the cache in advance, avoid cache misses when the data expires, and thus reduce burst requests to the backend data source.
[0115] Step D20, encapsulating the target data, the cache key corresponding to the target data, the cache time corresponding to the target data, and the refresh time corresponding to the target data into a data entry;
[0116] Step D30: cache the data entry in the cache center based on the cache center service.
[0117] It is understandable that data items stored in the cache go through a life cycle from creation to expiration or refresh. At different stages of the life cycle, the cache system manages the validity, update, and cleanup of data based on the cache key, cache time, and refresh time.
[0118] In the case of a cache miss, this embodiment first obtains data from the backend data source, then determines the cache time and refresh time of each data item, and stores it in the cache together with the data and cache key. The steps in this embodiment help build an efficient and reliable cache layer, providing users with faster response speeds while reducing the load on the backend system.
[0119] For example, Figure 3 A flow chart of the cache technology used in this application is provided. The little person represents the user, and the numbers 1-4 represent the corresponding steps. 1. The client accesses the server; 2. When accessing the data for the first time, there is no storage in the memory, so it is obtained from the database; 3. After obtaining the data from the database, it is returned to the user; 3', the accessed data is stored in the cache; 4. When accessing the data for the second time, the data is obtained from the cache and returned to the user.
[0120] In the first access to data, data needs to be obtained normally from the data source, and the execution order is 1-2-3. But at the same time, the data needs to be cached, and the execution order is 1-2-3'-4. In this way, in the second access to data, data can be directly obtained from the cache, and the execution order is 1-2'-4, which can effectively reduce the delay when repeated data requests occur.
[0121] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. On this basis, after step S40, the multi-project data caching method further includes steps E10 to E40:
[0122] Step E10, creating a time wheel and initializing the time wheel, wherein the time wheel is composed of a plurality of slots, each slot represents a preset time interval, the time wheel rotates once every preset time interval, and the pointer of the time wheel points to the next slot. After initialization, the pointer of the time wheel points to the first slot;
[0123] It should be noted that the time wheel can be imagined as a ring with multiple slots, each slot representing a preset time interval, such as 1 second, 1 minute or longer. The core idea of the time wheel is to use a cyclic structure instead of a linear time sequence, which can effectively manage a large number of timed events without creating a separate timer or timer for each event. The time wheel rotates once every preset time interval, that is, the pointer of the time wheel moves to the next slot. This rotation mechanism allows the system to check and execute tasks in the slots at fixed time intervals. When the pointer completes a rotation and returns to the first slot, it means that a complete cycle has passed, and the time wheel will start a new cycle.
[0124] Optionally, when creating a time wheel, you first determine the size of the time wheel, that is, how many slots it has. The number of slots and the time interval represented by each slot will be selected based on the specific application scenario and performance requirements. For example, if you need to process events that occur multiple times per second, you can choose a smaller time interval, such as 1 second; if there are fewer events and the intervals are longer, you can choose a larger time interval, such as 1 minute. Initializing the time wheel includes setting the initial state of the time wheel. After initialization, the pointer of the time wheel will point to the first slot. This pointer moves as the preset time interval passes, and each movement will point to the next slot. The movement of the pointer simulates the passage of time. When the pointer points to a slot, it means that the time interval represented by the slot has passed, and the scheduled tasks stored in the slot can be checked and executed.
[0125] Step E20, calculating the next update time point of the data entry according to the refresh time corresponding to the target data in each data entry in the cache center, determining the slot closest to the current time point and greater than the update time point in the time wheel as the first slot according to the update time point, and storing each data entry in each corresponding first slot;
[0126] Optionally, in the cache center, each target data has a refresh time associated with it. The current time is obtained through the system clock, and the refresh cycle of each target data is determined, that is, the time interval from the last refresh to the present and the next refresh. The time point of the next refresh is calculated, usually by adding the current time to the refresh cycle to obtain an absolute timestamp, which is the time point of the next refresh.
[0127] Optionally, once the next refresh time point of each target data is calculated, the next step is to store these data entries in the corresponding slots of the time wheel. Determining which slot in the time wheel is most suitable for storing this data based on the calculated refresh time point can be achieved by converting the refresh time point into a time offset relative to the starting point of the time wheel, and then calculating the specific slot based on the slot interval of the time wheel. After the slot is determined, the target data entry is stored in the slot, and the stored content includes the data itself, the cache key of the data, the refresh time, and other related metadata.
[0128] Step E30, determining that the slot currently pointed to by the pointer is the second slot, and determining whether there is a data entry that needs to be updated in the second slot;
[0129] During the operation of the time wheel, the pointer will continuously move according to the preset time interval, pointing to different slots on the time wheel. When a new time interval point is reached, it is first necessary to determine the slot currently pointed to by the pointer.
[0130] Once the slot that the pointer is currently pointing to is determined, the next step is to check whether there is target data that needs to be updated in the slot. Read the information of all data entries stored in the current slot, including the data's cache key, refresh time, data validity status, etc. For each data entry in the slot, compare the current time with the data's refresh time point to determine whether the current time is equal to or exceeds the refresh time point. If the current time is equal to or exceeds the data's refresh time point, then the data needs to be updated.
[0131] Step E40, if it exists, determining that the data entry to be updated is the first data entry, obtaining first update data corresponding to the target data in the first data entry from a preset data source, and updating the first data entry according to the first update data;
[0132] It should be noted that in the slots of the time wheel, if there is target data that needs to be updated, these target data will be marked as first target data. Once the first target data that needs to be updated is determined, the system will send a request to the preset data source to obtain the first update data corresponding to these target data. The "preset data source" here can be any backend data source, such as a relational data source, a NoSQL data source, an API service, etc., depending on the data storage location and the system architecture. After the first update data is obtained and processed, these data will be used to update the first target data in the cache.
[0133] Step E50, when the pointer of the time wheel points to the next slot, return to the execution step: determine that the slot currently pointed to by the pointer is the second slot, and determine whether there is a data entry that needs to be updated in the second slot.
[0134] By continuously repeating the logic of step E30, the update status of all data in the cache can be continuously monitored. Whenever the pointer of the time wheel moves to a new slot, the system automatically checks whether the data in the slot needs to be refreshed, thereby ensuring that the data in the cache is always up to date and valid.
[0135] In this embodiment, a time wheel is created and initialized, wherein the time wheel is composed of a plurality of slots, each slot represents a preset time interval, the time wheel rotates once at every preset time interval, and the pointer of the time wheel points to the next slot. After initialization, the pointer of the time wheel points to the first slot; the next update time point of the data entry is calculated according to the refresh time corresponding to the target data in each data entry in the cache center, and the slot closest to the current time point and greater than the update time point in the time wheel is determined as the first slot according to the update time point, and each data entry is stored in each corresponding first slot; the slot currently pointed to by the pointer is determined to be the second slot, and it is judged whether there is a data entry that needs to be updated in the second slot. When the pointer of the time wheel rotates to a specific slot, the data in the slot reaches the predetermined refresh time point; if there is, it is determined that the data entry that needs to be updated is the first data entry, and the first update data corresponding to the target data in the first data entry is obtained from the preset data source, and the first data entry is updated according to the first update data, so as to ensure that the data in the cache is the latest, and at the same time, frequent access to the backend data source is avoided, thereby improving the response speed and efficiency of the system. In this embodiment, the time wheel mechanism effectively manages the refreshing of cached data, ensuring the timeliness of data and the efficient operation of the system, especially when processing a large number of scheduled tasks and data updates.
[0136] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above description, and will not be described in detail later. On this basis, the multi-project data caching method further includes steps F10 to F60:
[0137] Step F10, when the target data is cached or accessed from the cache center, corresponding log information is generated;
[0138] It should be noted that log information usually contains request timestamps, which record the exact time when data is accessed or cached, which helps identify peak access periods; request URL, which identifies the specific resource location accessed, which can be a file path, database key, or API endpoint; request parameters; response status code, indicating whether the request is successful, and any related HTTP status codes; response time, which records the time from receiving the request to sending the response, which is a key indicator for evaluating performance; client information, which may include IP address, device type, or browser information, used to identify the source of access; cache status, marking whether the data hits the cache, and the type of cache operation.
[0139] Step F20, obtaining historical access data from all log information, the historical access data including request URL, request time, request frequency, and request parameters;
[0140] It should be noted that the request URL is an identifier of the specific resource that the client is trying to access, which can be a web page address, API endpoint, or database query path, etc.; the request time records the exact time when each request occurs; the request frequency refers to the number of times the same data or a group of resources is requested within a certain time interval, which can help identify popular data and potential load peaks; the request parameters are additional information sent by the client along with the request, which can include query strings, form data, or header information.
[0141] Step F30 analyzes the historical access data to identify user access patterns, which include peak access time, common query types, and high-frequency access data sets;
[0142] It should be noted that peak access times can be analyzed through time series. Peak access time: It is the peak time period for user access identified. Understanding the peak access time helps the system preload data before these periods to ensure high availability of the service. Common query types are the types of query requests issued by the client, which helps to distinguish different types of data access requirements. Highly accessed datasets can identify which datasets are accessed most frequently. These datasets may include popular news articles, high-traffic API calls, common database queries, etc. Understanding high-frequency access datasets can optimize caching strategies to ensure that these data are always in the cache to reduce latency.
[0143] Step F40, building a prediction model based on the user access pattern, the prediction model is used to predict the frequently accessed data set in the future according to the cache service data of the client;
[0144] Optionally, first, extract useful features from historical access data, including but not limited to user access time, access frequency, request type, request parameters, etc. These features will be used as inputs to the prediction model, and select a suitable machine learning model based on the nature of the problem. For the task of predicting future access frequencies, consider using a time series prediction model, a supervised learning model (such as random forest, gradient boosting tree, neural network), or a deep learning model (such as LSTM, GRU); use historical access data to train the model so that the model learns to predict the time points or data sets that may be frequently accessed in the future from the input features; deploy the trained model to the production environment so that it can receive new cache service data in real time or regularly and make predictions.
[0145] After receiving the cache service data uploaded by the client, wherein the cache service data includes the request address, request parameters, cache time and refresh time, the following steps are further included:
[0146] Step F50, inputting the cached service data into a preset prediction model to obtain a prediction probability value of each preset data set;
[0147] After receiving the input data, the model processes it and applies the learned patterns and rules to calculate the probability of each data set being accessed in the future. These probability values reflect the popularity of the data or the potential access demand, and are an important basis for subsequent decisions (such as whether to preload data into the cache).
[0148] The output of the prediction model is a series of predicted probability values corresponding to each data set. These probability values are usually between 0 and 1, where values close to 1 indicate that the data is very likely to be accessed in the near future, while values close to 0 mean that the probability of access is low.
[0149] Step F60, when the predicted probability value exceeds the preset threshold, the preset data set corresponding to the predicted probability value is determined to be the first data set, and the predicted data corresponding to the first data set is obtained from the preset data source, and the predicted data is cached in the cache center.
[0150] It should be noted that in step F60, it is first checked whether the predicted probability value generated by the prediction model exceeds a preset threshold. This threshold is a pre-set value used to distinguish between data with a high probability of access and data with a lower probability. If the predicted probability value of a data set exceeds this threshold, the system believes that the data set is likely to be frequently accessed in the future. Once the data set whose predicted probability value exceeds the threshold is determined, the next step is to obtain this data from a preset data source. The preset data source can be a database, a file system, a remote server, or any place where the original data is stored. Based on the determined data set, the system will send a request to the corresponding data source to obtain complete or partial data. After obtaining the predicted data, the system will cache it in the cache center.
[0151] This embodiment predicts future data access needs by analyzing historical access patterns, thereby preloading data that may be frequently accessed into the cache, achieving dynamic prediction and intelligent caching, which can not only significantly improve data access speed, but also effectively reduce server load, providing users with a smoother and more responsive service experience. This forward-looking caching strategy is particularly suitable for large projects with periodic access patterns or predictable needs, and helps maximize cache efficiency and resource utilization.
[0152] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the multi-project data caching method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0153] This application also provides a multi-project data cache device, please refer to Figure 4 , the multi-project data caching device comprises:
[0154] A construction module 10 is used to construct a cache center service, wherein the cache center service is used to store cache data and manage cache data;
[0155] A generation module 20, for generating a software development kit corresponding to the cache center service, wherein the client introduces the software development kit in each application, determines a cache interface according to the software development kit, and uploads cache service data corresponding to each application to the server through the cache interface;
[0156] An acquisition module 30 is used to receive cache service data uploaded by the client, wherein the cache service data includes a request address, request parameters, cache time and refresh time;
[0157] The cache module 40 is used to obtain target data matching the cache service data from a preset data source, and cache the target data in a cache center based on the cache center service.
[0158] The multi-project data caching device provided by the present application adopts the multi-project data caching method in the above embodiment, which can solve the technical problems of request dispersion and cache redundancy in data caching of multiple projects, resulting in heavy server load and long response delay. Compared with the prior art, the beneficial effects of the multi-project data caching device provided by the present application are the same as the beneficial effects of the multi-project data caching method provided by the above embodiment, and the other technical features in the multi-project data caching device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0159] The present application provides a multi-project data caching device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the multi-project data caching method in the above-mentioned embodiment 1.
[0160] Reference below Figure 5, which shows a schematic diagram of the structure of a multi-item data caching device suitable for implementing an embodiment of the present application. The multi-item data caching device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The multi-project data cache device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0161] like Figure 5 As shown, the multi-item data cache device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the multi-item data cache device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the multi-project data cache device to communicate wirelessly or wired with other devices to exchange data. Although the multi-project data cache device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided alternatively.
[0162] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0163] The multi-project data caching device provided by the present application adopts the multi-project data caching method in the above embodiment, which can solve the technical problems of request dispersion and cache redundancy in data caching of multiple projects, resulting in heavy server load and long response delay. Compared with the prior art, the beneficial effects of the multi-project data caching device provided by the present application are the same as the beneficial effects of the multi-project data caching method provided by the above embodiment, and the other technical features in the multi-project data caching device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0164] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0165] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0166] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, the computer-readable program instructions being used to execute the multi-item data caching method in the above-mentioned embodiment.
[0167] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned multi-project data caching method, and can solve the technical problems of request dispersion and cache redundancy in data caching for multiple projects, resulting in large server load and long response delay. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the multi-project data caching method provided by the above-mentioned embodiment, and will not be repeated here.
[0168] The present application also provides a computer program product, including a computer program, which implements the steps of the multi-item data caching method as described above when executed by a processor.
[0169] The computer program product provided by the present application can solve the technical problems that data caching for multiple projects has request dispersion and cache redundancy, resulting in heavy server load and long response delay. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as those of the multi-project data caching method provided by the above embodiment, and will not be elaborated here.
[0170] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A multi-project data caching method, characterized in that: Applied to a server, the multi-project data caching method includes: Build a cache center service, where the cache center service is used to store cache data from multiple project sources and manage the life cycle of cache data. The construction process of the cache center service includes selecting a cache center mode, configuring cache strategies and parameters, and developing a cache center backend management interface; Generate a software development kit corresponding to the cache center service, wherein the client introduces the software development kit in each application, determines a cache interface according to the software development kit, and uploads cache service data corresponding to each application to the server through the cache interface; Receiving cache service data uploaded by the client, wherein the cache service data includes a request address, request parameters, cache time, and refresh time; Acquire target data matching the cache service data from a preset data source, and cache the target data in a cache center based on the cache center service; Wherein, the multi-project data caching method further includes: When the target data is cached or accessed from the cache center, corresponding log information is generated; Obtain historical access data from all log information, the historical access data including request URL, request time, request frequency, and request parameters; Analyze the historical access data to identify user access patterns, including peak access times, common query types, and high-frequency access data sets; Based on the user access pattern, a prediction model is constructed, wherein the prediction model is used to predict a frequently accessed data set in the future according to the cache service data of the client; Wherein, after the step of receiving the cache service data uploaded by the client, the method further includes: Inputting the cache service data into a preset prediction model to obtain a prediction probability value of each preset data set; When the predicted probability value exceeds a preset threshold, the preset data set corresponding to the predicted probability value is determined to be a first data set, and predicted data corresponding to the first data set is obtained from a preset data source, and the predicted data is cached in a cache center.
2. The multi-project data caching method according to claim 1, characterized in that: The step of acquiring target data matching the cache service data from a preset data source includes: Determining a request address and request parameters from the cache service data; constructing a first data request according to the request address and the request parameters, and sending the first data request to the preset data source, wherein after receiving the first data request, the preset data source determines target data matching the request address and the request parameters, and sends the target data to the server; Receive target data sent by the preset data source.
3. The multi-project data caching method according to claim 2, characterized in that: After the step of determining the request address and request parameters from the cache service data, the method further includes: Encoding the request address and the request parameters to generate a cache key, wherein the cache key is used as a unique identification code to locate a data entry corresponding to the request address and the request parameters in a cache center; Query the cache center to see whether there is a data entry matching the cache key; If so, obtaining a data entry matching the cache key from the cache center, and returning the historical target data corresponding to the data entry as the target data to the client; If it does not exist, execute the step: construct a first data request according to the request address and the request parameters.
4. The multi-project data caching method according to claim 3, characterized in that: After the step of acquiring the data entry matching the cache key from the cache center, the method further includes: Get the validity time of the data entry matching the cache key; Determining whether the data entry is expired according to the validity period; If it is determined that the data entry is expired, construct a second data request according to the request address and the request parameters, send the second data request to the preset data source, receive the first target data returned by the preset data source based on the second data request, replace the corresponding historical target data in the data entry with the first target data, and return the first target data to the client; If it is determined that the data entry is not expired, the step of returning the historical target data corresponding to the data entry as target data to the client is executed.
5. The multi-project data caching method according to claim 3, characterized in that: The step of caching the target data in the cache center based on the cache center service includes: Determine a cache time and a refresh time corresponding to each target data from the cache service data; Encapsulate the target data, the cache key corresponding to the target data, the cache time corresponding to the target data, and the refresh time corresponding to the target data into a data entry; The data entry is cached in the cache center based on the cache center service.
6. The multi-project data caching method according to claim 4, characterized in that: After the step of caching the target data in the cache center based on the cache center service, the method further includes: Creating a time wheel and initializing the time wheel, wherein the time wheel consists of a plurality of slots, each slot represents a preset time interval, the time wheel rotates once every preset time interval, and the pointer of the time wheel points to the next slot. After initialization, the pointer of the time wheel points to the first slot; Calculate the next update time point of the data entry according to the refresh time corresponding to the target data in each data entry in the cache center, determine the slot in the time wheel that is closest to the current time point and greater than the update time point as the first slot according to the update time point, and store each of the data entries in each corresponding first slot; Determine that the slot currently pointed to by the pointer is the second slot, and determine whether there is a data entry that needs to be updated in the second slot; If so, determining that the data entry to be updated is the first data entry, acquiring first update data corresponding to the target data in the first data entry from a preset data source, and updating the first data entry according to the first update data; When the pointer of the time wheel points to the next slot, the execution returns to the step of determining that the slot currently pointed to by the pointer is the second slot, and judging whether there is a data entry that needs to be updated in the second slot.
7. A multi-item data caching device, characterized in that: The multi-item data caching device comprises: A construction module is used to construct a cache center service, wherein the cache center service is used to store cache data from multiple project sources and manage the life cycle of cache data. The construction process of the cache center service includes selecting a cache center mode, configuring cache strategies and parameters, and developing a cache center backend management interface; A generation module, used to generate a software development kit corresponding to the cache center service, wherein the client introduces the software development kit in each application, determines a cache interface according to the software development kit, and uploads cache service data corresponding to each application to the server through the cache interface; An acquisition module, configured to receive cache service data uploaded by the client, wherein the cache service data includes a request address, request parameters, cache time, and refresh time; A cache module, used to obtain target data matching the cache service data from a preset data source, and cache the target data in a cache center based on the cache center service; Wherein, the multi-project data caching device is also used for: When the target data is cached or accessed from the cache center, corresponding log information is generated; Obtain historical access data from all log information, the historical access data including request URL, request time, request frequency, and request parameters; Analyze the historical access data to identify user access patterns, including peak access times, common query types, and high-frequency access data sets; Based on the user access pattern, a prediction model is constructed, wherein the prediction model is used to predict a frequently accessed data set in the future according to the cache service data of the client; Inputting the cache service data into a preset prediction model to obtain a prediction probability value of each preset data set; When the predicted probability value exceeds a preset threshold, the preset data set corresponding to the predicted probability value is determined to be a first data set, and predicted data corresponding to the first data set is obtained from a preset data source, and the predicted data is cached in a cache center.
8. A multi-project data cache device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the multi-project data caching method according to any one of claims 2 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the multi-project data caching method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Data query method and device, electronic equipment and storage medium
CN112685634A
Data processing method and related device
CN114519082A
Data caching method and device, equipment and storage medium
CN115550424A
Cache updating method, device and equipment and computer readable storage medium
CN116842047A