Cache updating method, updating device, electronic device and storage medium

CN116996573BActive Publication Date: 2026-10-20MIDEA GROUP CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210441490.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-25
Publication Date
2026-10-20
Estimated Expiration
2042-04-25

AI Technical Summary

Benefits of technology

[0030]上述缓存的更新装置、电子设备和计算机可读存储介质,通过事件发起方服务和事件发起方之间的通信,以及事件接收方和事件接收方服务之间的通信,以及事件发起方和事件接收方分别与事件数据库之间通信,实现了各服务相关联的缓存更新,而且各服务无需关注对方服务即可完成缓存更新,实现快速更新。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116996573B_ABST
    Figure CN116996573B_ABST
Patent Text Reader

Abstract

The application discloses a cache updating method, an updating device, an electronic device and a storage medium. The cache updating method comprises the following steps: an event initiator writes a cache updating event into an event database based on the distribution processing of an event completion event of the cache updating event of an event initiator service; the event database pushes the cache updating event to an event receiver, and the event receiver subscribes to the event database in advance; the event receiver receives the cache updating event and writes an event log of an event receiver service based on the cache updating event; and the event receiver service updates cache content in response to the cache updating event based on the event log. The cache updating method can realize the cache updating of the associated services, and the services can complete the cache updating without paying attention to the other services, so that the cache can be quickly updated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cache update technology, and in particular to a cache update method, update device, electronic device and storage medium. Background Technology

[0002] With the massive growth of IoT platform access, the use of service caching is increasing. Many service caches are interconnected, meaning a change in one service will trigger synchronous updates across multiple caches. Therefore, how to update each service when the cache needs updating has become a technical problem to be solved. Summary of the Invention

[0003] This application provides a cache update method, update device, electronic device, and storage medium.

[0004] This application provides a cache update method, including:

[0005] The event initiator completes the event distribution process based on the cache update event of the event initiator service and writes the cache update event into the event database;

[0006] The event database pushes the cache update event to the event receiver, and the event receiver subscribes to the event database for event updates in advance.

[0007] The event receiver receives the cache update event and writes it into the event log of the event receiver service based on the cache update event;

[0008] The event receiver service responds to the cache update event based on the event log to update the cache content.

[0009] The above-described cache update method achieves cache updates associated with each service through communication between the event initiator service and the event initiator, communication between the event receiver and the event receiver service, and communication between the event initiator and the event receiver and the event database respectively. Moreover, each service can complete the cache update without paying attention to the other service, thus achieving fast updates.

[0010] In some implementations, both the event initiator and the event receiver employ a sidecar proxy.

[0011] In some implementations, the cache update method includes:

[0012] The sidecar agent distributes cache update events for the event initiator service;

[0013] The sidecar agent listens for cache update events pushed by the event database.

[0014] In some implementations, the cache update method includes:

[0015] The service registers the topic of event listening with the sidecar agent.

[0016] In some implementations, the cache update method includes:

[0017] Based on the cache update event, the event initiator starts a transaction;

[0018] The event initiator sends the data of the cache update event to the event database;

[0019] The event initiator submits the transaction.

[0020] In some implementations, the cache update method further includes:

[0021] In the event of an anomaly in the event receiver service, the event receiver writes the data of the cache update event to a shared file;

[0022] When the event receiver service restarts, it continues to consume data from the last read position in the event log.

[0023] In some implementations, the cache update method further includes:

[0024] After the event initiator sends the cache update event, it records the receiving status of all receiving nodes;

[0025] If no confirmation signal is received from the event receiver within a preset time period, the event initiator will send the cache update event again.

[0026] In some implementations, the event database is a key-value pair database.

[0027] An embodiment of this application provides a cache updating apparatus, comprising: a memory, a processor, and a cache updating program stored in the memory and executable on the processor. When the cache updating program is executed by the processor, it implements the steps of the cache updating method of any of the above embodiments.

[0028] An electronic device according to an embodiment of this application includes the cache update device of the above embodiment.

[0029] According to an embodiment of this application, a computer-readable storage medium stores a cache update program, which, when executed by a processor, implements the steps of the cache update method of any of the above embodiments.

[0030] The aforementioned cache update device, electronic device, and computer-readable storage medium enable cache updates associated with each service through communication between the event initiator service and the event initiator, communication between the event receiver and the event receiver service, and communication between the event initiator and the event receiver and the event database, respectively. Moreover, each service can complete the cache update without paying attention to the other service, thus achieving rapid updates.

[0031] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0032] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, wherein:

[0033] Figure 1 This is a flowchart of the cache update method according to an embodiment of this application;

