A cache data updating method, system, computing device, and storage medium

By registering ephemeral nodes and binding them to message queues in the coordination middleware, the local cache is updated in real time, which solves the problem of cache data consistency, improves the interface response performance and stability, and is suitable for high-concurrency scenarios.

CN116192956BActive Publication Date: 2026-04-21BEIJING CHESHANGHUI SOFTWARE
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING CHESHANGHUI SOFTWARE
Filing Date
2023-01-04
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing cache data update methods struggle to guarantee data consistency between the database and various levels of cache in high-concurrency scenarios. Furthermore, existing technologies cannot update local caches in a timely manner when data changes, leading to a decline in interface response performance.

Method used

By registering ephemeral nodes in the coordination middleware, generating application identifiers, creating message queues and binding them to sector switches, real-time monitoring of data change messages is achieved, and when new data change messages are detected, the messages are consumed to update the local cache.

Benefits of technology

It improves interface response speed in high-concurrency scenarios, ensures data consistency among databases, caching middleware, and local cache, and has scalability and high stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116192956B_ABST
    Figure CN116192956B_ABST
Patent Text Reader

Abstract

This invention discloses a method, system, computing device, and storage medium for updating cached data. The method is suitable for execution in an application server and includes: reading the pre-configured number of application instances from a configuration center; registering a temporary node with a coordination middleware and generating an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances; creating a message queue corresponding to the current application instance based on the application identifier and binding the message queue to a fan switch of the message middleware to listen for messages; if a new data change message is received in the message queue, consuming the new data change message to update the local cache.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method, system, computing device, and storage medium for updating cached data. Background Technology

[0002] Redis (Remote Dictionary Server) is an open-source, network-enabled, in-memory or persistent, log-structured database that stores data in key-value pairs. It provides APIs (Application Programming Interfaces) in multiple languages, which can be used to cache data to improve interface response speed.

[0003] However, as QPS (Queries Per Second) increases further, the pressure on Redis also increases, leading to issues such as timeouts and insufficient connections. In this case, a local cache is used as a first-level cache. When calling the API to query data, the local cache is queried first. If the data is not found, the second-level cache (such as Redis) is then queried. If the data exists, there is no need to query the second-level cache, reducing interactions and improving response performance.

[0004] When an API call is made, the server caches the data based on parameters such as the passed business identifier. Subsequent calls can retrieve data directly from the local cache. Furthermore, if the data in the database changes, the second-level cache needs to be refreshed and the local cache discarded. While using caching to store data for API queries offers the advantage of fast response times, if the cache isn't updated promptly when data changes, it's difficult to guarantee data consistency between the database and all levels of cache, ultimately leading to the inability to retrieve the latest data from the cache.

[0005] Currently, there are two common methods for updating local caches. The first method sets different expiration times for the local cache and the second-level cache. When data changes, a delayed double-delete strategy is used to ensure consistency between the data in the database and the data in the second-level cache. Since the local cache has a shorter expiration time, the data in the second-level cache is queried and loaded into the local cache only after the local cache expires. However, the data in this method is not updated in near real-time, and the expiration time needs to be set according to the business scenario.

[0006] The second approach utilizes Redis's publish / subscribe functionality. This allows for cache monitoring, where notifications are received when data changes, prompting updates to the local cache. However, this feature lacks a retry mechanism. If a local cache update fails, notifications for the same data change are never received again until a notification for a different data change occurs. This process continues until the local cache expires, at which point the latest data can be loaded.

[0007] Therefore, a new cached data update scheme is needed to optimize the above processing. Summary of the Invention

[0008] Therefore, the present invention provides a cached data update scheme in an attempt to solve or at least alleviate the problems mentioned above.

[0009] According to one aspect of the present invention, a cache data update method is provided, suitable for execution in an application server, comprising the following steps: First, reading the pre-configured number of application instances from a configuration center; registering a temporary node with a coordination middleware, and generating an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances; creating a message queue corresponding to the current application instance based on the application identifier, and binding the message queue to a fan switch of the message middleware to listen for messages; if a new data change message is received in the message queue, consuming the new data change message to update the local cache.

