CN112182039A - Data caching method and system - Google Patents

Data caching method and system Download PDF

Info

Publication number
CN112182039A
CN112182039A CN202011056756.XA CN202011056756A CN112182039A CN 112182039 A CN112182039 A CN 112182039A CN 202011056756 A CN202011056756 A CN 202011056756A CN 112182039 A CN112182039 A CN 112182039A
Authority
CN
China
Prior art keywords
data
updating
cache
time
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011056756.XA
Other languages
Chinese (zh)
Inventor
周中雨
郭冬阳
张锐芳
曹宇
赵荣霞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Travelsky Technology Co Ltd
China Travelsky Holding Co
Original Assignee
China Travelsky Holding Co
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Travelsky Holding Co filed Critical China Travelsky Holding Co
Priority to CN202011056756.XA priority Critical patent/CN112182039A/en
Publication of CN112182039A publication Critical patent/CN112182039A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a data caching method and a data caching system, which are used for classifying data, determining updating information of the data of different types, correspondingly caching the data of different types and the updating information of the data of different types, and updating the cached data of different types based on the updating information of the data of different types so as to determine the data meeting effective conditions based on a query request. According to the scheme, when the data is cached, the cached updating information corresponding to the data of different types is included, so that the cached data of different types can be updated based on the updating information of different types, the purpose that when a certain data needs to be searched from the cache, the cached data which is not invalid can be directly searched from the cache is achieved, the problem of time consumption caused by the fact that other systems need to be obtained due to the fact that the data in the cache is invalid when the query request is obtained is solved, the accuracy and the effectiveness of data output when the query request is responded are improved, and user experience is improved.

Description