[0034] Figure 2 This is a schematic diagram of the abstract structure of the embodiments of this application. Detailed Implementation

[0035] The embodiments of this application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.

[0036] This disclosure provides many different implementations or examples for carrying out different structures of this application. To simplify the disclosure of this application, the components and arrangements of specific examples are described herein. Of course, these are merely examples and are not intended to limit this application.

[0037] Please refer to 1, an embodiment of this application of a cache update method, comprising:

[0038] The event initiator completes the event distribution process based on the cache update event of the event initiator service and writes the cache update event to the event database;

[0039] The event database pushes cached update events to the event receivers, who in turn subscribe to event updates from the event database.

[0040] The event receiver receives cache update events and writes them to the event log of the event receiver service.

[0041] The event receiver service responds to cache update events based on the event log to update the cached content.

[0042] The above-described cache update method achieves cache updates for related services through communication between the event initiator service and the event initiator, communication between the event receiver and the event receiver service, and communication between the event initiator and the event receiver and the event database, and each service can complete the cache update without having to pay attention to the other service, thus achieving fast updates.

[0043] Specifically, in one implementation, the event initiator and the event initiator service can reside on one server, while the event receiver and the event receiver service can reside on another server. That is, one server can act as the initiator, and the other as the receiver. Both servers can include a VPC (Virtual Private Cloud).

[0044] In one implementation, the event initiator and event initiator service, the event receiver and event receiver service reside on the same server. The event initiator and event initiator service may reside in one functional component of that server, while the event receiver and event receiver service reside in another functional component of the server. Both functional components may include a VPC (Virtual Private Cloud).

[0045] Cache update events can include, but are not limited to, cache update content, update time, etc.

[0046] Please combine Figure 2 , Figure 2 This application describes an abstract structure used in the cache update method of its embodiments. A first VPC has two processes: service A and a first agent, and a second VPC has two processes: service B and a second agent. Service A and the first agent communicate via an inter-process communication pipe. The first agent can watch and set events in the event storage.

[0047] Service B and the second agent communicate via an inter-process communication pipe. The second agent can monitor and modify events in the event database.

[0048] In one implementation, the first VPC can act as the initiator, the second VPC can act as the receiver, service A is the event initiator service, the first proxy is the event initiator, service B is the event receiver service, and the second proxy is the event receiver.

[0049] Service A can update its cache based on data reports from IoT devices (such as home appliances). A first agent can communicate with Service A to receive cache update events. The first agent communicates with the event database and can write cache update events to the database. The first agent can also send results to Service A. Because a second agent pre-subscribes to these event updates from the event database, the database can push cache update events to the second agent. The second agent receives the cache update events and writes them to Service B's event log. Service B can then retrieve cache update events to update its own cached content when consuming events.

[0050] In one implementation, the first VPC can act as the receiver, the second VPC can act as the initiator, service B is the event initiator service, the second proxy is the event initiator, service A is the event receiver service, and the first proxy is the event receiver.

[0051] Service B can update its cache based on data reports from IoT devices (such as home appliances). The second agent can communicate with Service B to receive cache update events. The second agent also communicates with the event database, writing cache update events to it. Since the first agent pre-subscribes to these event updates from the event database, the database can push cache update events to the first agent. The first agent receives these events and writes them to Service A's event log. Service A can then retrieve cache update events to update its own cached content when consuming events.

[0052] In summary, cache update events and event consumption are asynchronous, not synchronized. After the caches of two services are updated, the cached content of service A and service B becomes identical, maintaining the consistency of related cached content. Moreover, the related services A and B can be distributed services, and the cache update method of this application can achieve a distributed asynchronous cache consistency scheme. In contrast, in related technologies, cache updates are usually performed through multiple hard-coded calls. As services become more complex, the time consumption and coding complexity of this method increase exponentially, and the coupling between services becomes increasingly tight, ultimately making it impossible to achieve fast updates in service scenarios. The cache update method of this application can achieve service cache updates through simple event-driven mechanisms, and each service does not need to pay attention to the other service.

[0053] For ease of understanding, the following examples illustrate the cache update method of the embodiments of this application. It should be noted that the following examples are only for the purpose of understanding the cache update method of the embodiments of this application, and should not be construed as limiting the scope of protection of this application.

[0054] In the Internet of Things (IoT), physical devices (such as home appliances) can communicate and connect to servers through gateways. When physical devices communicate with servers, there are two scenarios: data reporting and command issuance. Typically, data reporting by physical devices triggers service cache updates.