[0010] Optionally, in the cached data update method according to the present invention, registering a temporary node with the coordination middleware and generating an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances includes: registering a temporary node with the coordination middleware and obtaining the node identifier of the temporary node through the IP address and port registration path of the current application instance; calculating the result of modulo the number of application instances and the node identifier as the application identifier of the current application instance.

[0011] Optionally, in the cached data update method according to the present invention, the fan switch of the message middleware is bound to a database server. The database server has a preset database deployed and is connected to the cache middleware for communication. When the data changes, the database server modifies the data in the database accordingly, updates the data in the cache middleware, and sends a data change message generated based on the latest cached data in the cache middleware to the fan switch.

[0012] Optionally, in the cached data update method according to the present invention, the data change message is delivered by the sector switch to each message queue bound to the sector switch.

[0013] Optionally, in the cache data update method according to the present invention, if a new data change message is received in the message queue, the local cache is updated by consuming the new data change message, including: if a new data change message is received in the message queue, all data in the local cache is deleted, the local cache is set according to the new data change message, and the cache expiration time is reset.

[0014] According to another aspect of the present invention, a cached data update system is provided, comprising a configuration center, a coordination middleware, a message middleware, and multiple application servers. The configuration center is pre-configured with a number of application instances. Each application server is communicatively connected to the configuration center, the coordination middleware, and the message middleware. The application servers are adapted to: read the number of application instances from the configuration center; register a temporary node with the coordination middleware and generate an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances; create a message queue corresponding to the current application instance based on the application identifier, and bind the message queue to a fan switch of the message middleware to listen for messages; when a new data change message is received in the message queue, consume the new data change message and update the local cache.

[0015] Optionally, the cached data update system according to the present invention further includes a database server and a cached middleware connected in communication with the database server. The database server is bound to the sector switch and has a preset database deployed thereon. The database server is adapted to: modify the data in the database accordingly when the data changes, update the data in the cached middleware, and generate a data change message based on the latest cached data in the cached middleware and send it to the sector switch.

[0016] Optionally, in the cached data update system according to the present invention, the message middleware is adapted to: deliver the data change messages received by the sector switch to each message queue bound to the sector switch via the sector switch.

[0017] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions including instructions for performing the cached data update method as described above.

[0018] According to another aspect of the present invention, a readable storage medium storing program instructions is provided, which, when read and executed by a computing device, causes the computing device to perform the cached data update method as described above.

[0019] According to the cached data update scheme of the present invention, the application identifier of the current application instance is generated by using the node identifier of the temporary node registered in the coordination middleware and the number of application instances read from the configuration center. A message queue is created based on the application identifier and bound to the fan-shaped switch of the message middleware to listen for messages in real time. If a new data change message is detected, it is consumed to synchronously update the local cache. It can support scenarios with high interface access volume or high concurrency, has a faster interface response speed, and has portability, scalability and high stability.

[0020] In the above technical solution, the sector switch is also bound to a database server. When data changes, the database data in the database server is modified accordingly, and the data cached in the caching middleware is also updated. The data change message generated based on the latest cached data is sent to the sector switch, so that the sector switch can deliver the data change message to each message queue bound to the sector switch. This realizes the broadcast message and achieves the purpose of indiscriminately notifying different application instances of the same application to update the local cache, thereby maintaining the consistency of data in the database, caching middleware and local cache. Attached Figure Description

[0021] To achieve the foregoing and related objectives, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings. These aspects indicate various ways in which the principles disclosed herein may be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The foregoing and other objectives, features, and advantages of this disclosure will become more apparent from the following detailed description, taken in conjunction with the accompanying drawings. Throughout this disclosure, the same reference numerals generally refer to the same parts or elements.

[0022] Figure 1 A schematic diagram of a cached data update system 100 according to an embodiment of the present invention is shown;

[0023] Figure 2 A schematic diagram of a cached data update system 200 according to yet another embodiment of the present invention is shown;

[0024] Figure 3 A structural block diagram of a computing device 300 according to an embodiment of the present invention is shown; and

[0025] Figure 4 A flowchart of a cache data update method 400 according to an embodiment of the present invention is shown. Detailed Implementation