Data caching method and system
Technical Field
The present application relates to the field of data, and in particular, to a data caching method and system.
Background
When the software runs, a plurality of systems are involved in mutual cooperation, and a large amount of data query and data transmission operations are generated in the cooperation process due to the fact that data in other systems need to be called.
The system response to the user request usually includes the time consumed by the system running and calling other system data. In the system operation process, in order to ensure the response efficiency to the user request in the system operation process, a mode of caching data in other systems by the system is generally adopted.
However, if data in other systems is queried from the cache, the situation that the data in the cache is invalid when the data is queried usually occurs, which leads to the situation that the data acquired by the system in response to a user request is inaccurate.
Disclosure of Invention
In view of this, the present application provides a data caching method and system, and the specific scheme is as follows:
a data caching method, comprising:
classifying the data and determining the updating information of the data of different categories;
caching the data of different types and the updating information of the data of different types in a one-to-one correspondence manner;
updating the cached data of different categories based on the update information of the data of different categories so as to determine the data meeting the effective condition based on the query request.
Further, the determining update information of the different categories of data includes:
the updating frequency and the first updating time of each kind of data are determined based on the class attributes of different classes of data and the data attributes of the data.
Further, the updating the stored data of different categories based on the update information of the data of different categories includes:
determining a second updating time of each kind of data based on the updating frequency and the first updating time of each kind of data;
when the second updating time of the first data is reached, acquiring second data from a data source system of the first data, wherein the second data is real-time data which is stored by the data source system and corresponds to the first data;
and replacing the cached first data with the second data, and caching the second data in one-to-one correspondence with the updating frequency of the first data and the second updating time after adjusting the first updating time to be the second updating time.
Further, the method also comprises the following steps:
acquiring a query request;
determining third data based on the query request, and outputting the third data.
Further, the method also comprises the following steps:
acquiring a predetermined request;
determining whether the third data meets a valid condition based on the predetermined request;
and if the third data meets the effective condition, executing a predetermined operation based on the predetermined request to output a predetermined result.
Further, if the third data meets the valid condition, executing a predetermined operation based on the predetermined request to output a predetermined result, including:
if the third data meets the effective condition, determining whether the second updating time of the third data is reached currently, and if not, executing a predetermined operation based on the predetermined request to output a predetermined result;
and if the third data meets the effective condition and the second updating time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data meeting the effective condition.
Further, the method also comprises the following steps:
if the third data does not meet the effective condition, determining whether the second updating time of the third data is reached currently, and if not, outputting information that the data in the cache changes;
and if the third data does not meet the effective condition and the second updating time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data meeting the effective condition.
Further, whether the third data meets the valid condition includes:
and whether the third data is matched with the data in the cache or not is judged, if so, the third data accords with the effective condition, and if not, the third data does not accord with the effective condition.
A data caching system comprising:
the classification unit is used for classifying the data and determining the updating information of the data of different classes;
the cache unit is used for correspondingly caching the data of different types and the updating information of the data of different types one by one;
and the updating unit is used for updating the cached data of different categories based on the updating information of the data of different categories so as to determine the data meeting the effective conditions based on the query request.
Further, the classification unit is configured to:
the updating frequency and the first updating time of each kind of data are determined based on the class attributes of different classes of data and the data attributes of the data.
According to the technical scheme, the data caching method and the data caching system classify the data, determine the updating information of the data of different types, cache the data of different types and the updating information of the data of different types in a one-to-one correspondence mode, and update the cached data of different types based on the updating information of the data of different types so as to determine the data meeting the effective condition based on the query request. According to the scheme, when the data is cached, the cached updating information which also comprises the data of different types is correspondingly cached, so that the cached data of different types can be updated based on the updating information of different types, the purpose that when a certain data is required to be searched from the cache, the cache data which is not invalid can be directly searched from the cache is achieved, the problem of time consumption caused by the fact that other systems need to be obtained due to the fact that the data in the cache is invalid when the query request is obtained is solved, the accuracy and the validity of data output when the query request is responded are improved, and the user experience is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a data caching method disclosed in an embodiment of the present application;
fig. 2 is a flowchart of a data caching method disclosed in an embodiment of the present application;
fig. 3 is a schematic structural diagram of a data caching system according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The application discloses a data caching method, a flow chart of which is shown in fig. 1, comprising the following steps:
step S11, classifying the data and determining the updating information of the data of different categories;
the system acquires data from other systems or programs in advance and then classifies and stores the data.
Specifically, the data is classified, at least the actual service and scene corresponding to the data can be classified, and the classification rule is determined by combining the property of the data.
For example: taking flight information as an example, classification may be based on the nature of the arriving airport, such as: similar international aviation hubs have higher flight inquiry frequency and can be set as the same type of data and the same updating information; such as: the flight inquiry frequency of similar regional hubs is low, and the similar regional hubs can be set as the same type of data and the same updating information; further, the information of the international aviation hub class and the information of the regional hub class can be set into different classes of data, so that different data updating information can be set based on different query frequencies;
or, the query frequency can be affected according to factors such as flight distance, whether transfer exists, and the space, and all the factors can be used as the basis for data classification.
The data can be classified by using a certain parameter as a classification basis, or by using various parameters as classification basis.
In addition, a plurality of data of the same category may have different update information depending on the attribute of the data itself.
Wherein, the update information at least includes: the update frequency and the first update time.
The update frequency is how often the data is updated, the data is valid at the interval of updating the data, and when the data reaches the time required to be updated in the update frequency, the data is invalid and needs to be updated.
The first update time is the time for caching the data in the current cache into the system, and the second update time is the time for the data in the current cache to reach the time needing to be updated, namely the first update time is t0I.e. the time for storing the data in the current cache into the system, update periodPeriod is T, and the second update time is T1That is, the time required to update the data in the current cache after reaching an update cycle, specifically, t1=t0+T。
Step S12, caching the data of different types and the updating information of the data of different types in a one-to-one correspondence manner;
and step S13, updating the cached data of different categories based on the updating information of the data of different categories so as to determine the data meeting the effective conditions based on the query request.
The data cached in the system not only stores the data itself, but also stores the data type related to the data and the update information of the data.
Therefore, the system can directly count time based on the timer, whether an update period is reached after the data is updated from the cache is determined based on the timing of the timer, if the update period is reached, the current time is the second update time, and then the data cached in the system is updated to the data which is obtained again, so that the aim of updating the data in the cache is fulfilled.
Specifically, the second updating time of each kind of data is determined based on the updating frequency and the first updating time of each kind of data; when the second updating time of the first data is reached, acquiring second data from the data source system of the first data, wherein the second data is real-time data which is stored by the data source system and corresponds to the first data; and replacing the cached first data with second data, adjusting the first updating time to be second updating time, and caching the second data and the updating frequency and the second updating time of the first data in a one-to-one correspondence manner.
Each data stored in the cache has a corresponding data source system, and the data of the data source system is stored in the cache, so that the data can be directly called from the cache without being connected with other systems when being called, and the data can be called from other systems in real time.
In order to ensure the validity of the data, different update frequencies of different data in the cache are set.
For example: the first data in the cache is acquired at a first time, the updating period of the first data is a first period, the duration of the first period after the first data is stored in the cache is a second period, at this time, the first data in the cache is not valid any more after the first period passes, and needs to be updated, so that the real-time data corresponding to the first data is acquired from the data source system of the first data again, the first data stored in the cache is replaced by the currently acquired real-time data, namely the second data, and at this time, the time is the second time.
At this time, all the information related to the first data stored in the cache is replaced by the information related to the second data, such as: the information related to the first data includes: replacing the first data, the period or frequency of the first data, and the first time of the first data with information associated with the second data, wherein the information associated with the second data comprises: the second data, the period or frequency of the second data, and the first time of the second data, wherein the period or frequency of the second data is the same as the period or frequency of the first data, and the first time of the second data is the second time of the first data.
Further, when determining the update information of the data, the update information needs to be determined not only based on the category attribute of the category to which the data belongs, but also based on the data attribute of the data itself, and the data attribute of the data itself may be: age of the data itself.
The period or frequency in the update information of the data is related to at least the age of the data itself, in addition to the category to which the data belongs.
For example: and if the updating period of the data category to which the first data belongs is 30 minutes and the aging of the first data is 20 minutes, determining that the updating period of the first data is 20 minutes to determine that the first data in the cache is always in a valid state.
The data caching method disclosed in this embodiment classifies data, determines update information of data of different categories, caches the data of different categories and the update information of the data of different categories in a one-to-one correspondence manner, and updates the cached data of different categories based on the update information of the data of different categories, so as to determine the data meeting the effective condition based on the query request. According to the scheme, when the data is cached, the cached updating information which also comprises the data of different types is correspondingly cached, so that the cached data of different types can be updated based on the updating information of different types, the purpose that when a certain data is required to be searched from the cache, the cache data which is not invalid can be directly searched from the cache is achieved, the problem of time consumption caused by the fact that other systems need to be obtained due to the fact that the data in the cache is invalid when the query request is obtained is solved, the accuracy and the validity of data output when the query request is responded are improved, and the user experience is improved.
The present embodiment discloses a data caching method, a flowchart of which is shown in fig. 2, and the method includes:
step S21, classifying the data and determining the updating information of the data of different categories;
step S22, caching the data of different types and the updating information of the data of different types in a one-to-one correspondence manner;
step S23, updating the cached data of different categories based on the updating information of the data of different categories;
step S24, acquiring a query request;
and step S25, determining third data based on the query request and outputting the third data.
When different data are updated at different frequencies based on the attributes of the different data in the system, a query request of a user is obtained, wherein the query request of the user is a request sent by the user when the user queries the data of other systems based on the system.
When the system acquires the query request, because the system caches the relevant data, the system determines the data in the query request based on the query request so as to determine the third data in the cache, and if the cache of the system comprises the third data, the system determines the third data and outputs the third data.
If the user only inquires the information without performing subsequent operations, such as: and the reservation is carried out, so that the subsequent steps are not required, and the efficiency of returning data is ensured. For example: the query request sent by the user is to query flight information, and after the system returns the flight information in the cache to the equipment, the user does not make a reservation based on the flight information, but only executes query operation, so that the system directly returns the flight information in the cache to the user, and the flight information does not need to be returned after being acquired by the system, and the efficiency of data feedback is improved.
If the user needs to perform a predetermined operation based on the acquired third data, then:
and acquiring a predetermined request, determining whether the third data meets the effective condition based on the predetermined request, and if the third data meets the effective condition, executing a predetermined operation based on the predetermined request to output a predetermined result.
Only when the predetermined operation needs to be performed, whether the third data meets the valid condition is determined. Specifically, whether the third data meets the valid condition may be: and whether the third data is matched with the data in the cache or not, if so, the third data accords with the effective condition, and if not, the third data does not accord with the effective condition.
The third data is data in the system cache acquired by the user based on the query request, after the system feeds the third data back to the device, if the user needs to execute a predetermined operation, the user needs to send a predetermined request, and after the predetermined request is sent, whether the third data in the cache is consistent with the third data fed back to the device or not needs to be determined, that is, whether the third data in the cache is updated or not needs to be determined.
When the third data is matched with the data in the cache, the third data in the cache is not updated, and the second update time is not reached, at this time, the third data returned to the device is consistent with the third data in the cache, and the predetermined operation can be directly performed on the basis of the third data returned to the device without acquiring the updated data from the cache again;
when the third data is not matched with the data in the cache, that is, after the third data in the cache returns to the device, the third data in the cache is updated, at this time, the third data in the cache is not consistent with the third data returned to the device, and the third data returned to the device needs to be updated, so that a predetermined operation is performed based on the updated third data, or the predetermined operation is directly performed based on the updated data in the cache, and at this time, the third data returned to the device does not need to be updated.
Further, the method also comprises the following steps:
if the third data does not meet the effective condition, determining whether the second updating time of the third data is reached currently, and if not, outputting information that the data in the cache changes;
and if the third data does not accord with the effective condition and the second updating time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data which accords with the effective condition.
Specifically, if the third data is not matched with the data in the cache, it is required to determine whether the third data in the cache reaches a second update time, and if the third data in the cache reaches the second update time, the third data in the cache is updated, specifically, an inquiry request is sent to a data source system of the third data, so that the data source system can feed back the latest third data to the system, so that the latest third data is stored in the cache of the system, and then the third data in the cache is fed back to the device, so that the third data fed back to the device is also the latest third data, and thus, the user can perform predetermined operation based on the latest third data.
After the third data in the system cache is updated, the time for updating the third data is recorded and confirmed as the second updating time, so that the third data can be updated subsequently based on the updating frequency of the third data.
Specifically, if the third data does not match the data in the cache, and at the same time, the second update time of the third data in the system cache is not currently reached, it indicates that, after the system feeds back the data in the cache to the device, and before the system receives the predetermined request, in this time period, the third data in the system cache reaches the second update time, and the data in the system cache is updated, and then, after the predetermined request is obtained, the data in the system cache does not reach the next update time, at this time, the updated information of the third data in the cache may be returned to the device, that is, the information of the change of the data in the cache, so that the user can clearly determine that the data in the cache has changed.
The information that the third data changes may be: the updated third data and the situation of the third data changing may be specifically the time or the amount of change of the third data, or the value before the third data changes and the value after the third data changes.
Further, if the third data meets the valid condition, performing a predetermined operation based on the predetermined request to output a predetermined result, including:
if the third data meets the effective condition, determining whether the second updating time of the third data is reached currently, and if not, executing a predetermined operation based on a predetermined request to output a predetermined result; and if the third data meets the effective condition and the second update time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data meeting the effective condition.
If the third data matches with the data in the system cache, and the third data in the system cache does not reach the second update time, and does not need to be updated, the user may perform a reservation based on the current third data directly at this time, for example: reserving a seat on a flight, and then outputting a reservation result by the equipment, such as: the outcome of the reservation success or the reservation failure.
Wherein, the predetermined failure may be: when a user makes a reservation for a seat, other people are reserving the seat, the reservation may fail, or when the data in the cache or the data of the data source system of the third data is updated while the user makes the reservation, and the update is related to the seat or date reserved by the user, the reservation may fail.
If the third data is matched with the data in the system cache and the third data in the system cache reaches the second updating time, at this time, the third data in the system cache needs to be updated first, and after the third data in the system cache is updated, the third data fed back to the device is updated, or the third data fed back to the device is not updated, but the updated third data is directly operated in the system cache so as to complete the predetermined operation.
And updating the third data in the system cache, namely acquiring the updated third data from the data source system of the third data so as to replace the third data in the system cache according to the updated third data, so that the third data in the system cache is updated.
Further, the data may include, in addition to the update frequency: a validity period, wherein the update frequency is typically the same as or may be different from the validity period. For example: the update frequency of the data is: updating once every 30 minutes, and meanwhile, if the validity period of the data is 30 minutes, the validity period of the data is the same as the updating frequency; if the update frequency of the data is 1 hour and the validity period is 30 minutes, the validity period of the data is different from the update frequency, and at this time, the data may be data with a low query frequency and does not need to be updated frequently.
For example: the system firstly records a list of airlines supported by each airline department into the system, classifies all airlines of each airline department according to a certain rule, wherein an airline from Beijing to mansion is taken as an example, if three airlines, namely an airline A, an airline B and an airline C support the airline, classification results are respectively a class A hot airline, a class B common airline and a class C cold airline, and data aging set by the airlines corresponding to the three airlines is 30 minutes.
Respectively setting corresponding updating frequency, cache aging calculation modes and the like for each category, wherein the updating frequency, the cache aging calculation modes and the like are as follows: the class A hot data and the query and reservation frequency are high, the data can change frequently, and a high updating frequency and a short cache aging can be set, such as: updating every 10 minutes, and the cache aging is also 10 minutes; for the C-type cold data, the query and reservation frequency is low, the data updating is not frequent, and the lower updating frequency and the longer cache aging can be set, such as: update every hour, buffer age 30 minutes.
The user sends a query request, the query request is the flight information from Beijing to mansion, and all the information supporting the query is cached in advance, and the data is updated regularly, so the flight information provided by the airlines A, B and C supporting the airline can be directly queried from the cache, and the cached flight information is directly returned to the user after being integrated, and the system of each airline is not required to be called for query.
The user selects one flight to send a booking request according to the inquired flight information, compares the flight information in the booking request with the corresponding flight information in the cache, if the seat state and the price in the request data are equal to the data in the cache, continuously judges whether the flight data in the cache is valid, if the data are valid, directly sends the booking request to the airline company, and returns the result to the user; if the flight data in the cache fails, the validity period of the data of the airline company is exceeded, and the airline company system needs to be inquired again to obtain the flight data.
If the information in the request data is inconsistent with the information in the cache, the information in the cache is updated, whether the flight data in the cache is valid or not is determined, if the flight data in the cache is valid, the data in the cache is available, the flight data in the cache is returned to the user, and the user is informed that the flight information changes; and if the flight data in the cache fails, the airline system is inquired again to obtain the flight data.
Further, after new flight data are inquired from the airline company system, cache aging is calculated according to the data types, the flight data and the cache aging are updated into a cache, meanwhile, information in the inquired flight data is compared with information in the request data, if the data are consistent, a reservation request is made to the airline company, and the result is returned to the user; if the data are inconsistent, returning the inquired flight data to the user and informing the user that the flight information changes.
The data caching method disclosed in this embodiment classifies data, determines update information of data of different categories, caches the data of different categories and the update information of the data of different categories in a one-to-one correspondence manner, and updates the cached data of different categories based on the update information of the data of different categories, so as to determine the data meeting the effective condition based on the query request. According to the scheme, when the data is cached, the cached updating information which also comprises the data of different types is correspondingly cached, so that the cached data of different types can be updated based on the updating information of different types, the purpose that when a certain data is required to be searched from the cache, the cache data which is not invalid can be directly searched from the cache is achieved, the problem of time consumption caused by the fact that other systems need to be obtained due to the fact that the data in the cache is invalid when the query request is obtained is solved, the accuracy and the validity of data output when the query request is responded are improved, and the user experience is improved.
The present embodiment discloses a data caching system, a schematic structural diagram of which is shown in fig. 3, and the data caching system includes:
a classification unit 31, a buffer unit 32 and an update unit 33.
The classification unit 31 is configured to classify data and determine update information of different types of data;
the cache unit 32 is configured to cache the different types of data and the update information of the different types of data in a one-to-one correspondence manner;
the updating unit 33 is configured to update the cached data of different categories based on the update information of the data of different categories, so that the query request can be given data determined to meet the valid condition.
The system acquires data from other systems or programs in advance and then classifies and stores the data.
Specifically, the data is classified, at least the actual service and scene corresponding to the data can be classified, and the classification rule is determined by combining the property of the data.
For example: taking flight information as an example, classification may be based on the nature of the arriving airport, such as: similar international aviation hubs have higher flight inquiry frequency and can be set as the same type of data and the same updating information; such as: the flight inquiry frequency of similar regional hubs is low, and the similar regional hubs can be set as the same type of data and the same updating information; further, the information of the international aviation hub class and the information of the regional hub class can be set into different classes of data, so that different data updating information can be set based on different query frequencies;
or, the query frequency can be affected according to factors such as flight distance, whether transfer exists, and the space, and all the factors can be used as the basis for data classification.
The data can be classified by using a certain parameter as a classification basis, or by using various parameters as classification basis.
In addition, a plurality of data of the same category may have different update information depending on the attribute of the data itself.
Wherein, the update information at least includes: the update frequency and the first update time.
The update frequency is how often the data is updated, the data is valid at the interval of updating the data, and when the data reaches the time required to be updated in the update frequency, the data is invalid and needs to be updated.
The first update time is the time for caching the data in the current cache into the system, and the second update time is the time for the data in the current cache to reach the time needing to be updated, namely the first update time is t0That is, the time for storing the data in the current cache to the system is T, the update period is T, and the second update time is T1That is, the time required to update the data in the current cache after reaching an update cycle, specifically, t1=t0+T。
The data cached in the system not only stores the data itself, but also stores the data type related to the data and the update information of the data.
Therefore, the system can directly count time based on the timer, whether an update period is reached after the data is updated from the cache is determined based on the timing of the timer, if the update period is reached, the current time is the second update time, and then the data cached in the system is updated to the data which is obtained again, so that the aim of updating the data in the cache is fulfilled.
Specifically, the second updating time of each kind of data is determined based on the updating frequency and the first updating time of each kind of data; when the second updating time of the first data is reached, acquiring second data from the data source system of the first data, wherein the second data is real-time data which is stored by the data source system and corresponds to the first data; and replacing the cached first data with second data, adjusting the first updating time to be second updating time, and caching the second data and the updating frequency and the second updating time of the first data in a one-to-one correspondence manner.
Each data stored in the cache has a corresponding data source system, and the data of the data source system is stored in the cache, so that the data can be directly called from the cache without being connected with other systems when being called, and the data can be called from other systems in real time.
In order to ensure the validity of the data, different update frequencies of different data in the cache are set.
For example: the first data in the cache is acquired at a first time, the updating period of the first data is a first period, the duration of the first period after the first data is stored in the cache is a second period, at this time, the first data in the cache is not valid any more after the first period passes, and needs to be updated, so that the real-time data corresponding to the first data is acquired from the data source system of the first data again, the first data stored in the cache is replaced by the currently acquired real-time data, namely the second data, and at this time, the time is the second time.
At this time, all the information related to the first data stored in the cache is replaced by the information related to the second data, such as: the information related to the first data includes: replacing the first data, the period or frequency of the first data, and the first time of the first data with information associated with the second data, wherein the information associated with the second data comprises: the second data, the period or frequency of the second data, and the first time of the second data, wherein the period or frequency of the second data is the same as the period or frequency of the first data, and the first time of the second data is the second time of the first data.
Further, when determining the update information of the data, the update information needs to be determined not only based on the category attribute of the category to which the data belongs, but also based on the data attribute of the data itself, and the data attribute of the data itself may be: age of the data itself.
The period or frequency in the update information of the data is related to at least the age of the data itself, in addition to the category to which the data belongs.
For example: and if the updating period of the data category to which the first data belongs is 30 minutes and the aging of the first data is 20 minutes, determining that the updating period of the first data is 20 minutes to determine that the first data in the cache is always in a valid state.
Further, the method also comprises the following steps: an acquisition unit.
The acquisition unit is used for acquiring the query request, determining third data based on the query request and outputting the third data.
When different data are updated at different frequencies based on the attributes of the different data in the system, a query request of a user is obtained, wherein the query request of the user is a request sent by the user when the user queries the data of other systems based on the system.
When the system acquires the query request, because the system caches the relevant data, the system determines the data in the query request based on the query request so as to determine the third data in the cache, and if the cache of the system comprises the third data, the system determines the third data and outputs the third data.
If the user only inquires the information without performing subsequent operations, such as: and the reservation is carried out, so that the subsequent steps are not required, and the efficiency of returning data is ensured. For example: the query request sent by the user is to query flight information, and after the system returns the flight information in the cache to the equipment, the user does not make a reservation based on the flight information, but only executes query operation, so that the system directly returns the flight information in the cache to the user, and the flight information does not need to be returned after being acquired by the system, and the efficiency of data feedback is improved.
If the user needs to perform a predetermined operation based on the acquired third data, then:
and acquiring a predetermined request, determining whether the third data meets the effective condition based on the predetermined request, and if the third data meets the effective condition, executing a predetermined operation based on the predetermined request to output a predetermined result.
Only when the predetermined operation needs to be performed, whether the third data meets the valid condition is determined. Specifically, whether the third data meets the valid condition may be: and whether the third data is matched with the data in the cache or not, if so, the third data accords with the effective condition, and if not, the third data does not accord with the effective condition.
The third data is data in the system cache acquired by the user based on the query request, after the system feeds the third data back to the device, if the user needs to execute a predetermined operation, the user needs to send a predetermined request, and after the predetermined request is sent, whether the third data in the cache is consistent with the third data fed back to the device or not needs to be determined, that is, whether the third data in the cache is updated or not needs to be determined.
When the third data is matched with the data in the cache, the third data in the cache is not updated, and the second update time is not reached, at this time, the third data returned to the device is consistent with the third data in the cache, and the predetermined operation can be directly performed on the basis of the third data returned to the device without acquiring the updated data from the cache again;
when the third data is not matched with the data in the cache, that is, after the third data in the cache returns to the device, the third data in the cache is updated, at this time, the third data in the cache is not consistent with the third data returned to the device, and the third data returned to the device needs to be updated, so that a predetermined operation is performed based on the updated third data, or the predetermined operation is directly performed based on the updated data in the cache, and at this time, the third data returned to the device does not need to be updated.
Further, the method also comprises the following steps:
if the third data does not meet the effective condition, determining whether the second updating time of the third data is reached currently, and if not, outputting information that the data in the cache changes;
and if the third data does not accord with the effective condition and the second updating time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data which accords with the effective condition.
Specifically, if the third data is not matched with the data in the cache, it is required to determine whether the third data in the cache reaches a second update time, and if the third data in the cache reaches the second update time, the third data in the cache is updated, specifically, an inquiry request is sent to a data source system of the third data, so that the data source system can feed back the latest third data to the system, so that the latest third data is stored in the cache of the system, and then the third data in the cache is fed back to the device, so that the third data fed back to the device is also the latest third data, and thus, the user can perform predetermined operation based on the latest third data.
After the third data in the system cache is updated, the time for updating the third data is recorded and confirmed as the second updating time, so that the third data can be updated subsequently based on the updating frequency of the third data.
Specifically, if the third data does not match the data in the cache, and at the same time, the second update time of the third data in the system cache is not currently reached, it indicates that, after the system feeds back the data in the cache to the device, and before the system receives the predetermined request, in this time period, the third data in the system cache reaches the second update time, and the data in the system cache is updated, and then, after the predetermined request is obtained, the data in the system cache does not reach the next update time, at this time, the updated information of the third data in the cache may be returned to the device, that is, the information of the change of the data in the cache, so that the user can clearly determine that the data in the cache has changed.
The information that the third data changes may be: the updated third data and the situation of the third data changing may be specifically the time or the amount of change of the third data, or the value before the third data changes and the value after the third data changes.
Further, if the third data meets the valid condition, performing a predetermined operation based on the predetermined request to output a predetermined result, including:
if the third data meets the effective condition, determining whether the second updating time of the third data is reached currently, and if not, executing a predetermined operation based on a predetermined request to output a predetermined result; and if the third data meets the effective condition and the second update time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data meeting the effective condition.
If the third data matches with the data in the system cache, and the third data in the system cache does not reach the second update time, and does not need to be updated, the user may perform a reservation based on the current third data directly at this time, for example: reserving a seat on a flight, and then outputting a reservation result by the equipment, such as: the outcome of the reservation success or the reservation failure.
Wherein, the predetermined failure may be: when a user makes a reservation for a seat, other people are reserving the seat, the reservation may fail, or when the data in the cache or the data of the data source system of the third data is updated while the user makes the reservation, and the update is related to the seat or date reserved by the user, the reservation may fail.
If the third data is matched with the data in the system cache and the third data in the system cache reaches the second updating time, at this time, the third data in the system cache needs to be updated first, and after the third data in the system cache is updated, the third data fed back to the device is updated, or the third data fed back to the device is not updated, but the updated third data is directly operated in the system cache so as to complete the predetermined operation.
And updating the third data in the system cache, namely acquiring the updated third data from the data source system of the third data so as to replace the third data in the system cache according to the updated third data, so that the third data in the system cache is updated.
Further, the data may include, in addition to the update frequency: a validity period, wherein the update frequency is typically the same as or may be different from the validity period. For example: the update frequency of the data is: updating once every 30 minutes, and meanwhile, if the validity period of the data is 30 minutes, the validity period of the data is the same as the updating frequency; if the update frequency of the data is 1 hour and the validity period is 30 minutes, the validity period of the data is different from the update frequency, and at this time, the data may be data with a low query frequency and does not need to be updated frequently.
For example: the system firstly records a list of airlines supported by each airline department into the system, classifies all airlines of each airline department according to a certain rule, wherein an airline from Beijing to mansion is taken as an example, if three airlines, namely an airline A, an airline B and an airline C support the airline, classification results are respectively a class A hot airline, a class B common airline and a class C cold airline, and data aging set by the airlines corresponding to the three airlines is 30 minutes.
Respectively setting corresponding updating frequency, cache aging calculation modes and the like for each category, wherein the updating frequency, the cache aging calculation modes and the like are as follows: the class A hot data and the query and reservation frequency are high, the data can change frequently, and a high updating frequency and a short cache aging can be set, such as: updating every 10 minutes, and the cache aging is also 10 minutes; for the C-type cold data, the query and reservation frequency is low, the data updating is not frequent, and the lower updating frequency and the longer cache aging can be set, such as: update every hour, buffer age 30 minutes.
The user sends a query request, the query request is the flight information from Beijing to mansion, and all the information supporting the query is cached in advance, and the data is updated regularly, so the flight information provided by the airlines A, B and C supporting the airline can be directly queried from the cache, and the cached flight information is directly returned to the user after being integrated, and the system of each airline is not required to be called for query.
The user selects one flight to send a booking request according to the inquired flight information, compares the flight information in the booking request with the corresponding flight information in the cache, if the seat state and the price in the request data are equal to the data in the cache, continuously judges whether the flight data in the cache is valid, if the data are valid, directly sends the booking request to the airline company, and returns the result to the user; if the flight data in the cache fails, the validity period of the data of the airline company is exceeded, and the airline company system needs to be inquired again to obtain the flight data.
If the information in the request data is inconsistent with the information in the cache, the information in the cache is updated, whether the flight data in the cache is valid or not is determined, if the flight data in the cache is valid, the data in the cache is available, the flight data in the cache is returned to the user, and the user is informed that the flight information changes; and if the flight data in the cache fails, the airline system is inquired again to obtain the flight data.
Further, after new flight data are inquired from the airline company system, cache aging is calculated according to the data types, the flight data and the cache aging are updated into a cache, meanwhile, information in the inquired flight data is compared with information in the request data, if the data are consistent, a reservation request is made to the airline company, and the result is returned to the user; if the data are inconsistent, returning the inquired flight data to the user and informing the user that the flight information changes.
The data caching system disclosed in this embodiment classifies data, determines update information of data of different categories, caches the data of different categories and the update information of the data of different categories in a one-to-one correspondence manner, and updates the cached data of different categories based on the update information of the data of different categories, so as to determine the data meeting the effective condition based on the query request. According to the scheme, when the data is cached, the cached updating information which also comprises the data of different types is correspondingly cached, so that the cached data of different types can be updated based on the updating information of different types, the purpose that when a certain data is required to be searched from the cache, the cache data which is not invalid can be directly searched from the cache is achieved, the problem of time consumption caused by the fact that other systems need to be obtained due to the fact that the data in the cache is invalid when the query request is obtained is solved, the accuracy and the validity of data output when the query request is responded are improved, and the user experience is improved.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for caching data, comprising:
classifying the data and determining the updating information of the data of different categories;
caching the data of different types and the updating information of the data of different types in a one-to-one correspondence manner;
updating the cached data of different categories based on the update information of the data of different categories so as to determine the data meeting the effective condition based on the query request.
2. The method of claim 1, wherein determining update information for different classes of data comprises:
the updating frequency and the first updating time of each kind of data are determined based on the class attributes of different classes of data and the data attributes of the data.
3. The method of claim 2, wherein updating the stored data of the different categories based on the update information of the data of the different categories comprises:
determining a second updating time of each kind of data based on the updating frequency and the first updating time of each kind of data;
when the second updating time of the first data is reached, acquiring second data from a data source system of the first data, wherein the second data is real-time data which is stored by the data source system and corresponds to the first data;
and replacing the cached first data with the second data, and caching the second data in one-to-one correspondence with the updating frequency of the first data and the second updating time after adjusting the first updating time to be the second updating time.
4. The method of claim 2, further comprising:
acquiring a query request;
determining third data based on the query request, and outputting the third data.
5. The method of claim 4, further comprising:
acquiring a predetermined request;
determining whether the third data meets a valid condition based on the predetermined request;
and if the third data meets the effective condition, executing a predetermined operation based on the predetermined request to output a predetermined result.
6. The method of claim 5, wherein if the third data meets a valid condition, performing a predetermined operation based on the predetermined request to output a predetermined result comprises:
if the third data meets the effective condition, determining whether the second updating time of the third data is reached currently, and if not, executing a predetermined operation based on the predetermined request to output a predetermined result;
and if the third data meets the effective condition and the second updating time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data meeting the effective condition.
7. The method of claim 5, further comprising:
if the third data does not meet the effective condition, determining whether the second updating time of the third data is reached currently, and if not, outputting information that the data in the cache changes;
and if the third data does not meet the effective condition and the second updating time of the third data is determined to be reached currently, sending a query request to a data source system of the third data to update the third data so as to obtain the third data meeting the effective condition.
8. The method of claim 5, wherein determining whether the third data meets a validity condition comprises:
and whether the third data is matched with the data in the cache or not is judged, if so, the third data accords with the effective condition, and if not, the third data does not accord with the effective condition.
9. A data caching system, comprising:
the classification unit is used for classifying the data and determining the updating information of the data of different classes;
the cache unit is used for correspondingly caching the data of different types and the updating information of the data of different types one by one;
and the updating unit is used for updating the cached data of different categories based on the updating information of the data of different categories so as to determine the data meeting the effective conditions based on the query request.
10. The system of claim 9, wherein the classification unit is configured to:
the updating frequency and the first updating time of each kind of data are determined based on the class attributes of different classes of data and the data attributes of the data.
CN202011056756.XA 2020-09-30 2020-09-30 Data caching method and system Pending CN112182039A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011056756.XA CN112182039A (en) 2020-09-30 2020-09-30 Data caching method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011056756.XA CN112182039A (en) 2020-09-30 2020-09-30 Data caching method and system