[0055] In one example, the household appliance could be a water heater. When the water temperature from the water heater changes, the water heater can request service A through the gateway, and service A is a distribution service. Service A will update its cache based on the change in temperature data.

[0056] Service B can be a temperature process of an application (e.g., an app that controls the operation of a water heater). Service B can pre-subscribe to event updates related to the water heater's outlet water temperature through a second agent. When the second agent listens for temperature update events, it causes Service B to update its temperature cache. After the temperature changes, Service B pushes this temperature data to the user's app, allowing the app to perform corresponding actions based on the temperature change. For example, when the water heater's outlet water temperature reaches a suitable temperature for showering, the app can remind the user to take a shower.

[0057] In some implementations, both the event initiator and the event receiver use sidecar proxies.

[0058] In this way, low intrusion of client-side components can be achieved.

[0059] Specifically, the event initiator and the event initiator service can constitute an initiating client component, and the event receiver and the event receiver service can constitute a receiving client component. The sidecar proxy can act as a client. The client component can be based on inter-process communication, such as communication between service A and the sidecar proxy, or communication between service B and the sidecar proxy. This achieves decoupling between the client and the event notification service. The client only depends on the development language SDK or system base library, without needing to depend on specific code libraries, thus achieving low invasiveness of the client component.

[0060] In some implementations, the cache update method includes: the sidecar proxy distributing cache update events for the event initiator service;

[0061] The sidecar agent listens for cache update events pushed by the database.

[0062] In this way, the service can listen for and distribute cache update events through the sidecar proxy.

[0063] Specifically, the sidecar proxy distributes cache update events to the event initiator service, and each event receiver service can listen to the cache update events of the event database through the sidecar proxy. Each service does not need to pay attention to the other service to achieve related cache updates to achieve data consistency across all ends. Moreover, asynchronous updates can be achieved in terms of update time, making more reasonable use of system resources and improving system operating efficiency.

[0064] In some implementations, the cache update method includes: the service registering an event listening topic with the sidecar agent.

[0065] This allows the sidecar agent to monitor relevant events.

[0066] Specifically, services can register event listening topics with the sidecar agent according to their own needs. The sidecar agent can communicate with the event database and listen uniformly.

[0067] When a relevant cache update event occurs, the sidecar proxy can listen for the event, obtain the relevant cache update event, and write it to the service's event log. The service responds to the cache update event to update the cached content, thus realizing the push of the cache update content to the event receiver service for consumption, and finally completing the update of the cached content.

[0068] In some implementations, the cache update method includes:

[0069] Based on the cache update event, the event initiator starts a transaction;

[0070] The event initiator sends the cached update event data to the event database;

[0071] The event initiator submits the transaction.

[0072] In this way, high event reliability can be achieved from the event initiator.

[0073] Specifically, the event initiator can leverage the transaction isolation capabilities supported by the event database to initiate a transaction. The event initiator sends cached update event data to the event database, and then commits the transaction, thus completing a reliable commit. By using transaction commit to initiate events, the event initiator can guarantee the reliability of the commit, thereby achieving high event reliability from the event initiator's perspective.

[0074] The event initiator submits a transaction, specifically by updating the event based on the cache of the event initiator service, completing the event distribution process, and writing the cached update event into the event database.

[0075] In some implementations, the cache update method further includes:

[0076] In the event receiver service failure, the event receiver will write the cached update event data to a shared file;

[0077] When the event receiver service restarts, it continues consuming from the last read position in the event log.

[0078] In this way, high event reliability can be achieved from the event receiver.

[0079] Specifically, events are updated via communication between the service and the agent processes, and through file sharing. Even if the event receiver service encounters an anomaly (such as a system crash), the event data from the event receiver (e.g., a sidecar agent) can still be written to shared files, such as a VPC temporary file. Upon restarting the event receiver service, it can resume consuming events from the last read position in the event log.

[0080] In some implementations, the cache update method further includes:

[0081] After the event initiator sends the cache update event, it records the receiving status of all receiving nodes;

[0082] If no confirmation signal is received from the event recipient within a preset time period, the event initiator will send a cache update event again.

[0083] In this way, an event confirmation mechanism can be implemented, thereby achieving high event reliability.

[0084] Specifically, after sending a cache update event, the event initiator can record the reception status of all receiving nodes. After sending, the event initiator waits for a preset time to see if it receives a reception acknowledgment signal from the event receiver. When the event receiver receives the cache update event, it replies with a reception acknowledgment signal to the event initiator. If the event initiator receives the reception acknowledgment signal within the preset time, it records the reception status of the corresponding receiving node as "received". If the event initiator does not receive the reception acknowledgment signal within the preset time, it records the reception status of the corresponding receiving node as "not received". For cache update events corresponding to the "not received" status, the event initiator resends the cache update event in a retry manner, thereby achieving high event reliability. The number of retries can be one, two, or more than two, without specific limitation.

[0085] In some implementations, the event database uses a key-value database (KV database).

[0086] In this way, high performance can be achieved.

[0087] Specifically, the event database uses a key-value database, and event data is written to the KV database. There is a wide range of KV database options, such as ETCD and MongoDB. The middleware performance can be easily horizontally scaled to achieve high-performance cache consistency.

[0088] In summary, the cache update method of the embodiments of this application can achieve at least the following technical effects:

[0089] 1. Service providers do not need to worry about event distribution and subscription components, and are decoupled from specific middleware, resulting in low invasiveness;

[0090] 2. It greatly reduces the rate of event loss and significantly improves the reliability of the entire system;

[0091] 3. The entire service was scaled up based on service levels, achieving high-performance cache consistency.

[0092] An embodiment of the present application provides a cache updating apparatus, comprising: a memory, a processor, and a cache updating program stored in the memory and executable on the processor. When the cache updating program is executed by the processor, it implements the steps of the cache updating method of any of the above embodiments.

[0093] An electronic device according to an embodiment of this application includes the cache update device of the above embodiment. Specifically, the electronic device includes, but is not limited to, servers, personal computers, mobile phones, tablet computers, and home appliances.

[0094] This application provides a computer-readable storage medium storing a cache update program, which, when executed by a processor, implements the steps of the cache update method of any of the above embodiments.

[0095] In one implementation, the cache update method, implemented when the cache updater is executed by the processor, includes:

[0096] The event initiator completes the event distribution process based on the cache update event of the event initiator service and writes the cache update event to the event database;

[0097] The event database pushes cached update events to the event receivers, who in turn subscribe to event updates from the event database.

[0098] The event receiver receives cache update events and writes them to the event log of the event receiver service.

[0099] The event receiver service responds to cache update events based on the event log to update the cached content.

[0100] The aforementioned cache update device, electronic device, and computer-readable storage medium enable cache updates associated with each service through communication between the event initiator service and the event initiator, communication between the event receiver and the event receiver service, and communication between the event initiator and the event receiver and the event database, respectively. Moreover, each service can complete the cache update without paying attention to the other service, thus achieving rapid updates.

[0101] It should be noted that the above explanation of the implementation method and beneficial effects of the cache update method also applies to the cache update device, electronic device and computer-readable storage medium of this embodiment. To avoid redundancy, they will not be elaborated in detail here.

[0102] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0103] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, home appliance, or network device, etc.) to execute the methods of the various embodiments of the present invention.

[0104] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.

Claims

1. A cache update method, characterized in that, include: The event initiator completes the event distribution process based on the cache update event of the event initiator service and writes the cache update event into the event database; The event database pushes the cache update event to the event receiver, and the event receiver subscribes to the event database for event updates in advance. The event receiver receives the cache update event and writes it into the event log of the event receiver service based on the cache update event; The event receiver service responds to the cache update event based on the event log to update the cache content; Both the event initiator and the event receiver use a sidecar proxy. The cache update method further includes: in the event receiver service encountering an anomaly, the event receiver writes the data of the cache update event to a shared file; when the event receiver service restarts, the event receiver service continues to consume data from the last read position of the event log; The cache update method further includes: after the event initiator sends the cache update event, it records the reception status of all receiving nodes; if no reception confirmation signal is received from the event receiver within a preset time period, the event initiator sends the cache update event again.

2. The cache update method according to claim 1, characterized in that, The cache update method includes: The sidecar agent distributes cache update events for the event initiator service; The sidecar agent listens for cache update events pushed by the event database.

3. The cache update method according to claim 1, characterized in that, The cache update method includes: The service registers the topic of event listening with the sidecar agent.

4. The cache update method according to claim 1, characterized in that, The cache update method includes: Based on the cache update event, the event initiator starts a transaction; The event initiator sends the data of the cache update event to the event database; The event initiator submits the transaction.

5. The cache update method according to claim 1, characterized in that, The event database is a key-value pair database.

6. A cache update apparatus, characterized in that, include: A memory, a processor, and a cache updater stored in the memory and executable on the processor, wherein the cache updater, when executed by the processor, implements the steps of the cache update method according to any one of claims 1-5.

7. An electronic device, characterized in that, Includes the cache update device as described in claim 6.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a cache update program, which, when executed by a processor, implements the steps of the cache update method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Distributed event-driven service system of Internet of Things

    CN113489756A