[0026] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0027] Figure 1 A schematic diagram of a cached data update system 100 according to an embodiment of the present invention is shown. It should be noted that... Figure 1The cached data update system 100 is merely an example. In a specific implementation, the cached data update system 100 may have different numbers of configuration centers, coordination middleware, message middleware, and application servers, depending on the actual situation. There is no limitation on this.

[0028] like Figure 1 As shown, the cached data update system 100 includes a configuration center 110, a coordination middleware 120, a message middleware 130, and N application servers. The N application servers form an application server cluster, which includes application server 1, application server 2, ..., application server N, where N is a positive integer greater than 1.

[0029] Figure 1 Each of the N application servers communicates with the configuration center 110, the coordination middleware 120, and the message middleware 130, respectively. To ensure clarity of the diagram, Figure 1 The document only shows the communication connections between application server 1 and configuration center 110, coordination middleware 120, and message middleware 130. The communication connections between application servers 2 to N and configuration center 110, coordination middleware 120, and message middleware 130 are omitted and not included in the document. Figure 1 As shown.

[0030] Configuration center 110 is pre-configured with the number of application instances. For a given application, the number of application servers deploying that application should be the same as the number of corresponding application instances. The following is a brief explanation of the cache data update process using application server 1 as an example.

[0031] Application server 1 reads the number of application instances from configuration center 110, registers a temporary node with coordination middleware 120, and generates an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances. Then, it creates a message queue corresponding to the current application instance based on the application identifier and binds the message queue to the fan switch of message middleware 130 to listen for messages. When a new data change message is received in the message queue, the server consumes the new data change message and updates the local cache.

[0032] Figure 2 A schematic diagram of a cached data update system 200 according to yet another embodiment of the present invention is shown. It should be noted that... Figure 2 The cache data update system 200 shown is merely an example. In a specific implementation, the cache data update system 200 may contain different numbers of application servers, configuration centers, coordination middleware, message middleware, database servers, and cache middleware, depending on the actual situation. There is no limitation on this.

[0033] To facilitate understanding, the following is a brief explanation of the system setup and initialization.

[0034] First, deploy the application on the cloud container platform and determine the number of application instances to be configured. This number is designated as the application instance count. For example, a count of 3 means the application will have 3 instances deployed. Deploy the required number of application instances to form an application instance cluster. Each application instance can be considered as being deployed on a corresponding application server, which can execute or respond to a series of commands by starting the application instance.

[0035] Typically, the number of application instances needs to be pre-configured in the configuration center. If the configuration center has not pre-configured the number of application instances, it will initialize the number of application instances in the configuration center through a scheduled task after the application instance starts. Of course, this scheduled task can also periodically obtain the number of application instances configured by the cloud container platform to update the number of application instances maintained by the configuration center.

[0036] The aforementioned configuration center can be implemented using Apollo, an open-source configuration management center. Apollo can centrally manage the configurations of applications in different environments and clusters. After the configuration is modified, it can be pushed to the application in real time, and it has standardized permissions, process governance and other features.

[0037] Then, deploy the coordination middleware, message middleware, database server, and caching middleware respectively. Among them, the coordination middleware can be implemented using ZooKeeper (a distributed, open-source application coordination service) so that ZooKeeper can register ephemeral nodes and assign corresponding node identifiers for different decentralized application instances of the same application.

[0038] The message middleware can be RabbitMQ (an open-source message broker software that implements the Advanced Message Queuing Protocol), and the RabbitMQ exchange type can be selected as Fanout type. This type of exchange is generally called a fanout exchange, which is used to forward messages sent to the exchange to all message queues bound to the exchange.

[0039] A database server can be understood as a data storage service provider, on which a pre-defined database, such as MySQL (a relational database), is deployed. The database server and the message middleware can pre-agree on information such as exchange names and message formats, so that the database server can bind to the corresponding fan-shaped exchange using the exchange name, for example, binding to a Fanout type exchange in RabbitMQ. When data changes, the data storage service provider can modify the database, update data in the caching middleware, etc., where Redis can be used to provide caching services.

[0040] like Figure 2 As shown, the cached data update system 200 includes an application server cluster 210, a configuration center 220, a coordination middleware 230, and a message middleware 240. The application server cluster 210 includes application servers 211, 212, and 213, each corresponding to a different application instance of the same application; that is, the number of application instances is three.