Publications (1)

Publication Number Publication Date
CN112182039A true CN112182039A (en) 2021-01-05

Family

ID=73947165

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011056756.XA Pending CN112182039A (en) 2020-09-30 2020-09-30 Data caching method and system

Country Status (1)

Country Link
CN (1) CN112182039A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2698729A1 (en) * 2012-08-14 2014-02-19 Amadeus S.A.S. Updating cached database query results
CN103812849A (en) * 2012-11-15 2014-05-21 腾讯科技(深圳)有限公司 Local cache updating method and system, client and server
CN105389311A (en) * 2014-09-04 2016-03-09 阿里巴巴集团控股有限公司 Method and device used for determining query results
CN110471939A (en) * 2019-07-11 2019-11-19 平安普惠企业管理有限公司 Data access method, device, computer equipment and storage medium
CN111061744A (en) * 2018-10-17 2020-04-24 百度在线网络技术(北京)有限公司 Graph data updating method and device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2698729A1 (en) * 2012-08-14 2014-02-19 Amadeus S.A.S. Updating cached database query results
CN103812849A (en) * 2012-11-15 2014-05-21 腾讯科技(深圳)有限公司 Local cache updating method and system, client and server
CN105389311A (en) * 2014-09-04 2016-03-09 阿里巴巴集团控股有限公司 Method and device used for determining query results
CN111061744A (en) * 2018-10-17 2020-04-24 百度在线网络技术(北京)有限公司 Graph data updating method and device, computer equipment and storage medium
CN110471939A (en) * 2019-07-11 2019-11-19 平安普惠企业管理有限公司 Data access method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN100550766C (en) Preplanned mission manner of execution and management role manner of execution and terminal equipment thereof
CN110706069B (en) Exception handling method, device, server and system for order payment request
US11210284B2 (en) Method, system, apparatus, and computer-readable storage medium for sharing account resources
CN111464615A (en) Request processing method, device, server and storage medium
WO2015065366A1 (en) Process model catalog
CN111221469B (en) Method, device and system for synchronizing cache data
CN107908769A (en) Violation data querying method, device, system, equipment and readable storage medium storing program for executing
CN110222073B (en) Data query method and related device
CN111782692B (en) Frequency control method and device
CN110362598B (en) Data query method and device, storage medium and electronic equipment
CN102026228B (en) Statistical method and equipment for communication network performance data
US20200341899A1 (en) System and method for prediction based cache management
US10657449B2 (en) System and method for load distribution in a network
CN111340256A (en) Household appliance fault maintenance method, household appliance fault maintenance terminal and storage medium
CN113806651B (en) Data caching method, device, server and storage medium
CN112035766A (en) Webpage access method and device, storage medium and electronic equipment
CN111049882B (en) Cache state processing system, method, device and computer readable storage medium
CN102163197A (en) Skin changing method, system and device
CN112182039A (en) Data caching method and system
US11334476B2 (en) Client-side survey control
CN112702446A (en) Distributed storage system with DNS (domain name system) cached in edge network
CN110209510B (en) Data processing method and device for social contact
CN104969217A (en) Predictive cache apparatus and method of cache prediction
KR20150060747A (en) System and method for load distribution in a network
CN113448747A (en) Data transmission method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination