CN110941568A - Cache updating method, device, system, electronic equipment and medium - Google Patents

Cache updating method, device, system, electronic equipment and medium Download PDF

Info

Publication number
CN110941568A
CN110941568A CN201911011591.1A CN201911011591A CN110941568A CN 110941568 A CN110941568 A CN 110941568A CN 201911011591 A CN201911011591 A CN 201911011591A CN 110941568 A CN110941568 A CN 110941568A
Authority
CN
China
Prior art keywords
cache
data
version information
management server
target
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.)
Granted
Application number
CN201911011591.1A
Other languages
Chinese (zh)
Other versions
CN110941568B (en
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.)
Alipay Hangzhou Information Technology Co Ltd
Original Assignee
Alipay Hangzhou Information Technology Co Ltd
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 Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN201911011591.1A priority Critical patent/CN110941568B/en
Publication of CN110941568A publication Critical patent/CN110941568A/en
Application granted granted Critical
Publication of CN110941568B publication Critical patent/CN110941568B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0804Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with main memory updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0875Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with dedicated cache, e.g. instruction or stack

Abstract

The embodiment of the specification provides a cache updating method, a cache updating device, a cache updating system, electronic equipment and a cache updating medium, wherein if a data management server detects a data change event, a first version information of a cache domain to which target data belongs and a second version information of the target data are updated, a cache change instruction is pushed to a cache client, the cache client determines whether to initiate a data acquisition request or not based on the first version information and the second version information in the cache change instruction, if so, the cache updating server requests the changed target data, updates a local cache, and updates corresponding version information after the cache is updated.

Description

Cache updating method, device, system, electronic equipment and medium
Technical Field
Embodiments of the present disclosure relate to the field of computer technologies, and in particular, to a method, an apparatus, a system, an electronic device, and a medium for updating a cache.
Background
In a daily business scenario, a caching mechanism is often used to improve system performance and user experience. The cache mechanism can avoid frequently reading data from the database, relieve the pressure of the database, and reduce the response time of the system and the occurrence of abnormal conditions. When a cache mechanism is used, the cache is updated in time when data changes, and the method is particularly important for normal operation of a system.
Disclosure of Invention
The embodiment of the specification provides a cache updating method, a cache updating device, a cache updating system, electronic equipment and a cache updating medium.
In a first aspect, an embodiment of the present specification provides a cache updating method, where the method includes: if a data change event is detected, updating target version information of target data, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item; based on the updated target version information, pushing a cache updating instruction to a cache client cached with the target data, so that the cache client determines whether to initiate a data acquisition request based on the cache updating instruction; and if the data acquisition request sent by the cache client is received, acquiring changed target data based on the data acquisition request, and sending the changed target data to the cache client, so that the cache client updates a local cache by using the changed target data and updates locally stored target version information.
In a second aspect, an embodiment of the present specification provides a cache updating method, where the method includes: obtaining updated target version information corresponding to target data in a data management server based on a cache updating instruction pushed by the data management server, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item; determining whether to initiate a data acquisition request to the data management server based on the updated target version information; and if a data acquisition request is sent to the data management server, updating a local cache based on the changed target data returned by the data management server, and updating the locally stored target version information.
In a third aspect, an embodiment of the present specification provides a cache updating method, where the method includes: if an event for triggering a cache detection task is detected, sending a first data inspection request to a data management server, wherein the first data inspection request comprises: the first version information of each cache domain in the cache client is cached, so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and a first detection result is returned; if the cache domain to be updated is determined to exist according to the first detection result, sending a second data check request to the data management server, wherein the cache domain to be updated is the cache domain with the inconsistent first detection result, and the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server or not, and returns a second detection result; and based on the second detection result, obtaining changed data from the data management server, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated and the second version information of the changed data in the cache client.
In a fourth aspect, an embodiment of the present specification provides a cache update system, where the system includes a data management server and more than one cache clients. The data management server is configured to update target version information of target data if a data change event is detected, and push a cache update instruction to a cache client that caches the target data based on the updated target version information, where the target data is a changed data item, and the target version information includes first version information of a cache domain to which the target data belongs and second version information of the target data. The cache client is used for obtaining the updated target version information based on the cache updating instruction, and determining whether to initiate a data acquisition request to the data management server based on the updated target version information. And the data management server is used for acquiring changed target data based on the data acquisition request and sending the changed target data to the cache client if the data acquisition request sent by the cache client is received. The cache client is used for updating the local cache by using the received changed target data and updating the locally stored target version information.
In a fifth aspect, an embodiment of the present specification provides a cache updating apparatus, where the apparatus includes: the version updating module is used for updating target version information of target data if a data change event is detected, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item; the pushing module is used for pushing a cache updating instruction to a cache client cached with the target data based on the updated target version information so that the cache client determines whether to initiate a data acquisition request based on the cache updating instruction; and the data acquisition module is used for acquiring changed target data based on the data acquisition request and sending the changed target data to the cache client if the data acquisition request sent by the cache client is received, so that the cache client updates a local cache by using the changed target data and updates locally stored target version information.
In a sixth aspect, an embodiment of the present specification provides a cache updating apparatus, where the apparatus includes: the version analysis module is used for obtaining updated target version information corresponding to target data in a data management server based on a cache updating instruction pushed by the data management server, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item; a request sending module, configured to determine whether to initiate a data acquisition request to the data management server based on the updated target version information; and the first cache updating module is used for updating the local cache based on the changed target data returned by the data management server and updating the locally stored target version information if a data acquisition request is initiated to the data management server.
In a seventh aspect, an embodiment of this specification provides a cache updating apparatus, where the apparatus includes: a third sending module, configured to send a first data check request to the data management server if an event for triggering the cache detection task is detected, where the first data check request includes: the first version information of each cache domain in the cache client is cached, so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and a first detection result is returned; a fourth sending module, configured to send a second data check request to the data management server if it is determined that a cache domain to be updated exists according to the first detection result, where the cache domain to be updated is a cache domain whose first detection result is inconsistent, and the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and returns a second detection result; and the third cache updating module is used for acquiring changed data from the data management server based on the second detection result, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated and the second version information of the changed data in the cache client.
In an eighth aspect, an embodiment of the present specification provides an electronic device, including: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the cache update method provided in the first, second or third aspect when executing the program.
In a ninth aspect, the present specification provides a computer readable storage medium, on which a computer program is stored, and the program, when executed by a processor, implements the steps of the cache update method provided in the first, second or third aspect.
In the cache updating method provided in an embodiment of the present specification, when a data change event is detected, the data management server can push a cache change instruction to the cache client, and instruct the cache client to update a corresponding changed data item, so that timeliness of cache updating can be effectively ensured. Moreover, a double-version mechanism is adopted, when a data change event is detected, the first version information of the cache domain to which the target data belongs in the data management server and the second version information of the data item are updated, then after the cache client finishes updating the corresponding data item, the first version information of the local corresponding cache domain of the cache client and the second version information of the data item are synchronously updated to ensure that the cache updated data version is consistent with the changed version in the data management server, therefore, on one hand, the accuracy of the cache updating can be effectively ensured, on the other hand, the double-version mechanism can improve the efficiency of the cache client side for determining whether the updating is needed, if the first version information of the cache domain where the target data is located is consistent, the second version information of the target data does not need to be compared, and the comparison of the second version information is carried out only if the first version information is inconsistent. In addition, the data management server firstly sends a cache updating instruction to the cache client, when the cache client determines that the cache updating is needed, namely a data acquisition request sent by the cache client is received, the changed target data is provided to the cache client according to the need, and if the cache client does not need to perform the cache updating, the changed target data does not need to be provided to the cache client, so that the pressure of data transmission is favorably relieved, and the resource occupation of the data management server is reduced.
Drawings
Fig. 1 is a schematic structural diagram of a cache update system according to a first aspect of an embodiment of the present disclosure;
fig. 2 is a timing diagram of an exemplary data change cache update process provided in the first aspect of the embodiments of the present description;
fig. 3 is a timing diagram of an exemplary cache update scanning process provided in the first aspect of the embodiments of the present description;
fig. 4 is a flowchart of a cache update method provided in the second aspect of the embodiment of the present specification;
fig. 5 is a flowchart of a cache update method provided in the third aspect of the embodiment of the present disclosure;
fig. 6 is a flowchart of a cache updating method according to a fourth aspect of the present specification;
fig. 7 is a flowchart of a cache updating apparatus according to a fifth aspect of the embodiments of the present disclosure;
fig. 8 is a flowchart of a cache updating apparatus according to a sixth aspect of the present specification;
fig. 9 is a flowchart of a cache update apparatus according to a seventh aspect of the present specification;
fig. 10 is a schematic structural diagram of an electronic device according to an eighth aspect of the embodiments of the present description.
Detailed Description
In order to better understand the technical solutions provided by the embodiments of the present specification, the technical solutions of the embodiments of the present specification are described in detail below with reference to the drawings and specific embodiments, and it should be understood that the specific features in the embodiments and examples of the present specification are detailed descriptions of the technical solutions of the embodiments of the present specification, and are not limitations on the technical solutions of the embodiments of the present specification, and the technical features in the embodiments and examples of the present specification may be combined with each other without conflict. In the embodiments of the present specification, the term "more than one" includes one or more than one, and the term "plurality" means "more than two", that is, includes two or more than two. The term "and/or" is merely an associative relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone.
In a first aspect, fig. 1 illustrates a schematic structural diagram of a cache update system provided in an embodiment of the present specification. As shown in fig. 1, a cache update system 1 provided by the embodiment of the present specification includes a data management server 10 and one or more cache clients (such as cache clients 11, 12, and 13 shown in fig. 1). It should be noted that the cache client data shown in fig. 1 is only an illustration, and the specific number of cache clients is not limited, and is determined according to an actual application scenario.
In one embodiment of the present specification, the caching client refers to each service end that needs to access the cache, such as a member service. The data management server is an end providing cached data services, such as loading of data in the cache, updating of data in the cache, and the like.
The data management server establishes connection with each accessed cache client, and is used for managing the data items cached in each cache client in real time. In other embodiments of this specification, the data management server may also check the status of the data items cached in each cache client in real time and give an alarm in real time for an abnormal situation, which may be specifically set according to the needs of the actual application scenario. In an application scenario, a cache component is disposed in a cache client JVM (Java Virtual Machine), where the cache component is used to manage a near-end cache, and the near-end cache is cache data stored in the cache client JVM.
In an embodiment of the present specification, the data management server is configured to, if a data change event is detected, update target version information of target data to obtain updated target version information, and push a cache update instruction to a cache client that caches the target data based on the updated target version information, where the target data is a changed data item, and the target version information includes first version information of a cache domain to which the target data belongs and second version information of the target data.
The cache client is used for obtaining updated target version information based on the cache updating instruction, and determining whether to initiate a data acquisition request to the data management server based on the updated target version information. And the data management server is used for acquiring the changed target data based on the data acquisition request and sending the changed target data to the cache client side if receiving the data acquisition request sent by the cache client side. The cache client is used for updating the local cache by using the received changed target data and updating the locally stored target version information.
In a specific implementation process, the data management server can detect a data change event of the database, for example, an event of modifying an existing data item in the database or adding a new data item. And taking the changed data item in the database as target data. When a data change event is detected, determining a cache domain to which the target data belongs and a cache client for caching the target data.
The specific determination mode can be set according to the requirements of the actual application scene. For example, the data management server may store a corresponding relationship between the cache client, the cache domain, and the data item, and may determine, by obtaining the identification information of the target data, the cache client that caches the target data and the cache domain to which the target data belongs based on the identification information of the target data and the corresponding relationship. Wherein the identification information of the target data is used for uniquely identifying the target data. Or, in an application scenario, the cache domain included in each cache client and the data item cached in the cache domain are consistent, and all the accessed cache clients cache the target data, at this time, the data management server may store the corresponding relationship between the cache domain and the data item, so as to determine, through the identification information of the target data, the cache domain to which the target data belongs. Of course, in other embodiments of this specification, the data management server may also determine the cache domain to which the target data belongs and the cache client that caches the target data in other manners, which is not limited herein.
The cache client manages cache data according to a cache domain, where the cache domain is a region for caching data in a specific domain, and different cache domains may be used for caching data in different specific domains, for example, cache domain a may be used for caching staff information, and cache domain B may be used for caching contract information, and the like. In an embodiment of this specification, each cache domain in the cache client may have an independent cache size and a capacity limit value, that is, a maximum capacity, and the like, and the cache size and the capacity limit value of each cache domain may be configured according to actual needs.
Each cache domain in the cache client is configured with independent first version information, and each cache item in each cache domain is configured with independent second version information. The first version information of the cache domain is used for uniquely characterizing the version of the cache domain, and the second version information of the data item is used for uniquely characterizing the version of the data item. In this embodiment, the first version information and the second version information may be any type of identifier capable of distinguishing versions, for example, version numbers.
Taking the first version information and the second version information as examples, table 1 shows a corresponding table of an exemplary cache domain and a corresponding version number, and table 2 shows a corresponding table of an exemplary cache domain, a data item, and a version number of the data item. In table 1, "Domain 1" and "Domain 2" are identification information of two cache domains, respectively, and are used to uniquely identify the corresponding cache domains, the version number of the current version of the cache Domain1 is V2, and the version number of the cache Domain2 is V3. In table 2, "ItemID 1" and "ItemID 2" are identification information of two data items in the cache Domain1, respectively, for uniquely identifying the corresponding data item, "ItemID 3" is identification information of one data item in the cache Domain2, for uniquely identifying the data item, the version number of the data item ItemID1 of the current version is V4, the version number of the data item ItemID2 is V9, and the version number of the data item version number ItemID3 is V5.
TABLE 1
Cache domain Version number
Domain1 V2
Domain2 V3
TABLE 2
Cache domain Caching item ID Version number
Domain1 ItemID1 V4
Domain1 ItemID2 V9
Domain2 ItemID3 V5
When any data item in the cache domain is changed, the first version information of the cache domain needs to be updated, and the second version information of the data item needs to be updated. Taking the first version information and the second version information as an example, when any data item in a certain cache domain is changed, the version number of the cache domain is increased by 1, and the version number of the data item is increased by 1.
In order to manage the cache data in each accessed cache client, the data management server also stores the first version information of each cache domain in each accessed cache client and the second version information of each data item in each cache domain, so as to determine whether the cache data in the cache client needs to be updated by comparing the two version information in the data management server and the cache client. In an embodiment of this specification, the data management server may correspondingly store the identification information of the cache client, the identification information of the cache domain, the first version information of the cache domain, the identification information of the cache data item, and the second version information of the data item, so as to distinguish the cache client where the data item is located and the cache domain to which the data item belongs.
And after the data management server detects the data change event and determines the cache domain to which the target data belongs, updating the target version information of the target data to obtain the updated target version information. Specifically, the target version information corresponding to the target data is the first version information of the cache domain to which the target data belongs and the second version information of the target data. Taking the first version information and the second version information as version numbers as an example, assuming that the version number of the cache domain to which the target data belongs in the data management server is V6 and the version number of the target data is V3, the version number of the cache domain is increased by 1, the version number of the cache domain is updated to V7, the version number of the target data is increased by 1, and the version number of the target data is updated to V4.
It should be noted that, if the data change event is an event of a newly added data item, when a user newly adds a data item, the cache domain to which the newly added data item belongs and the cache client that caches the newly added data item may be determined, at this time, first version information of the cache domain to which the newly added data item belongs in the data management server needs to be updated, and initial second version information of the newly added data item needs to be configured.
In the embodiments of this specification, there are various implementation manners in which the data management server generates the cache update instruction, and the implementation manners may be specifically set according to needs of an actual application scenario. In an embodiment, in order to facilitate data transmission, updated target version information of the target data may be processed to obtain pushed version information, and then a cache update instruction is generated based on the pushed version information, so as to push the cache update instruction to a cache client that caches the target data. The cache update instruction may include push version information, identification information of a cache domain to which the target data belongs, and identification information of the target data. Specifically, the pushed version information may be calculated by using a reversible algorithm capable of processing two version information into one version information, which may be specifically set according to actual needs, for example, the updated first version information and the updated second version information may be spliced to form the pushed version information. And after receiving the cache updating instruction, the cache client acquires the pushed version information from the cache updating instruction, and analyzes the pushed version information to obtain updated first version information of the cache domain to which the target data belongs and updated second version information of the target data.
In another embodiment, the cache update instruction may include identification information of a cache domain to which the target data belongs, identification information of the target data, and the updated target version information. After receiving the cache update instruction, the cache client may obtain the identification information of the cache domain and the updated first version information, and the identification information of the target data and the updated second version information from the cache update instruction.
It can be understood that, in an application scenario, if the first version information may be used to represent not only the version of the cache domain but also the unique identifier of the cache domain, the second version information may also be used to represent not only the version of the data item but also the unique identifier of the data item, and the cache update instruction may not further carry the identifier information of the cache domain to which the target data belongs and the identifier information of the target data.
After the cache updating instruction received by the cache client side is received, the updated target version information is analyzed from the cache updating instruction, the target version information analyzed from the cache updating instruction is compared with the local target version information, and if the analyzed target version information is inconsistent with the local target version information, the local cache needs to be updated. Specifically, the parsed first version information may be compared with the local first version information, and if the first version information is consistent with the local first version information, it is determined that the local cache does not need to be updated, and a data acquisition request does not need to be initiated for the cache update instruction; if not, determining that the local cache needs to be updated, further comparing the analyzed second version information with the local second version information, determining whether the local target data needs to be updated, and if so, initiating a data acquisition request to the data management server. Therefore, when the first version information is consistent, the second version information of the target data does not need to be searched from huge data items for comparison, and the efficiency of determining whether the target data needs to be updated by the cache client side is improved.
For example, the inconsistency between the analyzed target version information and the local target version information may specifically include: the first version information analyzed from the cache update instruction is greater than the first version information of the local corresponding cache domain, and the second version information analyzed from the cache update instruction is greater than the second version information of the local cache corresponding data item, or the local cache does not have a data item corresponding to the target data, that is, the local cache does not have the second version information of the corresponding data item.
After the cache client determines that the local cache needs to be updated, a data acquisition request can be generated according to the target version information analyzed from the cache update instruction, and the data acquisition request is sent to the data management server. In an embodiment, the data obtaining request may include a query condition that is constructed by the cache client according to the target version information analyzed in the cache update instruction, so that the data management server queries the target data of the corresponding version, that is, the changed target data, through the query condition. Specifically, the query condition is used to query the changed target data, and may include target version information analyzed from the cache update instruction, identification information of a cache domain to which the target data belongs, and identification information of the target data. Of course, the query condition may further include other information, which is configured according to the needs of the actual application scenario, for example, the query condition may further include identification information of the cache client, which is used to uniquely identify the cache client that sends the data acquisition request.
In another embodiment, if the first version information may be used to represent not only the version of the cache domain but also the unique identifier of the cache domain, the second version information may also be used to represent not only the version of the data item but also the unique identifier of the data item, and the query condition may not be further carried with the identifier information of the cache domain to which the target data belongs and the identifier information of the target data.
And after receiving the data acquisition request sent by the cache client, the data management server determines a query condition from the data acquisition request, further queries the changed target data according to the query condition, and returns the changed target data to the cache client. In one embodiment, the data management server may sequentially process the received data acquisition requests in a queue manner, so as to relieve the query pressure of the data management server.
For example, the implementation process of determining a query condition from the data acquisition request and then querying the changed target data according to the query condition may include: determining identification information of a cache domain, identification information of target data and updated target version information from the data acquisition request; and inquiring the changed target data according to the identification information of the cache domain, the identification information of the target data and the updated target version information. Or, determining updated target version information from the data acquisition request, and querying changed target data according to the updated target version information. The updated target version information is target version information analyzed from the cache update instruction.
The data management server can find a corresponding data item through the identification information of the cache domain and the identification information of the target data in the data acquisition request, then match the current target version information corresponding to the data item found in the data management server with the target version information in the data acquisition request, and when the matching is passed, the data item is the data item of the version requested by the cache client, namely the changed target data. Suppose that the found current first version information of the corresponding cache domain is a, the first version information in the data acquisition request is a ', the found current second version information of the corresponding data item is b, and the second version information in the data acquisition request is b'. In the specific implementation process, the following matching conditions can be included:
first, if a matches a 'and b matches b', then the match is determined to pass.
Second, if a is greater than a 'and b is consistent with b', it indicates that other data items are also changed in the cache domain to which the target data belongs after the data management server pushes the cache update command to the cache client based on the change event of the target data and before the changed target data is queried based on the data acquisition request returned by the cache client, and in this case, it may be determined that the matching is passed.
Thirdly, if a is greater than a 'and b is greater than b', it indicates that after the data management server pushes a cache update instruction to the cache client based on the change event of the target data and before the data acquisition request returned by the cache client queries the changed target data, the data item is newly changed, so as to avoid repeated data query and reduce resource occupation of the data management server, and it may be determined that the matching fails and the current data acquisition request is discarded.
And after the cache client receives the changed target data returned by the data management server based on the data acquisition request, updating the local cache by using the changed target data, and updating the locally stored target version information by using the target version information analyzed from the cache updating instruction.
For example, the target version information parsed from the cache update instruction is: and V5 and V3, where V5 is the first version information, and V3 is the second version information, replacing the target data item of the local cache with the changed target data, where the target data item is a data item whose identification information is the same as the target data, updating the first version information of the cache domain to which the target data item cached in the cache client belongs to V5, and updating the second version information of the target data item to V3.
For another example, the target version information parsed from the cache update instruction is: v5 and V0, V5 is the first version information, V0 is the second version information, and is the initial second version information, which indicates that there is no data item whose identification information is the same as the target data in the target cache domain of the cache client, that is, the target data is a newly added data item in the database, at this time, the changed target data is added as the target data item to the target cache domain of the cache client for caching, the first version information of the target cache domain in the cache client is updated to V5, and the second version information of the target data item is configured as V0. And the target cache domain is the cache domain to which the target data belongs.
Therefore, the cache updating of the cache client can be realized, the on-demand updating mode is that the cache client can request data from the data management server for updating when receiving the cache updating instruction and determining that the updating is needed, and the data can not be requested from the data management server when determining that the updating is not needed, so that the excessive pressure on a data transmission belt can be effectively avoided, and the system bandwidth occupation is reduced.
In order to reduce the resource occupation of the data management server, in an optional embodiment of the present specification, the cache update system may further include a cache push module. The cache pushing module establishes connection with each cache client, and ensures that each cache client can be successfully pushed. At this time, the data management server may be configured to push the cache update instruction to the cache client having the target data cached therein through the cache push module. Specifically, the data management server may send the cache update instruction to the cache push module, and the cache push module triggers push when receiving the cache update instruction, and pushes the cache update instruction to the cache client having the target data cached therein. In an embodiment, the cache update instruction may further include identification information of the cache client that caches the target data.
In this embodiment, the cache push module may be independently arranged from the data management server and connected via a network, or the cache push module may be integrally arranged with the data management server.
The above is a data change cache update process initiated by the data management server. In order to describe the above process more clearly, an exemplary implementation process of the above cache update process is described below by taking the first version information and the second version information as version numbers as an example. FIG. 2 illustrates a timing diagram of one exemplary implementation of a data change cache update process. As shown in fig. 2, if the data management server detects a data change event, determines a cache domain where a changed data item, that is, target data, is located, then adds 1 to the version number of the cache domain in the data management server, and adds 1 to the version number of the target data, generates a cache update instruction based on the version number of the cache domain after being updated and the version number of the target data, sends the cache update instruction to a cache push module for pushing, the cache push module pushes the cache update instruction to a cache client cached with the target data, parses the version number in the cache update instruction after the cache client receives the cache update instruction, generates a data acquisition request based on the version number in the cache update instruction when determining that the cache needs to be updated by comparing the parsed version number with a local corresponding version number, and sends the data acquisition request to the data management service, and the data management server acquires the changed target data based on the data request and returns the changed target data to the cache client, and the cache client updates the local cache by using the changed target data and updates the local version number by using the version number analyzed from the cache updating instruction.
The cache updating system provided by the embodiment of the specification can push the cache changing instruction to the cache client in time when a data changing event is detected, and can effectively guarantee timeliness of cache updating. And through a double-version mechanism, namely configuring the first version information of the cache domain and the second version information of the data item, the accuracy of cache updating can be effectively ensured, and the efficiency of determining whether the cache client needs to update can be improved. In addition, the data management server firstly sends a cache updating instruction to the cache client, when the cache client determines that cache updating is needed based on the target version information in the cache updating instruction, the cache client sends a data acquisition request to the data management server to acquire the changed target data, and if the cache client does not need to perform cache updating, the cache client does not need to provide the changed target data to the cache client, so that the pressure of data transmission is relieved, and the resource occupation of the data management server is reduced.
In an alternative embodiment of the present description, the cache update system may be used to perform a cache update scan process in addition to the above data change cache update process.
At this time, the cache client is configured to send a first data check request to the data management server if an event for triggering the cache detection task is detected. The first data check request includes: and caching the first version information of each caching domain in the client. In an embodiment, the event for triggering the cache detection task may be configured according to the requirement of the actual application scenario, and in an implementation, the event may be configured to automatically trigger the cache detection task at every preset time, where the preset time is set according to the requirement of the actual application scenario, for example, may be set to 30 seconds. Of course, in other embodiments of the present disclosure, other triggering manners may be adopted, for example, triggering the cache detection task when a preset operation is detected, such as a user clicking a preset button.
The data management server is used for detecting whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, obtaining a first detection result and returning the first detection result to the cache client. For example, if the first data check request includes version numbers of 50 cache domains, the version numbers of the 50 cache domains need to be compared with the version number of the cache domain in the data management server, if the version numbers of the cache domains are consistent, it indicates that the cache domain does not need to be updated, and if the version numbers of the cache domains are inconsistent, it indicates that the cache domain needs to be updated, and the cache domain is marked as a cache domain to be updated in the first detection result.
It can be understood that, if the cache domain to be updated does not exist in the first detection result, it indicates that the data item in each cache domain of the cache client is the latest version, and the cache client does not need to be updated, the cache update scanning process is ended. If the cache domain to be updated exists in the first detection result, it indicates that the data item in the cache domain has been changed, and the data item in the cache domain needs to be further updated. The cache client may determine, from the first detection result, a cache domain to be updated and first version information of the cache domain to be updated in the data management server.
Further, the cache client is further configured to send a second data check request to the data management server if the cache domain to be updated exists in the first detection result. The second data check request comprises second version information of each data item in the cache domain to be updated. The data management server is used for detecting whether the second version information of each data item is consistent with the second version information of the data item in the data management server or not, obtaining a second detection result and returning the second detection result to the cache client.
For example, if the cache domain to be updated is a cache domain a, and the cache domain a includes ten thousand data items, it is necessary to send all the second version information of the ten thousand data items to the data management server for detection, and of the ten thousand data items, a data item whose second version information is inconsistent with the second version information of the data item in the data management server is a changed data item, and the changed data item is marked in a second detection result.
Further, the cache client is configured to obtain the changed data from the data management server based on the second detection result, update the local cache with the changed data, and update the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
Specifically, the cache client may determine, based on the second detection result, that the changed data item has occurred, and second version information of the changed data item in the data management server. And according to the second version information of the changed data item in the data management server and the first version information of the corresponding cache domain to be updated, constructing a query condition for helping the data management server to query the changed data of the corresponding version, sending a data acquisition request carrying the query condition to the data management server, querying the corresponding changed data by the data management server according to the query condition obtained from the data acquisition request, and returning the changed data to the cache client. Therefore, the cache client can replace the corresponding data item stored locally with the change data, and update the first version information of the corresponding cache domain and the second version information of the data item after updating the data item. For example, the first version information of the local corresponding cache domain may be updated to the first version information of the cache domain in the data management server, and the second version information of the local corresponding data item may be updated to the second version information of the data item in the data management server.
In order to describe the cache update scanning process more clearly, an exemplary implementation process of the cache update scanning process is described below by taking the first version information and the second version information as version numbers. FIG. 3 illustrates a timing diagram of an exemplary implementation of a cache update scan process. As shown in fig. 3, when detecting that an event for triggering a cache detection task reaches a timing time, a cache client starts the cache detection task, obtains a version number of each local cache domain, and sends a first data check request to a data management server; the data management server compares the version number of each cache domain in the first data checking request with the corresponding version number stored locally to obtain a first detection result, and returns the first detection result to the cache client; when the cache domain to be updated exists in the first detection result, the cache client continuously sends a second data check request to the data management server; the data management server detects the version number of each data item in the second data check request, namely determines the data items of which the version numbers are inconsistent with the locally stored version numbers in the data items, obtains a second detection result, and returns the second detection result to the cache client; the cache client generates a data acquisition request based on the second detection result, sends the data acquisition request to the data management server, and the data management server acquires the changed data according to the data acquisition request and returns the changed data to the cache client.
The cache updating system provided in the embodiment of the present description performs the cache updating scanning process and the data change cache updating process in a matching manner, and if the pushing of the cache updating instruction fails or other abnormalities exist in the data change cache updating process, the cache updating can be implemented through the cache updating scanning process, so that the data items cached in the cache client and the data items in the database can be further ensured to be consistent, and the accuracy of the cache data is ensured. In addition, by adopting a double-version mechanism, the first version information of each cache domain is detected firstly, the second version information of each data item of the cache domain with inconsistent first version information is detected, and the changed data is acquired as required to update the cache, so that unnecessary data transmission is avoided, the pressure of data transmission is relieved, and the bandwidth resource of the system is saved.
It should be noted that, in other embodiments of this specification, the cache update system may also perform the above-mentioned cache update scanning process separately, that is, the cache client initiates cache detection to implement cache update of itself.
In a second aspect, fig. 4 shows a flowchart of a cache updating method provided in an embodiment of this specification, referring to fig. 4, this embodiment describes a processing flow of a data management server, and the method may include at least the following steps S400 to S406.
Step S400, if a data change event is detected, updating target version information of the target data, where the target version information includes first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item.
Step S402, based on the updated target version information, a cache updating instruction is pushed to the cache client terminal cached with the target data, so that the cache client terminal determines whether to initiate a data acquisition request based on the cache updating instruction.
Step S404, if a data obtaining request sent by the cache client is received, obtaining changed target data based on the data obtaining request, and sending the changed target data to the cache client, so that the cache client updates the local cache with the changed target data, and updates the locally stored target version information.
It should be noted that, for the specific implementation process of steps S400 to S404, reference may be made to the implementation process of the data change cache updating process in the first aspect, and details are not described here.
As an optional implementation manner, the implementation process of acquiring the changed target data based on the data acquisition request sent by the cache client includes: determining the identification information of the cache domain, the identification information of the target data and the updated target version information from the data acquisition request; and inquiring the changed target data according to the identification information of the cache domain, the identification information of the target data and the updated target version information. For a specific implementation process, reference may be made to the process of acquiring the changed target data by the data management server in the first aspect, which is not described herein again.
The cache updating method provided by the embodiment of the specification can push the cache changing instruction to the cache client in time when a data changing event is detected, and can effectively guarantee timeliness of cache updating. And through a double-version mechanism, namely configuring the first version information of the cache domain and the second version information of the data item, the accuracy of cache updating can be effectively ensured, and the efficiency of determining whether the cache client needs to update can be improved. In addition, the data management server firstly sends a cache updating instruction to the cache client, when a data acquisition request sent by the cache client is received, the changed target data is provided for the cache client according to the requirement, and if the cache client does not need to perform cache updating, the changed target data does not need to be provided for the cache client, so that the pressure of data transmission is relieved, and the resource occupation of the data management server is reduced.
In the above step S400 to step S404 are data change cache updating processes executed by the data management server, in an optional embodiment of the present specification, in addition to the data change cache updating processes, the cache updating method provided in this embodiment further includes a cache update scanning process. Specifically, the cache update scanning process may include:
receiving a first data checking request sent by a cache client, wherein the first data checking request comprises: caching first version information of each caching domain in a client;
and detecting whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not to obtain a first detection result, and returning the first detection result to the cache client, so that the cache client determines whether cache updating is needed or not based on the first detection result.
If the first detection result is that the first version information of each cache domain in the first data check request is consistent with the first version information of the cache domain in the data management server, it indicates that no cache domain to be updated exists in the cache client. And after receiving the first detection result, the cache client stops the cache updating scanning process.
If the first detection result indicates that the first version information of more than one cache domain in the first data check request is not consistent with the first version information of the cache domain in the data management server, the cache client indicates that the cache domain to be updated exists in the cache client, and after receiving the first detection result, the cache client sends a second data check request to the data management server. At this time, the cache update scanning process performed by the data management server further includes:
receiving a second data check request sent by the cache client, wherein the second data check request comprises second version information of each data item in a cache domain to be updated, and the cache domain to be updated is a cache domain with inconsistent first detection results;
and detecting whether the second version information of each data item is consistent with the second version information of the data item in the data management server or not to obtain a second detection result, and returning the second detection result to the cache client, so that the cache client acquires changed data from the data management server based on the second detection result, updates the local cache with the changed data, and updates the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
It should be noted that, for the specific implementation process of the cache update scanning process, reference may be made to the implementation process of the cache update scanning process in the first aspect, and details are not described here again.
In the cache updating method provided in the embodiments of the present description, the cache updating scanning process and the data change cache updating process are executed in a matching manner, and if the pushing of the cache updating instruction fails or other abnormalities exist in the data change cache updating process, the cache updating can be realized through the cache updating scanning process, so that the data items cached in the cache client and the data items in the database can be further ensured to be consistent, and the accuracy of the cache data is ensured. In addition, by adopting a double-version mechanism, the first version information of each cache domain is detected firstly, the second version information of each data item of the cache domain with inconsistent first version information is detected, and the changed data is acquired as required to update the cache, so that unnecessary data transmission is avoided, the pressure of data transmission is relieved, and the bandwidth resource of the system is saved.
In a third aspect, fig. 5 shows a flowchart of a cache updating method provided in an embodiment of the present specification, referring to fig. 5, this embodiment describes a processing flow of a cache client, and the method at least includes the following steps S500 to S504.
Step S500, obtaining updated target version information corresponding to target data in the data management server based on a cache updating instruction pushed by the data management server, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item;
step S502, based on the updated target version information, determining whether to initiate a data acquisition request to the data management server;
step S504, if a data acquisition request is initiated to the data management server, the local cache is updated based on the changed target data returned by the data management server, and the target version information stored locally is updated.
It should be noted that, for the specific implementation process of steps S500 to S504, reference may be made to the implementation process of the data change cache updating process in the first aspect, and details are not described here.
In an embodiment of the present description, the determining whether to initiate a data obtaining request to the data management server based on the updated target version information includes: and judging whether the updated target version information is matched with locally stored target version information, if not, initiating a data acquisition request to the data management server, and if so, indicating that a data item corresponding to the target data in the cache client is an updated version, and not needing to be updated, and initiating the data acquisition request to the data management server.
Specifically, the updated target version information is the target version information analyzed from the cache update instruction, the analyzed first version information and the local first version information may be compared first, and if the analyzed first version information and the local first version information are consistent, it is determined that the local cache does not need to be updated, and a data acquisition request does not need to be initiated for the cache update instruction; if not, determining that the local cache needs to be updated, further comparing the analyzed second version information with the local second version information, determining whether the local target data needs to be updated, and if so, initiating a data acquisition request to the data management server. Therefore, when the first version information is consistent, the second version information of the target data does not need to be searched from huge data items for comparison, and the efficiency of determining whether the target data needs to be updated by the cache client side is improved.
It can be understood that, if the first version information analyzed from the cache update instruction is greater than the first version information of the local corresponding cache domain, and the second version information analyzed from the cache update instruction is greater than the second version information of the local cache corresponding data item, or if the local cache does not have a data item corresponding to the target data, that is, the local cache does not have the second version information of the corresponding data item, it is determined that the updated target version information does not match the locally stored target version information; if the first version information analyzed from the cache update instruction is consistent with the first version information of the local corresponding cache domain, it may be determined that the updated target version information matches the locally stored target version information.
The above steps S500 to S504 are data change cache updating processes executed by the cache client, and in an optional embodiment of the present specification, in addition to the data change cache updating processes, the cache updating method provided in this embodiment further includes a cache update scanning process. Specifically, the cache update scanning process may include:
if an event for triggering the cache detection task is detected, sending a first data inspection request to the data management server, wherein the first data inspection request comprises: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and a first detection result is obtained.
And if the cache domain to be updated does not exist in the first detection result, ending the cache detection task. If the cache domain to be updated exists in the first detection result, sending a second data check request to the data management server, wherein the second data check request comprises second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server to obtain a second detection result;
and based on a second detection result returned by the data management server, acquiring the changed data from the data management server, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
It should be noted that, for the specific implementation process of the cache update scanning process, reference may be made to the implementation process of the cache update scanning process in the first aspect, and details are not described here again. It should also be noted that the cache updating method provided in this embodiment is a processing procedure executed by an opposite end of the data management server, that is, the cache client, and the implementation effect is similar to that of the cache updating method provided in the second aspect, and is not described here again.
In a fourth aspect, fig. 6 shows a flowchart of a cache updating method provided in an embodiment of this specification, please refer to fig. 6, which describes a processing flow of a cache client, where the method at least includes the following steps S600 to S604.
Step S600, if an event for triggering the cache detection task is detected, sending a first data check request to the data management server, where the first data check request includes: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result.
Step S602, if a cache domain to be updated exists in the first detection result, sending a second data check request to the data management server, where the cache domain to be updated is a cache domain whose first detection result is inconsistent, and the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and returns a second detection result.
It should be noted that, if the cache domain to be updated does not exist in the first detection result, the cache detection task is ended, and the following step S604 is not executed any more.
Step S604, based on the second detection result, obtaining the changed data from the data management server, updating the local cache with the changed data, and updating the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
It should be noted that, for the specific implementation process of the steps S600 to S604, reference may be made to the implementation process of the cache update scanning process in the first aspect, and details are not described here.
The cache updating method provided by the embodiment of the present specification can implement cache updating on the cache client, and ensure that the data items cached in the cache client are consistent with the data items in the database. And by adopting a double-version mechanism, the first version information of each cache domain is detected firstly, the second version information of each data item of the cache domain with inconsistent first version information is detected, and the changed data is acquired as required to update the cache, so that unnecessary data transmission is avoided, the pressure of data transmission is relieved, and the bandwidth resource of the system is saved.
In a fifth aspect, based on the same inventive concept as the cache updating method provided in the foregoing second aspect, an embodiment of the present specification further provides a cache updating apparatus. As shown in fig. 7, the cache update apparatus 70 includes:
the version updating module 71 is configured to update target version information of target data if a data change event is detected, where the target version information includes first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item;
a pushing module 72, configured to push a cache update instruction to a cache client that caches the target data based on the updated target version information, so that the cache client determines whether to initiate a data acquisition request based on the cache update instruction;
a data obtaining module 73, configured to, if the data obtaining request sent by the cache client is received, obtain changed target data based on the data obtaining request, and send the changed target data to the cache client, so that the cache client updates a local cache with the changed target data, and updates locally stored target version information.
In an alternative embodiment of the present disclosure, the data obtaining module 73 includes:
a determining submodule 731, configured to determine, from the data obtaining request, the identification information of the cache domain, the identification information of the target data, and the updated target version information;
the query submodule 732 is configured to query the changed target data according to the identification information of the cache domain, the identification information of the target data, and the updated target version information.
In an alternative embodiment of the present disclosure, the cache updating apparatus 70 further includes:
a first receiving module 74, configured to receive a first data check request sent by the cache client, where the first data check request includes: caching first version information of each caching domain in the client;
a first detecting module 75, configured to detect whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server, and return a first detection result, so that the cache client determines whether cache updating is needed based on the first detection result.
In an alternative embodiment of the present disclosure, the cache updating apparatus 70 further includes:
a second receiving module 76, configured to receive a second data check request sent by the cache client, where the second data check request includes second version information of each data item in the cache domain to be updated, and the cache domain to be updated is a cache domain whose first detection result is inconsistent;
a second detecting module 77, configured to detect whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and return a second detection result, so that the cache client obtains changed data from the data management server based on the second detection result, updates the local cache with the changed data, and updates the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
It should be noted that, in the cache updating apparatus 70 provided in the embodiment of the present specification, specific ways in which each module performs operations have been described in detail in the system embodiment provided in the first aspect and the method embodiment provided in the second aspect, and specific reference may be made to the system embodiment provided in the first aspect and the method embodiment provided in the second aspect, and details of the operations will not be described here.
In a sixth aspect, based on the same inventive concept as the cache updating method provided in the foregoing third aspect, an embodiment of the present specification further provides a cache updating apparatus. As shown in fig. 8, the cache update apparatus 80 includes:
the version analysis module 81 is configured to obtain updated target version information corresponding to target data in a data management server based on a cache update instruction pushed by the data management server, where the target version information includes first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item;
a request sending module 82, configured to determine whether to initiate a data obtaining request to the data management server based on the updated target version information;
the first cache updating module 83 is configured to update the local cache based on the changed target data returned by the data management server and update the locally stored target version information if a data acquisition request is initiated to the data management server.
In an alternative embodiment of the present disclosure, the request sending module 82 is configured to: and judging whether the updated target version information is matched with locally stored target version information, and if not, initiating a data acquisition request to the data management server.
In an optional embodiment of this specification, the cache updating apparatus 80 further includes:
a first sending module 84, configured to send a first data check request to the data management server if an event for triggering a cache detection task is detected, where the first data check request includes: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result;
and a task ending module, configured to end the cache detection task if the cache domain to be updated does not exist in the first detection result, where the cache domain to be updated is a cache domain in which the first detection result is inconsistent.
In an optional embodiment of this specification, the cache updating apparatus 80 further includes:
a second sending module 85, configured to send a second data check request to the data management server if the cache domain to be updated exists in the first detection result, where the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and returns a second detection result;
and a second cache updating module 86, configured to obtain, based on the second detection result, changed data from the data management server, update the local cache with the changed data, and update the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
It should be noted that, in the cache updating apparatus 80 provided in the embodiment of the present specification, specific ways in which each module performs operations have been described in detail in the system embodiment provided in the first aspect and the method embodiment provided in the third aspect, and specific reference may be made to the system embodiment provided in the first aspect and the method embodiment provided in the third aspect, and a detailed description thereof will not be provided here.
In a seventh aspect, based on the same inventive concept as the cache updating method provided in the foregoing fourth aspect, an embodiment of this specification further provides a cache updating apparatus. As shown in fig. 9, the cache update apparatus 90 includes:
a third sending module 91, configured to send a first data check request to the data management server if an event for triggering the cache detection task is detected, where the first data check request includes: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result;
a fourth sending module 92, configured to send a second data check request to the data management server if a cache domain to be updated exists in the first detection result, where the cache domain to be updated is a cache domain whose first detection result is inconsistent, and the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and returns a second detection result;
and a third cache updating module 93, configured to obtain, based on the second detection result, changed data from the data management server, update a local cache with the changed data, and update the first version information of the cache domain to be updated and the second version information of the changed data in the cache client.
It should be noted that, in the cache updating apparatus 90 provided in the embodiment of the present specification, specific ways in which each module performs operations have been described in detail in the system embodiment provided in the first aspect and the method embodiment provided in the fourth aspect, and specific reference may be made to the system embodiment provided in the first aspect and the method embodiment provided in the fourth aspect, and a detailed description will not be made here.
In an eighth aspect, an embodiment of the present specification further provides an electronic device, as shown in fig. 10, which includes a memory 104, one or more processors 102, and a computer program stored on the memory 104 and executable on the processor 102, where the processor 102, when executing the program, implements the steps of any one implementation of the cache update method provided in the second aspect, the third aspect, or the fourth aspect.
Where in FIG. 10 a bus architecture (represented by bus 106), bus 106 may include any number of interconnected buses and bridges, with bus 106 linking together various circuits including one or more processors, represented by processor 102, and memory, represented by memory 104. The bus 106 may also link together various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface 105 provides an interface between the bus 106 and the receiver 101 and transmitter 103. The receiver 101 and the transmitter 103 may be the same element, i.e. a transceiver, providing a means for communicating with various other apparatus over a transmission medium. The processor 102 is responsible for managing the bus 106 and general processing, while the memory 104 may be used to store data used by the processor 102 in performing operations.
It is to be understood that the structure shown in fig. 10 is merely an illustration, and that the electronic device provided by the embodiments of the present description may further include more or less components than those shown in fig. 10, or have a different configuration than that shown in fig. 10. The components shown in fig. 10 may be implemented in hardware, software, or a combination thereof.
In a ninth aspect, based on the same inventive concept as the cache updating method provided in the foregoing embodiments, this specification embodiment further provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of any one implementation manner of the cache updating method provided in the foregoing second, third or fourth aspect embodiments.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The description has been presented with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the description. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present specification have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all changes and modifications that fall within the scope of the specification.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present specification without departing from the spirit and scope of the specification. Thus, if such modifications and variations of the present specification fall within the scope of the claims of the present specification and their equivalents, the specification is intended to include such modifications and variations.