[0041] Considering that the diagram should be as clear as possible and easy to compare, and that the connection relationships are the same for each application server in application server cluster 210, therefore... Figure 2 The diagram only shows the communication connection between application server 211 and coordination middleware 230, etc., and the communication connections related to application server 212 and application server 213 are not shown due to omission.

[0042] Since application servers 211, 212, and 213 follow the same steps in updating cached data, the following explanation will use application server 211 as an example.

[0043] According to one embodiment of the present invention, the application server 211 is communicatively connected to the configuration center 220, the coordination middleware 230, and the message middleware 240, respectively, wherein the configuration center 220 is pre-configured with the number of application instances. In this embodiment, the number of application instances can be maintained in the configuration center 220 in the form of key-value pairs. For example, when the number of application instances is 3, if instance is the key, then 3 is the value corresponding to the key.

[0044] When the current application instance of application server 211 starts, it reads the number of application instances from configuration center 220, registers temporary nodes with coordination middleware 230, and generates application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances.

[0045] According to one embodiment of the present invention, the application server 211 can register a temporary node with the coordination middleware 230 in the following manner, and generate an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances. In this embodiment, the temporary node is first registered with the coordination middleware 230, and the node identifier of the temporary node is obtained through the IP (Internet Protocol) address and port registration path of the current application instance. Then, the result of modulo the number of application instances and the node identifier is calculated as the application identifier of the current application instance.

[0046] The ephemeral nodes here are generally ordered ephemeral nodes, with their node identifiers being auto-incrementing sequence identifiers. When ZooKeeper is used to implement the coordination middleware 230, registered nodes will generate ordered ephemeral nodes according to their order and without duplication. After the application is deployed to the cloud container platform and starts, IP addresses will be automatically assigned to each application instance of the application, and the application instances will also be configured with application ports accordingly. Furthermore, for the application server 211, it can obtain the ephemeral node and its corresponding node identifier from the application port configured in the current application instance under the port registration path " / example / instance / server" in ZooKeeper, and write the IP address and node identifier into the ephemeral node.

[0047] Then, application server 211 creates a message queue corresponding to the current application instance based on the application identifier, and binds the message queue to the fanout exchange of message middleware 240 to listen for messages. According to one embodiment of the present invention, message middleware 240 is RabbitMQ. When the current application instance starts, application server 211 dynamically registers the queue name and creates a message queue corresponding to the current application instance based on the aforementioned application identifier, and binds the message queue to the fanout type exchange of RabbitMQ.

[0048] According to one embodiment of the present invention, the cached data update system 200 further includes a database server 250 and a cache middleware 260 that is communicatively connected to the database server 250. The database server 250 is also communicatively connected to a message middleware 240 and is bound to a fan switch and has a preset database deployed thereon.

[0049] In this implementation, when data changes, the database server 250 can modify the data in the database accordingly, update the data in the caching middleware 260, and generate a data change message based on the latest cached data in the caching middleware 260 and send it to the sector switch. The database can be a MySQL database, and the caching middleware can be implemented using Redis.

[0050] Next, message middleware 240 will use a sector switch to deliver the data change message received by the sector switch to the respective message queues bound to the sector switch. For example, if the sector switch receives data change message Q1, as mentioned above, there should be three message queues bound to this sector switch, corresponding to application servers 211, 212, and 213 respectively. Therefore, message middleware 240 will deliver the data change message Q1 to these three message queues through the sector switch, or in other words, directly through the sector switch.

[0051] Therefore, application servers 211, 212, and 213 can all listen to their respective message queues to detect whether a new data change message has been received. For application server 211, if a new data change message is detected in the message queue, it consumes the new data change message and updates the local cache.

[0052] According to one embodiment of the present invention, the local cache can be updated by consuming new data change messages in the following manner. In this embodiment, if the application server 211 detects that a new data change message has been received in the message queue, it deletes all data in the local cache, sets the local cache according to the new data change message, and resets the cache expiration time. The relevant code examples for the above processing steps are as follows:

[0053] @RabbitListener(queues="#{queue.name}")

[0054] public void listen(Message message,Channel channel)

