Data caching method and device, equipment and storage medium
By obtaining and analyzing the number of supplier interface requests, loading historical data into the Redis cache, and performing real-time price verification and dynamically adjusting the failure time, the problem of supplier system performance bottlenecks in the hotel booking industry is solved and system performance and user experience is improved.
Patent Information
- Application Number
- CN202411716541.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-04-29
AI Technical Summary
Performance bottlenecks in supplier systems in the hotel booking industry, especially the limit on query per second (QPS), lead to extended query response time, degraded system performance, and affect user experience and business efficiency.
By getting the number of interface requests for each vendor, identify the target vendor and load its historical data into the Redis cache. Perform real-time price verification processing on supplier data and dynamically adjust the expiration time of data in the cache.
Reduce the direct request volume of supplier system interfaces, reduce system load, and improve performance; ensure the latest cache data, reduce user query errors, and improve response speed and user experience.
Smart Images

Figure CN119903082A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer data processing, and in particular to a data caching method, device, equipment and storage medium. Background Art
[0002] In the current hotel reservation industry, the performance bottleneck of supplier systems, especially the query per second (QPS) limitation, has become a widely recognized technical challenge.
[0003] As demand for online bookings continues to grow and users’ expectations for instant responses and smooth experiences continue to increase, existing supplier systems often suffer from insufficient processing capacity. This overload not only leads to longer query response times, but may also cause an overall decline in system performance, affecting user experience and business efficiency. Summary of the invention
[0004] The present application provides a data caching method, apparatus, device and storage medium, which can reduce the number of queries per second of suppliers and improve the performance of supplier systems.
[0005] In a first aspect, the present application provides a data caching method, including: obtaining the interface request volume of each supplier, and determining the target supplier based on the interface request volume; obtaining the historical data corresponding to the target supplier, determining the supplier data based on the historical data, and loading the supplier data into a Redis cache; performing real-time price verification on the supplier data, and dynamically adjusting the expiration time of the supplier data in the Redis cache based on the real-time price verification results.
[0006] In one possible implementation, the interface request quantity of each supplier is obtained, and a target supplier is determined based on the interface request quantity, specifically including: obtaining the interface request quantity of each supplier, and comparing the interface request quantity corresponding to each supplier with a preset interface request quantity threshold, and when it is detected that the interface request quantity corresponding to the current supplier is not less than the interface request quantity threshold, setting the current supplier as the target supplier.
[0007] In a possible implementation, the obtaining of historical data corresponding to the target supplier and determining the supplier data based on the historical data specifically include: obtaining the historical data of the target supplier within a preset time, wherein the historical data includes historical price data and historical reservation data; performing data analysis on the historical price data to obtain price pattern data, wherein the price pattern data includes a first supplier ID, multiple first dates, and a price corresponding to each first date; performing data analysis on the historical reservation data to obtain predetermined pattern data, wherein the predetermined pattern data includes a second supplier ID, multiple second dates, and an inventory amount corresponding to each second date; and using the price pattern data and the predetermined pattern data as the supplier data.
[0008] In a possible implementation, the loading of the supplier data into the Redis cache specifically includes: associating the first supplier ID in the price rule data with each first date, respectively, to obtain multiple first associated tuples; using the first associated tuple as a key name, and the price corresponding to the first date in the first associated tuple as a key value, to construct a key-value pair, to obtain multiple first key-value pairs; associating the second supplier ID in the historical reservation data with each second date, respectively, to obtain multiple second associated tuples; using the second associated tuple as a key name, and the inventory corresponding to the second date in the second associated tuple as a key value, to construct a key-value pair, to obtain multiple second key-value pairs; and loading the multiple first key-value pairs and the multiple second key-value pairs into the Redis cache, respectively.
[0009] In one possible implementation, the real-time price verification processing of the supplier data specifically includes: sending a real-time data query instruction to the interface of the target supplier, and receiving the real-time supplier data returned by the interface of the target supplier; calculating the supplier data accuracy of the target supplier based on the real-time supplier data and the supplier data corresponding to the target supplier; when it is detected that the supplier data accuracy is not greater than the preset supplier data accuracy, a real-time price verification result is generated as low data accuracy; when it is detected that the supplier data accuracy is greater than the preset supplier data accuracy, a real-time price verification result is generated as high data accuracy.
[0010] In a possible implementation, based on the real-time price verification result, the expiration time of the supplier data in the Redis cache is dynamically adjusted, specifically including: obtaining the first target supplier whose real-time price verification result is low data accuracy, and counting the number of first target suppliers; calculating the supplier pricing rate based on the first target supplier number and the total target supplier number, and when the supplier pricing rate is not greater than a preset supplier pricing rate threshold, shortening the expiration time of the number of suppliers corresponding to the first target supplier in the Redis cache; when the supplier pricing rate is greater than the preset supplier pricing rate threshold, shortening the expiration time of the supplier data corresponding to the first target supplier in the Redis cache, and extending the expiration time of the supplier data corresponding to the second target supplier whose real-time price verification result is high data accuracy in the Redis cache.
[0011] A data caching method provided by the present application also includes: setting a low-frequency sniffing task, and based on the low-frequency sniffing task, performing value analysis on the target supplier to obtain a first value corresponding to the target supplier; based on the first value, deleting the supplier data corresponding to the target supplier stored in the Redis cache.
[0012] In the second aspect, the present application provides a data caching device, including: a target supplier determination module, a supplier data caching module and an expiration time adjustment module; wherein the target supplier determination module is used to obtain the interface request volume of each supplier, and determine the target supplier based on the interface request volume; the supplier data caching module is used to obtain the historical data corresponding to the target supplier, determine the supplier data based on the historical data, and load the supplier data into the Redis cache; the expiration time adjustment module is used to perform real-time price verification on the supplier data, and dynamically adjust the expiration time of the supplier data in the Redis cache based on the real-time price verification results.
[0013] In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.
[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0015] The embodiments of the present application provide a data caching method, apparatus, device, and storage medium, which have the following advantages over the prior art:
[0016] By obtaining the interface request volume of each supplier, the target supplier is determined based on the interface request volume; the historical data corresponding to the target supplier is obtained, the supplier data is determined based on the historical data, and the supplier data is loaded into the Redis cache; by loading the supplier data into the Redis cache, the direct request volume for the supplier system interface can be reduced, thereby reducing the load on the supplier system and improving the performance of the supplier system, especially during high-traffic periods, which helps prevent system overload; by performing real-time price verification on the supplier data and dynamically adjusting the expiration time of the data in the cache according to the price verification results, it can be ensured that the data in the cache is the latest, reducing user query errors caused by outdated data, and in this process, due to the improvement in data retrieval speed, the user's query request can be responded to faster, thereby improving the overall user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0018] In order to more clearly illustrate the embodiments of the present invention 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.
[0019] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0020] Figure 1 It is a flowchart of an embodiment of a data caching method provided by the present application;
[0021] Figure 2 It is a structural diagram of an embodiment of a data cache device provided by the present application;
[0022] Figure 3 is a structural diagram of another embodiment of a data cache device provided by the present application;
[0023] Figure 4 It is a structural schematic diagram of an electronic device provided by this application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0025] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0026] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0027] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0028] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0029] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0030] Example 1, see Figure 1 , Figure 1 is a flow chart of an embodiment of a data caching method provided by the present application, such as Figure 1As shown, the method includes steps 101 to 103, which are specifically as follows:
[0031] Step 101: Obtain the interface request volume of each supplier, and determine the target supplier based on the interface request volume.
[0032] In one embodiment, the interface request volume of each supplier is obtained, and the interface request volume corresponding to each supplier is compared with a preset interface request volume threshold. When it is detected that the interface request volume corresponding to the current supplier is not less than the interface request volume threshold, the current supplier is set as the target supplier.
[0033] Specifically, all first interfaces provided by each supplier are obtained, and the first interface request quantities corresponding to all the first interfaces are obtained, and the sum of all the first interface request quantities is calculated to obtain the interface request quantity corresponding to each supplier.
[0034] Specifically, the number of all the first interfaces may be one or more. When the number of all the first interfaces is plural, all the first interfaces include but are not limited to query interfaces and reservation interfaces.
[0035] Specifically, the interface request volume corresponding to each interface of each supplier is obtained through log analysis, monitoring system or special performance testing tools, the collected interface request volume is analyzed, and the performance of each supplier interface is evaluated.
[0036] Preferably, the interface request volume threshold can be set according to the interface performance of different suppliers to determine the interface request volume threshold corresponding to each supplier; for example, under different interface request volumes, the interface response time of each supplier is evaluated, and the interface request volume threshold is determined based on the interface response time; and according to the system performance of different suppliers, the number of queries per second of each supplier can be personalized evaluated.
[0037] Specifically, when determining the interface request quantity threshold based on the interface response time, the current interface response time and the previous interface response time can be obtained. When the current interface response time is greater than the previous interface response time, the interface request quantity corresponding to the previous interface response time is used as the interface request quantity threshold; the obtained current interface response time can also be judged with the preset interface response time threshold. When the current interface response time is greater than the interface response time threshold, the interface request quantity corresponding to the previous interface response time is obtained and used as the interface request quantity threshold.
[0038] Specifically, when it is detected that the interface request volume corresponding to the current supplier is less than the interface request volume threshold, it is considered that the interface request volume of the current supplier is small, and the current supplier is set as a non-target supplier.
[0039] Preferably, the number of the target suppliers may be one or more, and a unique corresponding supplier ID is set for each target supplier to distinguish different suppliers.
[0040] Specifically, by obtaining the interface request volume corresponding to each supplier, the target supplier with high QPS requests is identified based on the interface request volume, so as to facilitate subsequent corresponding optimization measures to improve its processing capacity.
[0041] Step 102: Obtain historical data corresponding to the target supplier, determine supplier data based on the historical data, and load the supplier data into the Redis cache.
[0042] In one embodiment, historical data of the target supplier within a preset time is obtained, wherein the historical data includes historical price data and historical reservation data.
[0043] Specifically, the historical data within the preset time includes but is not limited to the historical price data and historical reservation data corresponding to each historical day in a plurality of preset historical years; preferably, the plurality of preset historical years are a plurality of consecutive years.
[0044] Preferably, the historical price data refers to the historical prices corresponding to the historical days, and the historical reservation data refers to the historical inventory corresponding to the historical days.
[0045] In one embodiment, data analysis is performed on the historical price data to obtain price pattern data, wherein the price pattern data includes a first supplier ID, multiple first dates, and a price corresponding to each first date.
[0046] Specifically, before performing data analysis on the historical price data, the method further includes: performing data processing on the historical price data, including but not limited to processing missing values and outliers.
[0047] Specifically, the first historical price data corresponding to the same historical day in multiple preset historical years is obtained, and the first historical price data is sorted to obtain a historical daily price data sequence corresponding to each historical day, and the mean of the historical daily price data sequence is calculated to obtain the historical daily average price data corresponding to each historical day; and for each historical day, the historical daily average price data is sorted to generate annual average price data.
[0048] Specifically, each historical day in the annual average price data is taken as the first date, and the historical daily average price data corresponding to each historical day is taken as the price corresponding to the corresponding first date, and combined with the first supplier ID of the target supplier corresponding to the historical price data, the price pattern data is obtained.
[0049] In one embodiment, data analysis is performed on the historical reservation data to obtain reservation regularity data, wherein the reservation regularity data includes a second supplier ID, a plurality of second dates, and an inventory quantity corresponding to each second date.
[0050] Specifically, before performing data analysis on the historical reservation data, the method further includes: performing data processing on the historical reservation data, including but not limited to processing missing values and abnormal values.
[0051] Specifically, the first historical reservation data corresponding to the same historical day in multiple preset historical years is obtained, and the first historical reservation data is sorted to obtain a historical day reservation data sequence corresponding to each historical day, and the mean of the historical day reservation data sequence is calculated to obtain the historical day average reservation data corresponding to each historical day; and for each historical day, the historical day average reservation data is sorted to generate annual average reservation data.
[0052] Specifically, each historical day in the annual average reservation data is used as the second date, and the historical daily average reservation data corresponding to each historical day is used as the inventory corresponding to the corresponding second date, and combined with the second supplier ID of the target supplier corresponding to the historical reservation data, the reservation regular data is obtained.
[0053] Preferably, for the same target supplier, the first supplier ID and the first date in the price rule data are the same as the second supplier ID and the second date in the predetermined rule data.
[0054] In one embodiment, the price rule data and the predetermined rule data are used as supplier data.
[0055] In one embodiment, the first supplier ID in the price pattern data is associated with each first date to obtain multiple first associated tuples; the first associated tuple is used as the key name, and the price corresponding to the first date in the first associated tuple is used as the key value to construct a key-value pair to obtain multiple first key-value pairs.
[0056] Specifically, the first key-value pair is expressed in the form of: first supplier ID-first date-price.
[0057] In one embodiment, the second supplier ID in the historical reservation data is associated with each second date to obtain multiple second associated tuples; the second associated tuple is used as the key name, and the inventory quantity corresponding to the second date in the second associated tuple is used as the key value to construct a key-value pair to obtain multiple second key-value pairs.
[0058] Specifically, the second key-value pair is expressed in the form of: second supplier ID-second date-inventory quantity.
[0059] In one embodiment, the plurality of first key-value pairs and the plurality of second key-value pairs are loaded into a Redis cache respectively.
[0060] Specifically, using Redis as a cache can ensure that the system has key capabilities such as high performance, data persistence, diverse data structures, high availability, flexibility, and real-time monitoring.
[0061] Specifically, the multiple first key-value pairs and the multiple second key-value pairs loaded into the Redis cache are optimized using the Key and Value structure, which can achieve the purpose of saving memory.
[0062] Step 103: Perform real-time price verification on the supplier data, and dynamically adjust the expiration time of the supplier data in the Redis cache based on the real-time price verification result.
[0063] In one embodiment, a real-time data query instruction is sent to the interface of the target supplier, and real-time supplier data returned by the interface of the target supplier is received; based on the real-time supplier data and the supplier data corresponding to the target supplier, the supplier data accuracy of the target supplier is calculated.
[0064] Specifically, a real-time price data query instruction is sent to the interface of the target supplier, and the real-time price returned by the interface of the target supplier is received, and the first real-time date when the real-time price is received is obtained; the first supplier ID corresponding to the target supplier and the first real-time date are associated with each other to obtain a first real-time associated tuple; the first real-time associated tuple is used as the key name, and the real-time price corresponding to the first real-time date in the first real-time associated tuple is used as the key value to construct a key-value pair to obtain a first real-time key-value pair.
[0065] Specifically, based on the first real-time key name in the first real-time key-value pair, all first key names in the multiple first key-value pairs are traversed, and the first key-value pair corresponding to the first key name that is the same as the first real-time key name is taken as the target first key-value pair, and the first difference between the target first key value in the target first key-value pair and the first key value in the first real-time key-value pair is calculated, and based on the first difference, the accuracy between the target first key-value pair and the first real-time key-value pair is calculated to obtain a first accuracy.
[0066] Specifically, a real-time inventory data query instruction is sent to the interface of the target supplier, and the real-time inventory returned by the interface of the target supplier is received, and a second real-time date when the real-time inventory is received is obtained; the second supplier ID corresponding to the target supplier and the second real-time date are associated to obtain a second real-time associated tuple; the second real-time associated tuple is used as the key name, and the real-time inventory corresponding to the second real-time date in the second real-time associated tuple is used as the key value to construct a key-value pair to obtain a second real-time key-value pair.
[0067] Specifically, based on the second real-time key name in the second real-time key-value pair, all second key names in the multiple second key-value pairs are traversed, and the second key-value pair corresponding to the second key name that is the same as the second real-time key name is taken as the target second key-value pair, and the second difference between the target second key value in the target second key value pair and the second key value in the second real-time key value pair is calculated, and based on the second difference, the accuracy between the target second key value pair and the second real-time key value pair is calculated to obtain a second accuracy.
[0068] Specifically, the first accuracy and the second accuracy are weighted averaged to obtain the supplier data accuracy of the target supplier.
[0069] Preferably, a first weight is set for the first accuracy, and a second weight is set for the second accuracy value, a first product of the first accuracy and the first weight is calculated, and a second product of the second accuracy value and the second weight is calculated, and the first product and the second product are added to obtain the supplier data accuracy of the target supplier.
[0070] In one embodiment, when it is detected that the supplier data accuracy is not greater than the preset supplier data accuracy, a real-time price verification result is generated as low data accuracy; when it is detected that the supplier data accuracy is greater than the preset supplier data accuracy, a real-time price verification result is generated as high data accuracy.
[0071] Specifically, when it is detected that the accuracy of the data provided by the supplier is not greater than the preset supplier data accuracy threshold, the system will generate a real-time price verification result marked as "low data accuracy", which means that the data provided by the supplier may have problems, is not accurate enough or is unreliable; on the contrary, if the accuracy of the supplier data exceeds the preset threshold, the system will generate a real-time price verification result of "high data accuracy", indicating that the data is reliable.
[0072] In one embodiment, first target suppliers whose real-time price verification results are low in data accuracy are obtained, and the number of first target suppliers is counted.
[0073] In one embodiment, the supplier pricing rate is calculated based on the first target supplier quantity and the total target supplier quantity.
[0074] Specifically, a subtraction operation is performed on the total target number of suppliers and the first target number of suppliers to obtain a difference in the number of suppliers, and a first proportion of the difference in the number of suppliers in the total target number of suppliers is calculated, and the first proportion is used as the supplier pricing rate.
[0075] In one embodiment, when the supplier pricing rate is not greater than a preset supplier pricing rate threshold, the expiration time of the supplier number corresponding to the first target supplier in the Redis cache is shortened.
[0076] Specifically, if the calculated supplier pricing rate is not greater than the preset supplier pricing rate threshold, it means that the proportion of target suppliers with high data accuracy is lower than that of all target suppliers. At this time, the expiration time of the first supplier data with low data accuracy in the Redis cache will be shortened; the purpose of this is to reduce reliance on inaccurate data and promote more frequent updates of cached data; the expiration time of target supplier data with high data accuracy in the Redis cache remains unchanged.
[0077] In one embodiment, when the supplier pricing rate is greater than a preset supplier pricing rate threshold, the expiration time of the supplier data corresponding to the first target supplier in the Redis cache is shortened, and the expiration time of the supplier data corresponding to the second target supplier whose real-time price verification result is high in data accuracy in the Redis cache is extended.
[0078] Specifically, if the calculated supplier pricing rate is greater than the preset supplier pricing rate threshold, it means that the proportion of target suppliers with high data accuracy is higher than that of all target suppliers. At this time, in addition to shortening the expiration time of the first supplier data with low data accuracy in the Redis cache; the purpose of this is to reduce reliance on inaccurate data and promote more frequent updates of cached data; it will also extend the expiration time of the target supplier data with high data accuracy in the Redis cache, because these data are more reliable, which can reduce the update frequency and improve system efficiency.
[0079] In one embodiment, the expiration time of the supplier data in the Redis cache is dynamically adjusted through the real-time price verification results of the supplier data and the supplier's pricing rate, thereby optimizing system performance and user experience; by reducing reliance on inaccurate data, the system can respond to market changes more quickly and improve the accuracy and efficiency of data processing; at the same time, this also helps to reduce unnecessary data updates, reduce system load, and improve cache utilization efficiency.
[0080] In one embodiment, a low-frequency sniffing task is further provided, and based on the low-frequency sniffing task, a value analysis is performed on the target supplier to obtain a first value corresponding to the target supplier.
[0081] Specifically, the low-frequency sniffing task includes using a network sniffing tool to capture data packets; such as based on the pcap library, using pcap_open_live to open the network interface for real-time sniffing, and setting filtering conditions through pcap_compile and pcap_setfilter, capturing and processing data packets through the pcap_loop loop, and using the callback function got_packet to process each captured data packet.
[0082] Specifically, after capturing data packets, the source IP, destination IP, and port number corresponding to each data packet are checked to determine whether it is the traffic of the target provider, and the number of data packets of the target provider captured within a specific time period is counted.
[0083] Specifically, the number of data packets is subtracted from a preset query number threshold per second to obtain a first data packet difference, and the proportion of the first data packet difference in the query number threshold per second is calculated to obtain a first value.
[0084] Preferably, when the number of data packets is not less than a preset threshold of queries per second, the first data packet difference is a positive number and the first value is a positive value; when the number of data packets is less than the preset threshold of queries per second, the first data packet difference is a negative number and the first value is a negative value.
[0085] In one embodiment, based on the first value, the supplier data corresponding to the target supplier stored in the Redis cache is deleted.
[0086] Specifically, the first value is compared with a preset value threshold. When the first value is not less than the value threshold, the supplier data corresponding to the target supplier corresponding to the first value is retained. When the first value is less than the value threshold, the supplier data corresponding to the target supplier corresponding to the first value is deleted.
[0087] Preferably, the value threshold is 0.
[0088] Specifically, after obtaining the first value of the supplier through value analysis, it can be decided whether the corresponding supplier data needs to be deleted from the Redis cache based on this first value. If the first value of the target supplier is low, it indicates that it has converted from high QPS to low QPS. Therefore, the cache space and resource allocation can be optimized by deleting the data of these suppliers.
[0089] Example 2, see Figure 2 , Figure 2 1 is a schematic diagram of a structure of an embodiment of a data caching device provided by the present application. Corresponding to the above data caching method, the present application also provides a data caching device. The data caching device includes a unit for executing the above data caching method, and the data caching device can be configured in a desktop computer, a tablet computer, a laptop computer, and other terminals. Specifically, the data caching device includes a target supplier determination module 201, a supplier data caching module 202, and an expiration time adjustment module 203.
[0090] The target supplier determination module 201 is used to obtain the interface request quantity of each supplier and determine the target supplier based on the interface request quantity.
[0091] The supplier data cache module 202 is used to obtain historical data corresponding to the target supplier, determine supplier data based on the historical data, and load the supplier data into the Redis cache.
[0092] The expiration time adjustment module 204 is used to perform real-time price verification processing on the supplier data, and dynamically adjust the expiration time of the supplier data in the Redis cache based on the real-time price verification result.
[0093] In one embodiment, the target supplier determination module 201 is used to obtain the interface request quantity of each supplier, and determine the target supplier based on the interface request quantity, specifically including: obtaining the interface request quantity of each supplier, and comparing the interface request quantity corresponding to each supplier with a preset interface request quantity threshold, and when it is detected that the interface request quantity corresponding to the current supplier is not less than the interface request quantity threshold, setting the current supplier as the target supplier.
[0094] In one embodiment, the target supplier determination module 201 is used to obtain historical data corresponding to the target supplier, and determine the supplier data based on the historical data, specifically including: obtaining historical data of the target supplier within a preset time, wherein the historical data includes historical price data and historical reservation data; performing data analysis on the historical price data to obtain price pattern data, wherein the price pattern data includes a first supplier ID, multiple first dates, and a price corresponding to each first date; performing data analysis on the historical reservation data to obtain predetermined pattern data, wherein the predetermined pattern data includes a second supplier ID, multiple second dates, and an inventory corresponding to each second date; and using the price pattern data and predetermined pattern data as supplier data.
[0095] In one embodiment, the supplier data cache module 202 is used to load the supplier data into the Redis cache, specifically including: associating the first supplier ID in the price rule data with each first date to obtain multiple first associated tuples; using the first associated tuple as the key name, and the price corresponding to the first date in the first associated tuple as the key value, to construct a key-value pair to obtain multiple first key-value pairs; associating the second supplier ID in the historical reservation data with each second date to obtain multiple second associated tuples; using the second associated tuple as the key name, and the inventory corresponding to the second date in the second associated tuple as the key value, to construct a key-value pair to obtain multiple second key-value pairs; and loading the multiple first key-value pairs and the multiple second key-value pairs into the Redis cache respectively.
[0096] In one embodiment, the expiration time adjustment module 203 is used to perform real-time price verification processing on the supplier data, specifically including: sending a real-time data query instruction to the interface of the target supplier, and receiving the real-time supplier data returned by the interface of the target supplier; calculating the supplier data accuracy of the target supplier based on the real-time supplier data and the supplier data corresponding to the target supplier; when it is detected that the supplier data accuracy is not greater than the preset supplier data accuracy, a real-time price verification result is generated as low data accuracy, and when it is detected that the supplier data accuracy is greater than the preset supplier data accuracy, a real-time price verification result is generated as high data accuracy.
[0097] In one embodiment, the expiration time adjustment module 203 is used to dynamically adjust the expiration time of the supplier data in the Redis cache based on the real-time price verification result, specifically including: obtaining the first target supplier whose real-time price verification result is low data accuracy, and counting the number of first target suppliers; calculating the supplier pricing rate based on the first target supplier number and the total target supplier number, and when the supplier pricing rate is not greater than a preset supplier pricing rate threshold, shortening the expiration time of the number of suppliers corresponding to the first target supplier in the Redis cache; when the supplier pricing rate is greater than the preset supplier pricing rate threshold, shortening the expiration time of the supplier data corresponding to the first target supplier in the Redis cache, and extending the expiration time of the supplier data corresponding to the second target supplier whose real-time price verification result is high data accuracy in the Redis cache.
[0098] The data cache device provided in this embodiment further includes: a target supplier value calculation module 204, such as Figure 3 As shown, Figure 3It is a structural diagram of another embodiment of a data caching device provided by the present application.
[0099] In one embodiment, the target supplier value calculation module 204 is used to set a low-frequency sniffing task, and based on the low-frequency sniffing task, perform value analysis on the target supplier to obtain a first value corresponding to the target supplier; based on the first value, delete the supplier data corresponding to the target supplier stored in the Redis cache.
[0100] The above data cache device can implement the data cache method of the above method embodiment. The options in the above method embodiment are also applicable to this embodiment and will not be described in detail here.
[0101] like Figure 4 As shown, Figure 4 It is a structural diagram of an electronic device provided by the present application; it includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114, and the memory 113 is used to store computer programs.
[0102] In one embodiment of the present application, the processor 111 is used to implement the data caching method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113.
[0103] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0104] Therefore, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the data caching method provided in any of the aforementioned method embodiments are implemented.
[0105] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which can store program codes. The computer-readable storage medium can be non-volatile or volatile.
[0106] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0107] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0108] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present application can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0109] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0110] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0111] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0112] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A data caching method, characterized in that: include: Obtaining the interface request volume of each supplier, and determining a target supplier based on the interface request volume; Obtaining historical data corresponding to the target supplier, determining supplier data based on the historical data, and loading the supplier data into a Redis cache; The supplier data is subjected to real-time price verification processing, and based on the real-time price verification result, the expiration time of the supplier data in the Redis cache is dynamically adjusted.
2. The method according to claim 1, characterized in that The obtaining of the interface request volume of each supplier and determining the target supplier based on the interface request volume specifically includes: Obtain the interface request quantity of each supplier, and compare the interface request quantity corresponding to each supplier with the preset interface request quantity threshold. When it is detected that the interface request quantity corresponding to the current supplier is not less than the interface request quantity threshold, set the current supplier as the target supplier.
3. The method according to claim 1, characterized in that: The acquiring of historical data corresponding to the target supplier and determining supplier data based on the historical data specifically includes: Acquire historical data of the target supplier within a preset time, wherein the historical data includes historical price data and historical reservation data; Performing data analysis on the historical price data to obtain price pattern data, wherein the price pattern data includes a first supplier ID, a plurality of first dates, and a price corresponding to each first date; Performing data analysis on the historical reservation data to obtain reservation regularity data, wherein the reservation regularity data includes a second supplier ID, a plurality of second dates, and an inventory quantity corresponding to each second date; The price rule data and the predetermined rule data are used as supplier data.
4. The method according to claim 3, characterized in that The step of loading the supplier data into the Redis cache specifically includes: Associating the first supplier ID in the price rule data with each first date respectively to obtain a plurality of first associated tuples; Using the first associated binary group as a key name and the price corresponding to the first date in the first associated binary group as a key value, constructing a key-value pair to obtain a plurality of first key-value pairs; Associating the second supplier ID in the historical reservation data with each second date respectively to obtain a plurality of second associated tuples; Using the second associated binary group as a key name and the inventory quantity corresponding to the second date in the second associated binary group as a key value, constructing a key-value pair to obtain a plurality of second key-value pairs; The multiple first key-value pairs and the multiple second key-value pairs are loaded into the Redis cache respectively.
5. The method according to claim 1, characterized in that: The real-time price verification process of the supplier data specifically includes: Sending a real-time data query instruction to the interface of the target supplier, and receiving the real-time supplier data returned by the interface of the target supplier; Calculating the supplier data accuracy of the target supplier based on the real-time supplier data and the supplier data corresponding to the target supplier; When it is detected that the supplier data accuracy is not greater than the preset supplier data accuracy, a real-time price verification result is generated as low data accuracy; when it is detected that the supplier data accuracy is greater than the preset supplier data accuracy, a real-time price verification result is generated as high data accuracy.
6. The method according to claim 1, characterized in that: Based on the real-time price verification result, dynamically adjust the expiration time of the supplier data in the Redis cache, specifically including: Obtain the first target suppliers whose real-time price verification results show low data accuracy, and count the number of the first target suppliers; Calculate the supplier pricing rate based on the first target supplier quantity and the total target supplier quantity, and when the supplier pricing rate is not greater than a preset supplier pricing rate threshold, shorten the expiration time of the supplier quantity corresponding to the first target supplier in the Redis cache; When the supplier pricing rate is greater than a preset supplier pricing rate threshold, the expiration time of the supplier data corresponding to the first target supplier in the Redis cache is shortened, and the expiration time of the supplier data corresponding to the second target supplier whose real-time price verification result is high in data accuracy in the Redis cache is extended.
7. The method according to claim 1, characterized in that: Also includes: A low-frequency sniffing task is set, and based on the low-frequency sniffing task, a value analysis process is performed on the target supplier to obtain a first value corresponding to the target supplier; Based on the first value, the supplier data corresponding to the target supplier stored in the Redis cache is deleted.
8. A data cache device, characterized in that: include: Target supplier determination module, supplier data cache module and expiration time adjustment module; The target supplier determination module is used to obtain the interface request volume of each supplier and determine the target supplier based on the interface request volume; The supplier data cache module is used to obtain historical data corresponding to the target supplier, determine supplier data based on the historical data, and load the supplier data into the Redis cache; The expiration time adjustment module is used to perform real-time price verification processing on the supplier data, and dynamically adjust the expiration time of the supplier data in the Redis cache based on the real-time price verification results.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 can be implemented.