Claims (24)

1. A cache update method, the method comprising:
if a data change event is detected, updating target version information of target data, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item;
based on the updated target version information, pushing a cache updating instruction to a cache client cached with the target data, so that the cache client determines whether to initiate a data acquisition request based on the cache updating instruction;
and if the data acquisition request sent by the cache client is received, acquiring changed target data based on the data acquisition request, and sending the changed target data to the cache client, so that the cache client updates a local cache by using the changed target data and updates locally stored target version information.
2. The method of claim 1, further comprising:
receiving a first data check request sent by the cache client, wherein the first data check request comprises: caching first version information of each caching domain in the client;
and detecting whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result, so that the cache client determines whether cache updating is needed or not based on the first detection result.
3. The method of claim 2, after returning the first detection result, further comprising:
receiving a second data check request sent by the cache client, wherein the second data check request includes second version information of each data item in a cache domain to be updated, and the cache domain to be updated is a cache domain with inconsistent first detection results;
and detecting whether the second version information of each data item is consistent with the second version information of the data item in the data management server or not, and returning a second detection result, so that the cache client acquires changed data from the data management server based on the second detection result, updates the local cache by using the changed data, and updates the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
4. The method of claim 1, the retrieving the changed target data based on the data retrieval request, comprising:
determining the identification information of the cache domain, the identification information of the target data and the updated target version information from the data acquisition request;
and inquiring the changed target data according to the identification information of the cache domain, the identification information of the target data and the updated target version information.
5. A cache update method, the method comprising:
obtaining updated target version information corresponding to target data in a data management server based on a cache updating instruction pushed by the data management server, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item;
determining whether to initiate a data acquisition request to the data management server based on the updated target version information;
and if a data acquisition request is sent to the data management server, updating a local cache based on the changed target data returned by the data management server, and updating the locally stored target version information.
6. The method of claim 5, determining whether to initiate a data acquisition request to the data management server based on the updated target version information, comprising:
and judging whether the updated target version information is matched with locally stored target version information, and if not, initiating a data acquisition request to the data management server.
7. The method of claim 5, further comprising:
if an event for triggering a cache detection task is detected, sending a first data inspection request to the data management server, where the first data inspection request includes: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result;
if the cache domain to be updated does not exist in the first detection result, the cache detection task is ended, wherein the cache domain to be updated is a cache domain with the first detection result being inconsistent.
8. The method of claim 7, further comprising:
if the cache domain to be updated exists in the first detection result, sending a second data check request to the data management server, wherein the second data check request comprises second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server or not, and returns a second detection result;
and based on the second detection result, obtaining changed data from the data management server, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
9. A cache update method, the method comprising:
if an event for triggering a cache detection task is detected, sending a first data inspection request to a data management server, wherein the first data inspection request comprises: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result;
if the first detection result has a cache domain to be updated, sending a second data check request to the data management server, wherein the cache domain to be updated is a cache domain with inconsistent first detection result, and the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and returns a second detection result;
and based on the second detection result, obtaining changed data from the data management server, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated and the second version information of the changed data in the cache client.
10. A cache updating system comprises a data management server and more than one cache client, wherein,
the data management server is used for updating target version information of target data if a data change event is detected, and pushing a cache updating instruction to a cache client cached with the target data based on the updated target version information, wherein the target data is a changed data item, and the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data;
the cache client is used for obtaining the updated target version information based on the cache updating instruction, and determining whether to initiate a data acquisition request to the data management server based on the updated target version information;
the data management server is used for acquiring changed target data based on the data acquisition request and sending the changed target data to the cache client if the data acquisition request sent by the cache client is received;
the cache client is used for updating the local cache by using the received changed target data and updating the locally stored target version information.
11. The system of claim 10, further comprising: a cache push module for pushing the cache to the client,
the data management server is used for pushing the cache updating instruction to a cache client terminal cached with the target data through the cache pushing module.
12. The system of claim 10, wherein,
the cache client is configured to send a first data check request to the data management server if an event for triggering a cache detection task is detected, where the first data check request includes: caching first version information of each caching domain in the client;
the data management server is used for detecting whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not and returning a first detection result.
13. The system of claim 12, wherein,
the cache client is configured to send a second data check request to the data management server if a cache domain to be updated exists in the first detection result, where the cache domain to be updated is a cache domain with an inconsistent first detection result, and the second data check request includes second version information of each data item in the cache domain to be updated;
the data management server is used for detecting whether the second version information of each data item is consistent with the second version information of the data item in the data management server or not and returning a second detection result;
the cache client is used for acquiring changed data from the data management server based on the second detection result, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated and the second version information of the changed data in the cache client.
14. A cache update apparatus, the apparatus comprising:
the version updating module is used for updating target version information of target data if a data change event is detected, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item;
the pushing module is used for pushing a cache updating instruction to a cache client cached with the target data based on the updated target version information so that the cache client determines whether to initiate a data acquisition request based on the cache updating instruction;
and the data acquisition module is used for acquiring changed target data based on the data acquisition request and sending the changed target data to the cache client if the data acquisition request sent by the cache client is received, so that the cache client updates a local cache by using the changed target data and updates locally stored target version information.
15. The apparatus of claim 14, further comprising:
a first receiving module, configured to receive a first data check request sent by the cache client, where the first data check request includes: caching first version information of each caching domain in the client;
the first detection module is configured to detect whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server, and return a first detection result, so that the cache client determines whether cache updating is required based on the first detection result.
16. The apparatus of claim 15, further comprising:
a second receiving module, configured to receive a second data check request sent by the cache client, where the second data check request includes second version information of each data item in a cache domain to be updated, and the cache domain to be updated is a cache domain whose first detection result is inconsistent;
and the second detection module is used for detecting whether the second version information of each data item is consistent with the second version information of the data item in the data management server or not, and returning a second detection result, so that the cache client acquires changed data from the data management server based on the second detection result, updates the local cache by using the changed data, and updates the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
17. The apparatus of claim 14, the data acquisition module comprising:
a determining submodule, configured to determine, from the data acquisition request, identification information of the cache domain, identification information of the target data, and updated target version information;
and the query submodule is used for querying the changed target data according to the identification information of the cache domain, the identification information of the target data and the updated target version information.
18. A cache update apparatus, the apparatus comprising:
the version analysis module is used for obtaining updated target version information corresponding to target data in a data management server based on a cache updating instruction pushed by the data management server, wherein the target version information comprises first version information of a cache domain to which the target data belongs and second version information of the target data, and the target data is a changed data item;
a request sending module, configured to determine whether to initiate a data acquisition request to the data management server based on the updated target version information;
and the first cache updating module is used for updating the local cache based on the changed target data returned by the data management server and updating the locally stored target version information if a data acquisition request is initiated to the data management server.
19. The apparatus of claim 18, the request sending module to:
and judging whether the updated target version information is matched with locally stored target version information, and if not, initiating a data acquisition request to the data management server.
20. The apparatus of claim 18, further comprising:
a first sending module, configured to send a first data check request to the data management server if an event for triggering a cache detection task is detected, where the first data check request includes: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result;
and a task ending module, configured to end the cache detection task if the cache domain to be updated does not exist in the first detection result, where the cache domain to be updated is a cache domain in which the first detection result is inconsistent.
21. The apparatus of claim 20, further comprising:
a second sending module, configured to send a second data check request to the data management server if the cache domain to be updated exists in the first detection result, where the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and returns a second detection result;
and the second cache updating module is used for acquiring changed data from the data management server based on the second detection result, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated in the cache client and the second version information of the changed data.
22. A cache update apparatus, the apparatus comprising:
a third sending module, configured to send a first data check request to the data management server if an event for triggering the cache detection task is detected, where the first data check request includes: caching the first version information of each cache domain in the client so that the data management server detects whether the first version information of each cache domain is consistent with the first version information of the cache domain in the data management server or not, and returning a first detection result;
a fourth sending module, configured to send a second data check request to the data management server if a cache domain to be updated exists in the first detection result, where the cache domain to be updated is a cache domain whose first detection result is inconsistent, and the second data check request includes second version information of each data item in the cache domain to be updated, so that the data management server detects whether the second version information of each data item is consistent with the second version information of the data item in the data management server, and returns a second detection result;
and the third cache updating module is used for acquiring changed data from the data management server based on the second detection result, updating the local cache by using the changed data, and updating the first version information of the cache domain to be updated and the second version information of the changed data in the cache client.
23. An electronic device, comprising: memory, processor and computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of any one of claims 1-9 when executing the program.
24. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 9.
CN201911011591.1A 2019-10-23 2019-10-23 Cache updating method, device, system, electronic equipment and medium Active CN110941568B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911011591.1A CN110941568B (en) 2019-10-23 2019-10-23 Cache updating method, device, system, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911011591.1A CN110941568B (en) 2019-10-23 2019-10-23 Cache updating method, device, system, electronic equipment and medium