[0055] {

[0056] String message=new String(message.getBody());

[0057] JSONObject object=JSON.parseObject(message);

[0058] cache.evict(object.getInteger("id"));

[0059] cache.put(key, message);

[0060] }

[0061] According to one embodiment of the present invention, the caching middleware 260 also has communicative connections with each application server in the application server cluster 210. Figure 2 The diagram only shows the communication connection between the cache middleware 260 and the application server 211. When the current application instance has a data interface call, the cached data in Redis can be queried using a local lock, and then the cached data can be stored in the local cache.

[0062] Figure 1 The application server 1, application server 2, ..., application server N shown, and Figure 2 The application servers 211, 212 and 213 shown can all be implemented as a computing device.

[0063] Figure 3 A structural block diagram of a computing device 300 according to an embodiment of the present invention is shown.

[0064] like Figure 3 As shown, in the basic configuration 302, the computing device 300 typically includes a system memory 306 and one or more processors 304. A memory bus 308 can be used for communication between the processors 304 and the system memory 306.

[0065] Depending on the desired configuration, processor 304 can be any type of processor, including but not limited to: microprocessor (UP), microcontroller (UC), digital information processor (DSP), or any combination thereof. Processor 304 may include one or more levels of cache such as L1 cache 310 and L2 cache 312, processor core 314, and registers 316. Example processor core 314 may include an arithmetic logic unit (ALU), floating-point unit (FPU), digital signal processing core (DSP core), or any combination thereof. Example memory controller 318 may be used with processor 304, or in some implementations, memory controller 318 may be an internal part of processor 304.

[0066] Depending on the desired configuration, system memory 306 can be any type of memory, including but not limited to volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 306 may include operating system 320, one or more applications 322, and program data 324. In some embodiments, applications 322 may be arranged to execute instructions on the operating system using program data 324 by one or more processors 304.

[0067] The computing device 300 also includes a storage device 332, which includes a removable storage device 336 and a non-removable storage device 338.

[0068] The computing device 300 may also include a storage interface bus 334. The storage interface bus 334 enables communication from storage devices 332 (e.g., removable memory 336 and non-removable memory 338) to the basic configuration 302 via a bus / interface controller 330. At least a portion of the operating system 320, application 322, and program data 324 may be stored on the removable memory 336 and / or the non-removable memory 338, and loaded into system memory 306 via the storage interface bus 334 when the computing device 300 is powered on or when application 322 is to be executed, and executed by one or more processors 304.

[0069] The computing device 300 may also include an interface bus 340 that facilitates communication from various interface devices (e.g., output devices 342, peripheral interfaces 344, and communication devices 346) to the basic configuration 302 via a bus / interface controller 330. Example output devices 342 include a graphics processing unit 348 and an audio processing unit 350. They may be configured to facilitate communication with various external devices such as displays or speakers via one or more A / V ports 352. Example peripheral interfaces 344 may include a serial interface controller 354 and a parallel interface controller 356, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboards, mice, pens, voice input devices, touch input devices) or other peripherals (e.g., printers, scanners, etc.) via one or more I / O ports 358. Example communication devices 346 may include a network controller 360, which may be arranged to facilitate communication with one or more other computing devices 362 via a network communication link through one or more communication ports 364.

[0070] A network communication link can be an example of a communication medium. A communication medium can typically be embodied in a modulated data signal, such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A “modulated data signal” can be a signal whose data set, or its modifications, can be encoded as information within the signal. As a non-limiting example, a communication medium can include wired media such as wired networks or leased lines, and various wireless media including sound, radio frequency (RF), microwave, infrared (IR), or other wireless media. The term “computer-readable medium” as used herein can include both storage media and communication media.

[0071] The computing device 300 can be implemented as a personal computer, including desktop and laptop computer configurations. Of course, the computing device 300 can also be implemented as part of a small-sized portable (or mobile) electronic device, such as a cellular phone, digital camera, personal digital assistant (PDA), personal media player device, wireless network browsing device, personal head-mounted device, application-specific device, or a hybrid device that may include any of the above functions. It can even be implemented as a server, such as a file server, database server, application server, and web server. The embodiments of the present invention do not limit this.

[0072] In an embodiment of the present invention, the computing device 300 may be implemented as follows: Figure 1 or Figure 2 Any application server in the system is configured to execute the cache data update method 400 according to the present invention. The application 322, located on the operating system, contains multiple program instructions for executing the cache data update method 400 of the present invention. These program instructions can instruct the processor 304 to execute the cache data update method 400 of the present invention, so that the application server in the cache data update system 100 or 200 updates the cached data by executing the cache data update method 400 of the present invention.

[0073] Figure 4 A flowchart of a cache data update method 400 according to an embodiment of the present invention is shown.

[0074] like Figure 4 As shown, method 400 begins with step S410. In step S410, the pre-configured number of application instances is read from the configuration center.

[0075] Then, proceed to step S420, register a temporary node with the coordination middleware, and generate the application identifier of the current application instance based on the node identifier of the temporary node and the number of application instances.

[0076] According to one embodiment of the present invention, ephemeral nodes can be registered with the coordination middleware in the following manner, and the application identifier of the current application instance can be generated based on the node identifier of the ephemeral node and the number of application instances. In this embodiment, ephemeral nodes are registered with the coordination middleware, and the node identifier of the ephemeral node is obtained through the IP address and port registration path of the current application instance. The result of modulo the number of application instances and the node identifier is calculated as the application identifier of the current application instance.

[0077] In step S430, a message queue corresponding to the current application instance is created based on the application identifier, and the message queue is bound to the fan switch of the message middleware to listen for messages.

[0078] According to one embodiment of the present invention, the fan switch of the message middleware is bound to a database server. The database server deploys a preset database and communicates with the caching middleware. When data changes, the database server modifies the data in the database accordingly, updates the data in the caching middleware, and sends a data change message generated based on the latest cached data in the caching middleware to the fan switch. In this embodiment, the data change message is delivered by the fan switch to each message queue bound to the fan switch.

[0079] Finally, step S440 is executed: if a new data change message is received in the message queue, the new data change message is consumed to update the local cache.

[0080] According to one embodiment of the present invention, if a new data change message is received in the message queue, the local cache can be updated by consuming the new data change message. In this embodiment, if a new data change message is received in the message queue, all data in the local cache is deleted, the local cache is set according to the new data change message, and the cache expiration time is reset.

[0081] The execution logic of each step in the above method 400 can be found in the detailed description of the cache data update system 100 or 200 in the previous text, and will not be repeated here.

[0082] According to the cached data update scheme of the present invention, the node identifier of the temporary node registered in the coordination middleware and the number of application instances read from the configuration center are used to generate the application identifier of the current application instance. Based on the application identifier, a message queue is created and bound to the fan-shaped switch of the message middleware to listen for messages in real time. If a new data change message is detected, it is consumed to synchronously update the local cache. This scheme can support higher QPS, has better interface response performance, and is stable, portable, and scalable.

[0083] In the above technical solution, the sector switch is also bound to a database server. When data changes, the database server modifies the data accordingly and updates the cached data in the caching middleware. A data change message generated based on the latest cached data is then sent to the sector switch. The sector switch then delivers the data change message to each message queue bound to it, thus broadcasting the message and achieving the goal of indiscriminately notifying different application instances of the same application to update their local caches. In other words, the same code deployed to multiple application instances can consume the same data change message, achieving decoupling of the message notification scheme, near real-time performance, and ultimately ensuring data consistency between the database, caching middleware, and local cache. Furthermore, the message middleware can be deployed in a distributed cluster to further improve interface response speed while enhancing message notification performance.

[0084] The various techniques described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, can take the form of program code (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, USB flash drive, floppy disk, CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into and executed by a machine such as a computer, the machine becomes an apparatus for practicing the present invention.

[0085] When the program code is executed on a programmable computer, the computing device generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store program code; the processor is configured to execute the cache data update method of the present invention according to instructions in the program code stored in the memory.

[0086] By way of example, and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer-readable instructions, data structures, program modules, or other data. Communication media generally embodies computer-readable instructions, data structures, program modules, or other data in the form of modulated data signals such as carrier waves or other transmission mechanisms, and includes any information delivery medium. Any combination of the above is also included within the scope of readable media.

[0087] In the specification provided herein, the algorithms and displays are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with the examples of this invention. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0088] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0089] Similarly, it should be understood that, in order to streamline this disclosure and aid in understanding one or more of the various aspects of the invention, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.