Publications (2)

Publication Number Publication Date
CN110941568A true CN110941568A (en) 2020-03-31
CN110941568B CN110941568B (en) 2022-03-01

Family

ID=69906301

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911011591.1A Active CN110941568B (en) 2019-10-23 2019-10-23 Cache updating method, device, system, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN110941568B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114205368A (en) * 2020-08-27 2022-03-18 腾讯科技(深圳)有限公司 Data storage system, control method, control device, electronic equipment and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101126998A (en) * 2006-08-15 2008-02-20 英业达股份有限公司 Assembling type computer system high speed cache data backup processing method and system
US8819357B2 (en) * 2011-07-12 2014-08-26 Vmware, Inc. Method and system for ensuring cache coherence of metadata in clustered file systems
CN104391653A (en) * 2014-10-31 2015-03-04 山东超越数控电子有限公司 Data block-based cache design method
CN105245560A (en) * 2014-07-11 2016-01-13 阿里巴巴集团控股有限公司 Method, device and system for realizing distributed cache
CN106469073A (en) * 2015-08-19 2017-03-01 阿里巴巴集团控股有限公司 The method and apparatus of display application program splashette image
CN107122410A (en) * 2017-03-29 2017-09-01 武汉斗鱼网络科技有限公司 A kind of buffering updating method and device
CN108319619A (en) * 2017-01-18 2018-07-24 腾讯科技(北京)有限公司 Data processing method and device
US10229058B2 (en) * 2015-12-30 2019-03-12 Roku, Inc. Providing rolling updates of distributed systems with a shared cache

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101126998A (en) * 2006-08-15 2008-02-20 英业达股份有限公司 Assembling type computer system high speed cache data backup processing method and system
US8819357B2 (en) * 2011-07-12 2014-08-26 Vmware, Inc. Method and system for ensuring cache coherence of metadata in clustered file systems
CN105245560A (en) * 2014-07-11 2016-01-13 阿里巴巴集团控股有限公司 Method, device and system for realizing distributed cache
CN104391653A (en) * 2014-10-31 2015-03-04 山东超越数控电子有限公司 Data block-based cache design method
CN106469073A (en) * 2015-08-19 2017-03-01 阿里巴巴集团控股有限公司 The method and apparatus of display application program splashette image
US10229058B2 (en) * 2015-12-30 2019-03-12 Roku, Inc. Providing rolling updates of distributed systems with a shared cache
CN108319619A (en) * 2017-01-18 2018-07-24 腾讯科技(北京)有限公司 Data processing method and device
CN107122410A (en) * 2017-03-29 2017-09-01 武汉斗鱼网络科技有限公司 A kind of buffering updating method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
徐万锦 等: "一种基于Ad_Hoc网络的移动P2P系统协同缓存一致性维护算法", 《楚雄师范学院学报》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114205368A (en) * 2020-08-27 2022-03-18 腾讯科技(深圳)有限公司 Data storage system, control method, control device, electronic equipment and storage medium
CN114205368B (en) * 2020-08-27 2023-06-30 腾讯科技(深圳)有限公司 Data storage system, control method, control device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110941568B (en) 2022-03-01