[0090] Those skilled in the art will understand that modules, units, or components of the devices disclosed in the examples herein can be arranged in the devices described in this embodiment, or alternatively, can be located in one or more devices different from the devices in this example. The modules in the foregoing examples can be combined into a single module or further divided into multiple sub-modules.

[0091] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0092] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.

[0093] Furthermore, some of the embodiments described herein are methods or combinations of method elements that can be implemented by a processor of a computer system or by other means of performing the functions. Therefore, a processor having the necessary instructions for implementing the methods or method elements forms means for implementing the methods or method elements. Furthermore, the elements described herein in the apparatus embodiments are examples of means for implementing the functions performed by elements for the purposes of carrying out the invention.

[0094] As used herein, unless otherwise specified, the use of ordinal numbers such as “first,” “second,” “third,” etc., to describe ordinary objects merely indicates different instances of similar objects and is not intended to imply that the objects being described must have a given order in time, space, ordering, or any other manner.

[0095] Although the invention has been described with reference to a limited number of embodiments, those skilled in the art will understand from the foregoing description that other embodiments are conceivable within the scope of the invention described herein. Furthermore, it should be noted that the language used in this specification has been chosen primarily for readability and instructional purposes, and not for the purpose of interpreting or limiting the subject matter of the invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the invention is illustrative and not restrictive, and the scope of the invention is defined by the appended claims.

Claims

1. A method for updating cached data, suitable for execution in an application server, comprising: Read the pre-configured number of application instances from the configuration center; Registering a temporary node with the coordination middleware and generating an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances includes registering a temporary node with the coordination middleware, obtaining the node identifier of the temporary node through the IP address and port registration path of the current application instance, and calculating the modulo result of the number of application instances and the node identifier as the application identifier of the current application instance. A message queue corresponding to the current application instance is created based on the application identifier. The message queue is bound to the fan switch of the message middleware to listen for messages. The fan switch of the message middleware is bound to a database server. The database server has a preset database deployed and communicates with the caching middleware. When the data changes, the database server modifies the data in the database accordingly, updates the data in the caching middleware, and sends a data change message generated based on the latest cached data in the caching middleware to the fan switch. The data change message is delivered by the fan switch to each message queue bound to the fan switch. If a new data change message is detected in the message queue, the local cache is updated by consuming the new data change message.

2. The method as described in claim 1, wherein, If a new data change message is detected in the message queue, then consuming the new data change message to update the local cache includes: If a new data change message is received in the message queue, all data in the local cache is deleted, the local cache is set according to the new data change message, and the cache expiration time is reset.

3. A cached data update system, comprising a configuration center, a coordination middleware, a message middleware, multiple application servers, a database server, and a cache middleware, wherein: The configuration center is pre-configured with the number of application instances; The database server is bound to the fan switch and has a pre-set database deployed on it; Communication connections between the database server and the caching middleware; Each of the plurality of application servers is communicatively connected to the configuration center, the coordination middleware, and the message middleware, respectively, and the application server is adapted to: Read the number of application instances from the configuration center; Registering a temporary node with the coordination middleware and generating an application identifier for the current application instance based on the node identifier of the temporary node and the number of application instances includes registering a temporary node with the coordination middleware, obtaining the node identifier of the temporary node through the IP address and port registration path of the current application instance, and calculating the modulo result of the number of application instances and the node identifier as the application identifier of the current application instance. A message queue corresponding to the current application instance is created based on the application identifier, and the message queue is bound to the fan switch of the message middleware to listen for messages; When a new data change message is received in the message queue, the new data change message is consumed to update the local cache. The database server is adapted to modify the data in the database accordingly when the data changes, update the data in the caching middleware, and generate a data change message based on the latest cached data in the caching middleware and send it to the sector switch. The message middleware is adapted to deliver data change messages received by the sector switch to each message queue bound to the sector switch via the sector switch.

4. A computing device, comprising: At least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions including instructions for performing the method as described in any one of claims 1-2.

5. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method as described in any one of claims 1-2.

Citation Information

Patent Citations

  • Cluster multi-node caching method and device

    CN115242811A