Similar Documents

Publication Publication Date Title
US8171008B2 (en) Data retrieval
CN109995866B (en) Distributed file verification method and device, computer device and storage medium
CN109167840B (en) Task pushing method, node autonomous server and edge cache server
US10509716B2 (en) Automated recovery of flighted features based on service requests
CN108595505B (en) Data query method and device
CN109254981B (en) Data management method and device of distributed cache system
CN110941568B (en) Cache updating method, device, system, electronic equipment and medium
CN111049882B (en) Cache state processing system, method, device and computer readable storage medium
US8554889B2 (en) Method, system and apparatus for managing computer identity
CN106899651B (en) Communication processing method, system and network communication system
CN111159131A (en) Performance optimization method, device, equipment and computer readable storage medium
CN103118045B (en) A kind of method and system of offline download
CN111796931B (en) Information processing method, device, computing equipment and medium
CN107918617B (en) Data query method and device
CN113486060A (en) Data access processing method and device, storage medium and electronic equipment
US20150095496A1 (en) System, method and medium for information processing
CN110727895B (en) Sensitive word sending method and device, electronic equipment and storage medium
CN111221742A (en) Test case updating method and device, storage medium and server
US20120023489A1 (en) Updating computer files
CN107679198B (en) Information query method and device
CN115396159A (en) Container mirror image detection method, client and server
US10193965B2 (en) Management server and operation method thereof and server system
CN115186164A (en) Search request control method and device, equipment, medium and product thereof
US20200195720A1 (en) Communication device and communication method for processing meta data
CN112738207B (en) Keyword data transmission method and device, storage medium and electronic device

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
GR01 Patent grant
GR01 Patent grant