A data caching processing method, apparatus, device and medium

By updating and merging configuration data in the cache, the problem of frequent gateway program restarts was solved, ensuring stable operation of the gateway device and accuracy of configuration data.

CN123145158APending Publication Date: 2026-11-20GUANGZHOU HEDONG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611311147.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-27
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In industrial IoT and edge computing scenarios, frequent gateway program restarts can cause system interruptions, affecting business continuity and stability.

Method used

By updating the target configuration data in the cache and adding a change identifier, the difference is merged, written once, and then reloaded, avoiding repeated restarts of the gateway device caused by frequent configuration.

Benefits of technology

Reduce the frequency of gateway device restarts, improve configuration management efficiency and gateway service availability, and ensure the accuracy and consistency of configuration data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123145158A_ABST
    Figure CN123145158A_ABST
Patent Text Reader

Abstract

The application discloses a data cache processing method and device, equipment and medium, comprising: obtaining target configuration data of a target gateway program and caching to a cache area; in response to a configuration operation instruction of the target configuration data, configuring the target configuration data in the cache area, and adding a change identifier to the configured target configuration data; in response to a target configuration data saving instruction, obtaining current running configuration data from the target gateway program, and performing difference merging processing on the target configuration data marked with the change identifier in the cache area and the current running configuration data to obtain an updated configuration data set; writing the updated configuration data set to a storage path corresponding to the target gateway program, and sending a restart instruction to a gateway device running the target gateway program, so that the gateway device loads the updated configuration data set after restarting. The method ensures the configuration update accuracy and improves the gateway configuration management efficiency through cache area configuration change and runtime data difference merging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a data caching processing method, apparatus, device and medium. Background Technology

[0002] In industrial IoT and edge computing scenarios, gateway programs, as key nodes connecting field devices and upper-level systems, typically require configuration software to distribute and update their operating parameters.

[0003] In existing technical solutions, the configuration software sends each set of configuration data directly to the gateway program. Upon receiving the configuration data, the gateway program performs a storage operation and automatically restarts to load the latest configuration after storage is complete. When the configuration software needs to configure multiple parameters for the gateway program, each time configuration data is sent, it triggers a gateway storage and automatic restart, leading to frequent gateway program restarts, system interruptions, and severely impacting business continuity and stability. Summary of the Invention

[0004] This application provides a data caching processing method, apparatus, device, and medium. By updating the target configuration data in the cache area and adding a change identifier, and then writing the difference between the current running configuration data and the target configuration data marked with the change identifier at once and restarting the loading process, the method avoids repeated restarts of the gateway device and system interruptions caused by frequent configuration.

[0005] In a first aspect, embodiments of this application provide a data caching processing method, the method comprising: Send a configuration data read request to the target gateway program, receive the target configuration data returned by the target gateway program, store the target configuration data in the cache according to a preset data structure format, and establish a correspondence between the target configuration data and the identity identifier of the target gateway program; In response to a configuration operation instruction for the target configuration data, the target configuration data is configured in the cache area, and a change identifier is added to the configured target configuration data; In response to the save command for target configuration data, the current running configuration data is obtained from the target gateway program, and the target configuration data marked with the change identifier in the cache is merged with the current running configuration data to obtain an updated configuration data set; According to the correspondence, the updated configuration data set is written to the storage path corresponding to the target gateway program, and a restart command is sent to the gateway device running the target gateway program so that the gateway device loads the updated configuration data set after restarting.

[0006] Further, the step of performing difference merging processing on the target configuration data marked with the change identifier in the cache and the current running configuration data includes: The current running configuration data is parsed to obtain multiple current running data items and their corresponding data indexes; Extract the target configuration data marked with the change identifier from the cache area to obtain a set of changed configuration data; Based on the data index, the data items in the multiple currently running data items that have the same data index as the changed configuration data set are replaced with the corresponding target configuration data in the changed configuration data set to obtain the updated configuration data set.

[0007] Furthermore, the change identifier includes a data change type identifier, which is used to characterize the data change type of the target configuration data; Adding a change identifier to the configured target configuration data includes: Based on the operation type of the configuration operation instruction, determine the data change type identifier corresponding to the target configuration data; The data change type identifier is merged and stored with the target configuration data.

[0008] Further, obtaining the current running configuration data from the target gateway program includes: If the target configuration data contains configuration data items corresponding to multiple target gateway programs, then the multiple target gateway programs are traversed, and configuration data read requests are sent to each target gateway program in turn. Receive the current running configuration data returned by each target gateway program, and obtain the current running configuration data corresponding to each target gateway program.

[0009] Furthermore, the cache area includes several storage partitions divided according to the target gateway program, and each storage partition contains target configuration data corresponding to each target gateway program; Configuring the target configuration data in the cache includes: The target storage partition is determined based on the target gateway program to which the target configuration data belongs; Perform configuration operations on the target configuration data within the target storage partition.

[0010] Further, the step of writing the updated configuration data set into the storage path corresponding to the target gateway program according to the correspondence includes: Based on the correspondence, determine the storage path corresponding to the identity identifier of the target gateway program; If a full write method is used, the entire updated configuration data set will be written to the target configuration file under the storage path; If incremental writing is used, the changed configuration data items in the updated configuration data set will be written to the target configuration file under the storage path.

[0011] Furthermore, after loading the updated configuration data set after the gateway device restarts, the method further includes: Clear the change identifier corresponding to the updated target configuration data in the cache area.

[0012] In a second aspect, embodiments of this application provide a data caching processing apparatus, comprising: The data caching module is used to send a configuration data read request to the target gateway program, receive the target configuration data returned by the target gateway program, store the target configuration data in the cache area according to a preset data structure format, and establish a correspondence between the target configuration data and the identity identifier of the target gateway program. A status flag module is used to configure the target configuration data in the cache area in response to a configuration operation instruction for the target configuration data, and to add a change flag to the configured target configuration data. The merging processing module is used to respond to the save instruction of the target configuration data, obtain the current running configuration data from the target gateway program, and perform difference merging processing on the target configuration data marked with the change identifier in the cache and the current running configuration data to obtain an updated configuration data set; The data writing module is used to write the updated configuration data set into the storage path corresponding to the target gateway program according to the correspondence, and send a restart command to the gateway device running the target gateway program so that the gateway device loads the updated configuration data set after restarting.

[0013] In a third aspect, embodiments of this application provide an electronic device, including: a memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data caching processing method as described in the first aspect.

[0014] In a fourth aspect, embodiments of this application provide a storage medium for storing computer-executable instructions, which, when executed by a computer processor, are used to perform the data caching processing method as described in the first aspect.

[0015] This embodiment of the application sets up a cache as an intermediate storage layer for target configuration data. The target configuration data of the target gateway program is first obtained and cached in the cache, so that configuration operations are performed only in the cache without being immediately sent to the target gateway program, thus avoiding the problem of triggering a gateway device restart with each configuration operation. Furthermore, a change identifier is added to the configured target configuration data in the cache, accurately marking the changed configuration data items. When a target configuration data save command is triggered, the currently running configuration data is obtained from the target gateway program, and the target configuration data marked with change identifiers in the cache is merged with the currently running configuration data to perform a difference merging process, saving only the actually changed target configuration data. Instead of overwriting all target configuration data in the cache with the target gateway program, the data is merged into the currently running configuration data to obtain the updated configuration data set. This ensures that the configuration operation will not accidentally overwrite or lose the valid configuration data currently running in the target gateway program, thus guaranteeing the accuracy and consistency of the configuration data. Finally, the updated configuration data set is written to the storage path corresponding to the target gateway program, and a restart command is sent to the gateway device running the target gateway program. This ensures that the gateway device only restarts once and loads the updated configuration data set after all configuration data has been uniformly updated. This combines the original multiple scattered restarts into a single centralized restart, reducing the restart frequency of the gateway device and improving configuration management efficiency and the availability of gateway services. Attached Figure Description

[0016] Figure 1 This is a flowchart of a data caching processing method provided in an embodiment of this application; Figure 2 This is a flowchart of the difference merging process provided in the embodiments of this application; Figure 3 This is a flowchart illustrating the addition of change identifiers provided in the embodiments of this application; Figure 4 This is a flowchart illustrating the acquisition of current running configuration data provided in an embodiment of this application; Figure 5 This is a flowchart of the configuration target configuration data provided in the embodiments of this application; Figure 6 This is a flowchart illustrating the writing of the updated configuration data set provided in this application embodiment; Figure 7 This is a structural block diagram of a data caching processing device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but additional steps not included in the drawings may also be present. The above processes can correspond to methods, functions, procedures, subroutines, subroutines, etc.

[0018] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0019] The server program, or service-side program, serves as the control program for caching configuration data and starts automatically along with the gateway program after the device boots up. The server program can run on a computer device and is the execution entity of this method. This computer device refers to any electronic device capable of data computation, processing, and storage, specifically such as an industrial IoT gateway device, edge computing node server, cloud configuration management server, PC, industrial control computer, etc. This application embodiment does not limit this to any particular type.

[0020] Figure 1 This is a flowchart of a data caching processing method provided in an embodiment of this application, such as... Figure 1 As shown, the data caching method includes the following steps: Step S101: Send a configuration data read request to the target gateway program, receive the target configuration data returned by the target gateway program, store the target configuration data in the cache according to the preset data structure format, and establish the correspondence between the target configuration data and the identity identifier of the target gateway program.

[0021] In one embodiment, after the Server program starts, it sends a configuration data read request to the target gateway program. Upon receiving the configuration data read request from the Server program, the target gateway program reads the configuration data it is currently using and returns this configuration data as the target configuration data to the Server program. For example, after receiving the read request, the target gateway program reads all configuration items from the configuration file in its current working directory. These configuration items may include communication parameters, protocol parameters, data acquisition parameters, and device parameters. The target gateway program encapsulates all the above configuration items according to a preset response data format, generates the target configuration data, and returns it to the Server program. The Server program receives the target configuration data returned by the target gateway program and stores the target configuration data in a cache according to a preset data structure format.

[0022] Simultaneously, the Server program establishes a mapping between target configuration data and the identity identifiers of target gateway programs. The identity identifier is used to identify the gateway program and may include the gateway program's program name, program ID, process identifier, or network communication address. For example, when storing target configuration data in the cache, the Server program uses the target gateway program's program name as the index key to associate the storage address of the target configuration data in the cache with the program name in a mapping table. This mapping table can be a hash table data structure, where the key is the gateway program's program name, and the value is a pointer or reference to the corresponding configuration data storage location in the cache. By establishing this mapping, the Server program can quickly locate the configuration data corresponding to any gateway program.

[0023] It should be noted that the cache area is a memory cache region within the Server program. This cache area is used to temporarily store copies of the configuration data of each gateway program for configuration software to perform read and write operations. For example, the Server program may pre-allocate a contiguous storage space in memory as a cache area. The size of this cache area can be dynamically adjusted according to the number of gateway programs and the amount of configuration data for each gateway program. The Server program formats and stores the received target configuration data according to a preset data structure format, which can be a key-value pair format, a JSON object format, or a structured data table format. The Server program parses each configuration item in the target configuration data into a key-value pair, where the key is the name of the configuration item (e.g., the host computer IP address), and the value is the specific value of the configuration item (e.g., 192.168.1.100). All key-value pairs together constitute the configuration data set of the target gateway program.

[0024] Step S102: In response to the configuration operation instruction for the target configuration data, configure the target configuration data in the cache area and add a change identifier to the configured target configuration data.

[0025] In one embodiment, the configuration software, i.e., the host computer software used to edit and modify the configuration data of the gateway program, sends a configuration operation instruction to the server program when it needs to modify the configuration data of the gateway program. The server program receives the configuration operation instruction sent by the configuration software, parses the instruction to determine the identity of the target gateway program and the configuration data content to be configured. Based on the identity of the target gateway program, the server program searches for and reads the target configuration data corresponding to that identity from the cache.

[0026] The server program performs configuration operations on the target configuration data in the cache, that is, updates the corresponding configuration items of the target configuration data in the cache according to the modifications in the configuration operation instructions. After completing the configuration operation on the target configuration data, the server program adds a change identifier to the configured target configuration data. The change identifier is used to mark which configuration data items in the cache have changed, so that the changed configuration data can be quickly identified and retrieved during the save operation. For example, the server program adds a boolean change flag field (e.g., isChanged: true) to the changed configuration data items, or adds the changed configuration data items to a change list.

[0027] It should be noted that since the Server program has preloaded the configuration data of each gateway program into the cache, the Server program can directly perform configuration operations on the target configuration data in the cache without immediately sending the configuration data to the target gateway program.

[0028] Step S103: In response to the save command for target configuration data, obtain the current running configuration data from the target gateway program, and perform difference merging processing on the target configuration data marked with change identifier in the cache and the current running configuration data to obtain the updated configuration data set.

[0029] In one embodiment, after the configuration software completes all configuration operations on the target configuration data, it sends a save command to the server program. Upon receiving the save command, the server program retrieves the currently running configuration data from the target gateway program. It should be noted that the purpose of retrieving the currently running configuration data from the target gateway program is to obtain the latest version of the configuration data actually used by the target gateway program during its current operation. Since the configuration data cached by the server program may be inconsistent with the configuration data actually used by the gateway program during caching, the server program needs to retrieve the latest currently running configuration data from the target gateway program before performing the save operation. This ensures that the difference merging process is based on the latest data version and avoids configuration overwrite errors due to inconsistent data versions. Specifically, the server program sends a configuration data read request to the target gateway program. Upon receiving this request, the target gateway program reads the configuration data it is currently using and returns this configuration data as the current running configuration data to the server program. After obtaining the current running configuration data of the target gateway program, the server program performs difference merging processing on the target configuration data marked with a change identifier in the cache and the current running configuration data to obtain an updated configuration data set. Difference merging refers to merging only the target configuration data that has actually changed in the cache into the currently running configuration data, while retaining the original values ​​of configuration data items that have not changed, thus obtaining an updated configuration data set containing all the latest changes. For example, suppose the currently running configuration data contains configuration item A (value 10), configuration item B (value 20), and configuration item C (value 30), and the target configuration data marked with a change identifier in the cache contains configuration item A (modified value 15) and configuration item D (newly added value 40), while configuration items B and C have not changed. Then, the updated configuration data set obtained after difference merging will contain configuration item A (value 15), configuration item B (value 20), configuration item C (value 30), and configuration item D (value 40). Through the above difference merging process, it can be ensured that configuration operations will not accidentally overwrite or lose the currently running valid configuration data of the target gateway program, guaranteeing the accuracy and consistency of the configuration data.

[0030] Step S104: Write the updated configuration data set into the storage path corresponding to the target gateway program according to the correspondence, and send a restart command to the gateway device running the target gateway program so that the gateway device loads the updated configuration data set after restarting.

[0031] In one embodiment, after obtaining the updated configuration data set through difference merging, the Server program determines the storage path corresponding to the identity of the target gateway program based on the established mapping relationship. The storage path refers to the directory path where the target gateway program stores its configuration file in the gateway device's file system. The Server program searches for and determines the storage path corresponding to the target gateway program to be saved based on the mapping relationship between the target gateway program's identity and the storage path recorded in the mapping table. The Server program writes the updated configuration data set to the storage path corresponding to the target gateway program. For example, the Server program serializes the updated configuration data set according to the configuration file format required by the target gateway program, such as XML, JSON, or YAML, generates a configuration file, and writes this configuration file to the storage path corresponding to the target gateway program, overwriting the original configuration file. After completing the writing of the updated configuration data set, the Server program sends a restart command to the gateway device running the target gateway program. The restart command instructs the gateway device to restart the target gateway program. Upon receiving the restart command, the gateway device executes the restart operation of the target gateway program. During the restart process, the target gateway program reloads the configuration file from its corresponding storage path and reads the updated configuration data set as the new runtime configuration data, so that all configuration changes made by the configuration software take effect at once after the gateway program restarts.

[0032] Figure 2 This is a flowchart of the difference merging process provided in the embodiments of this application, such as... Figure 2 As shown, the difference merging process specifically includes: Step S201: Perform structural parsing on the current running configuration data to obtain multiple current running data items and their corresponding data indexes.

[0033] In one embodiment, after obtaining the current runtime configuration data from the target gateway program, the server program performs structure parsing on the current runtime configuration data. The current runtime configuration data is typically organized and stored in a specific format, such as XML, JSON, or structured text, and contains multiple configuration data items, each corresponding to a specific configuration parameter. The server program parses the current runtime configuration data using the corresponding parsing method based on the format type. For example, if the current runtime configuration data is in JSON format, the server program calls a JSON parser to parse the data, resolving each key-value pair in the JSON object into a current runtime data item. Each current runtime data item obtained after parsing includes a configuration item name and a configuration item value.

[0034] Simultaneously, the Server program determines a corresponding data index for each currently running data item obtained through parsing. The data index identifies a configuration data item, enabling the matching of changed configuration data in the cache with the corresponding data item in the currently running configuration data during the difference merging process. For example, the data index can be the name of the configuration item, such as the collection period or the host computer's IP address, or it can be the path of the configuration item in the configuration file, such as network.server.ip, or a unique identifier for the configuration item. By establishing the data index, the Server program can establish a mapping relationship between the two data sets, ensuring accurate matching and replacement of configuration data items.

[0035] Step S202: Extract the target configuration data marked with the change identifier from the cache area to obtain the changed configuration data set.

[0036] In one embodiment, the server program iterates through the target configuration data stored in the cache, checking whether each target configuration data item is marked with a change identifier. The change identifier is added by the server program to mark configuration data items that have changed during the configuration operation. The server program extracts all target configuration data items marked with change identifiers and combines these configuration data items into a changed configuration data set. For example, the server program maintains a change list that records the storage addresses or references of all target configuration data items marked with change identifiers. The server program iterates through this change list, sequentially reading each changed configuration data item, its corresponding data index, and the changed value, thereby obtaining the changed configuration data set.

[0037] Step S203: Based on the data index, replace the data items in the multiple currently running data items that have the same data index as the changed configuration data set with the corresponding target configuration data in the changed configuration data set to obtain the updated configuration data set.

[0038] In one embodiment, the Server program uses data indexes as the matching basis to match each changed configuration data item in the changed configuration data set with the currently running data items in the currently running configuration data. Specifically, for each changed configuration data item in the changed configuration data set, the Server program obtains the data index of the changed configuration data item, and then searches for a currently running data item with the same data index among multiple currently running data items. If a currently running data item with the same data index is found, the Server program replaces the value of the currently running data item with the value of the changed configuration data item. If no currently running data item with the same data index is found, the Server program adds the changed configuration data item as a new data item to the currently running configuration data.

[0039] After the server program completes the matching and replacement operations on all changed configuration data items in the changed configuration data set, it obtains the updated configuration data set. This updated configuration data set contains all data items in the currently running configuration data that have not changed, as well as data items that have actually changed after configuration operations. It includes modified data items and newly added data items, thus forming a configuration data set containing all the latest changes. For example, suppose the currently running configuration data contains a current running data item with a data index of the collection period (value 5s) and a current running data item with a data index of the reporting address (value http: / / server:8080 / report). The changed configuration data set contains a changed configuration data item with a data index of the collection period (value 2s) and a changed configuration data item with a data index of the device number (value Device_001, which is a newly added item). The server program matches the data index, replaces the value of the collection period item from 5s to 2s, and adds the device number as a new item to the configuration data. The resulting updated configuration data set includes the collection period item (value 2s), the reporting address item (value http: / / server:8080 / report), and the device number item (value Device_001).

[0040] Figure 3 This is a flowchart of the change identifier addition provided in the embodiments of this application, such as... Figure 3 As shown, adding a change flag to the configured target configuration data specifically includes: Step S301: Determine the data change type identifier corresponding to the target configuration data based on the operation type of the configuration operation instruction.

[0041] In one embodiment, the configuration operation instruction includes operation type information, which indicates the type of operation performed by the configuration software on the target configuration data. For example, the operation type may include, but is not limited to, an Add operation for adding a new configuration data item to the target configuration data; a Modify operation for modifying an existing configuration data item in the target configuration data; and a Delete operation for removing an existing configuration data item from the target configuration data.

[0042] After receiving a configuration operation command, the server program parses the command to obtain the operation type information. Based on the parsed operation type, the server program determines the data change type identifier corresponding to the target configuration data. The data change type identifier is a marker used to characterize the type of configuration data change; different operation types correspond to different data change type identifiers. For example, the server program internally has a pre-configured mapping relationship between operation types and data change type identifiers. If the operation type of the configuration operation command is "modify," the server program determines the corresponding data change type identifier as "Modify"; if the operation type is "add," it determines the corresponding data change type identifier as "Add"; and if the operation type is "delete," it determines the corresponding data change type identifier as "Delete." By setting the data change type identifier, subsequent steps can distinguish different types of changes based on this identifier, facilitating difference merging and change record management.

[0043] Step S302: Merge and store the data change type identifier with the target configuration data.

[0044] In one embodiment, after determining the data change type identifier corresponding to the target configuration data, the server program merges and stores the data change type identifier with the target configuration data. Specifically, the server program stores the data change type identifier as an additional attribute of the target configuration data in the cache. For example, the server program sets a metadata field for each configuration data item in the cache, which stores additional information related to the configuration data item. The server program writes the data change type identifier into this metadata field. Taking a modification operation as an example, the server program finds the target configuration data item to be modified in the cache, updates the value of the configuration data item to the modified value, writes the change type "Modify" into the metadata field of the configuration data item, and writes "this item has been changed (isChanged: true)" into the change flag field to fully record the change information of the configuration data item.

[0045] In an optional embodiment, the change identifier comprises two parts: a change flag field and a data change type identifier. The change flag field indicates whether the configuration data item has changed; for example, it is a boolean field where true indicates a change and false indicates no change. The data change type identifier further indicates the specific type of change. Using both together provides more accurate change information for difference merging processing.

[0046] Figure 4 This is a flowchart of the current running configuration data acquisition provided in an embodiment of this application, such as... Figure 4 As shown, obtaining the current running configuration data specifically includes: Step S401: If the target configuration data contains configuration data items corresponding to multiple target gateway programs, then traverse the multiple target gateway programs and send configuration data read requests to each target gateway program in turn.

[0047] In one embodiment, the configuration software may modify the configuration data of multiple gateway programs during a single configuration operation. For example, the configuration software's interface simultaneously displays the configuration parameters of gateway A and gateway B. The user modifies the data acquisition cycle in the configuration interface of gateway A and the data reporting address in the configuration interface of gateway B. In this case, the target configuration data contains configuration data items corresponding to multiple target gateway programs. After receiving a save command, the server program first checks the number of target gateway programs involved in the target configuration data. If the target configuration data contains configuration data items corresponding to multiple target gateway programs, the server program iterates through these multiple target gateway programs and sends a configuration data read request to each target gateway program in sequence. For example, the server program, following the list order of the gateway programs, first sends a configuration data read request to gateway A, waits for gateway A to return the currently running configuration data, and then sends a configuration data read request to gateway B.

[0048] It should be noted that sending requests to each target gateway program sequentially can effectively avoid network congestion and gateway program response timeouts that may result from sending requests to multiple gateway programs simultaneously, ensuring that the server program can reliably obtain the current running configuration data of each target gateway program.

[0049] Step S402: Receive the current running configuration data returned by each target gateway program to obtain the current running configuration data corresponding to each target gateway program.

[0050] In one embodiment, after receiving a configuration data read request from the Server program, each target gateway program reads its own current running configuration data and returns it to the Server program. The Server program receives the current running configuration data returned by each target gateway program and stores the data returned by each target gateway program in relation to its identity identifier, thus obtaining current running configuration data corresponding to each target gateway program. For example, the Server program pre-creates a mapping table in memory, where the key is the identity identifier of the gateway program and the value is the received current running configuration data. When the Server program receives current running configuration data returned by gateway A, it stores it in the mapping table with Gateway_A as the key and the received data as the value; when it receives current running configuration data returned by gateway B, it stores it in the mapping table with Gateway_B as the key and the received data as the value. In this way, the Server program prepares corresponding current running configuration data for each target gateway program for difference merging processing.

[0051] Figure 5 This is a flowchart of the configuration target configuration data provided in the embodiments of this application, such as... Figure 5 As shown, configuring the target configuration data in the cache specifically includes: Step S501: Determine the target storage partition based on the target gateway program to which the target configuration data belongs.

[0052] In one embodiment, the cache is pre-divided into multiple storage partitions, each corresponding to a gateway program for storing its target configuration data. For example, when initializing the cache, the server program allocates an independent memory region as its storage partition for each gateway program based on the number of gateway programs in the current device and the amount of configuration data for each program. Each storage partition is identified by a partition identifier, which has a one-to-one correspondence with the gateway program's identity identifier.

[0053] Upon receiving a configuration operation instruction, the server program parses the instruction to determine the target gateway program to which the target configuration data belongs. Based on the identity of the target gateway program, the server program searches for the corresponding storage partition in the cache. For example, if the configuration operation instruction indicates configuring data for gateway A, the server program searches for the corresponding storage partition based on the program name of gateway A, Gateway_A, and identifies that storage partition as the target storage partition.

[0054] Step S502: Perform configuration operations on the target configuration data within the target storage partition.

[0055] In one embodiment, after determining the target storage partition, the server program performs configuration operations on the target configuration data within that partition. Specifically, the server program locates the target configuration data item to be configured in the target storage partition and updates it according to the modifications in the configuration operation instruction. For example, if the configuration operation instruction indicates that the data collection period of gateway A be changed from 5 seconds to 2 seconds, the server program searches for the configuration data item corresponding to the collection period in the target storage partition (i.e., the storage partition corresponding to gateway A) and updates its value from 5s to 2s. After completing the configuration operation, the server program adds a change identifier to the configuration data item, marking that the data item has been changed.

[0056] As described above, by dividing the cache into independent storage partitions according to the gateway program, the configuration data of different gateway programs are stored in mutually isolated storage areas, avoiding data interference between different gateway programs. At the same time, it also makes it easier for the server program to quickly locate and operate the configuration data of a specific gateway program, thereby improving the access efficiency and data security of the cache.

[0057] Figure 6 This is a flowchart illustrating the writing of the updated configuration data set provided in this application embodiment, such as... Figure 6 As shown, writing the updated configuration data set to the storage path corresponding to the target gateway program according to the corresponding relationship specifically includes: Step S601: Determine the storage path corresponding to the identity identifier of the target gateway program based on the correspondence.

[0058] In one embodiment, the server program establishes a mapping between target configuration data and target gateway program identifiers. This mapping includes not only the storage location information of the target configuration data in the cache, but also the storage path information of the target gateway program's configuration file in the gateway device's file system. After receiving the updated configuration data set, the server program searches for and determines the storage path corresponding to the identifier of the target gateway program in the mapping table. For example, the mapping table records that the storage path corresponding to Gateway_A is / etc / gateway_A / config.xml, and the storage path corresponding to Gateway_B is / etc / gateway_B / config.json. If the target gateway program being processed is Gateway A, the server program determines the storage path to be / etc / gateway_A / config.xml.

[0059] Step S602: If the full write method is used, the entire updated configuration data set will be written to the target configuration file under the storage path.

[0060] In this embodiment, the write method includes two optional modes: full write and incremental write. The server program determines which write mode to use based on a preset write strategy.

[0061] In an optional embodiment, if a full write method is used, the Server program will serialize the entire updated configuration data set to generate a complete configuration file, and then write this complete configuration file to the target configuration file located at the storage path corresponding to the target gateway program. For example, the Server program will serialize the updated configuration data set into an XML format configuration file, then open the target configuration file at the storage path in overwrite mode, write the serialized complete configuration data to that file, and replace all the original content of that file.

[0062] As mentioned above, the advantage of the full write method is that it is simple to implement and can ensure that the target configuration file and the updated configuration data set are completely consistent, and will not cause configuration inconsistency problems due to the residue of historical data.

[0063] Step S603: If incremental write method is used, the changed configuration data items in the updated configuration data set are written to the target configuration file under the storage path.

[0064] In an optional embodiment, if incremental writing is used, the server program only writes the changed configuration data items in the updated configuration data set—that is, the data items that have changed relative to the currently running configuration data—to the target configuration file, while keeping the unchanged configuration data items in the target configuration file unchanged. For example, the server program has already determined the changed configuration data items and their change types during the difference merging process. Based on this change information, the server program generates incremental update data and writes this incremental update data to the target configuration file. For modification operations, the server program updates the value of the corresponding configuration data item in the target configuration file; for addition operations, the server program adds the new configuration data item to the target configuration file; for deletion operations, the server program removes the corresponding configuration data item from the target configuration file.

[0065] As mentioned above, the advantages of incremental write are small data volume and fast write speed, making it suitable for scenarios with large configuration data volume and few changes. Optionally, when using incremental write, the server program can ensure the atomicity and data consistency of incremental write operations by recording change logs in the target configuration file or using the transaction write mechanism of the configuration file.

[0066] Figure 7This is a structural block diagram of a data caching processing apparatus provided in an embodiment of this application. The apparatus is configured to execute the data caching processing method provided in the above embodiments, and possesses corresponding functional modules and beneficial effects for executing the method, such as... Figure 7 As shown, the device specifically includes: The data caching module 801 is used to send a configuration data read request to the target gateway program, receive the target configuration data returned by the target gateway program, store the target configuration data in the cache area according to the preset data structure format, and establish the correspondence between the target configuration data and the identity identifier of the target gateway program. The status flag module 802 is used to configure the target configuration data in the cache in response to the configuration operation command for the target configuration data, and add a change flag to the configured target configuration data. The merging processing module 803 is used to respond to the target configuration data saving instruction, obtain the current running configuration data from the target gateway program, and perform difference merging processing on the target configuration data marked with the change identifier in the cache and the current running configuration data to obtain the updated configuration data set; The data writing module 804 is used to write the updated configuration data set to the storage path corresponding to the target gateway program according to the correspondence, and send a restart command to the gateway device running the target gateway program so that the gateway device loads the updated configuration data set after restarting.

[0067] As described above, by centrally managing gateway configuration data through a cache layer, all configuration operations are completed within the cache layer, avoiding gateway restarts for every modification. Change identifiers are used to track modified configuration items, ensuring that changes are identifiable and traceable. Based on this, in response to save commands, the system retrieves currently running configuration data from the target gateway program in real time and performs difference merging based on data indexes. Only the actually changed configuration items are merged into the current running configuration, rather than blindly overwriting all data in the cache, thus avoiding accidental overwriting or loss of valid configuration data. Finally, the updated configuration data set is uniformly written to the storage path, and a restart command is sent to the gateway device. This ensures that the gateway device restarts only once after all configuration data has been updated, merging multiple scattered restarts into a single restart. This reduces the frequency of gateway device restarts while ensuring the accuracy and consistency of configuration data, improving configuration management efficiency and gateway service availability.

[0068] In one possible embodiment, the cache area includes several storage partitions divided according to the target gateway program, each storage partition containing target configuration data corresponding to each target gateway program; the data caching module 801 is further configured to: Determine the target storage partition based on the target gateway program to which the target configuration data belongs; Perform configuration operations on the target configuration data within the target storage partition.

[0069] In one possible embodiment, the status marking module 802 is further configured to: Based on the operation type of the configuration operation command, determine the data change type identifier corresponding to the target configuration data; The data change type identifier is stored together with the target configuration data.

[0070] In one possible embodiment, the merging processing module 803 is further configured to: The current running configuration data is parsed to obtain multiple current running data items and their corresponding data indexes; Extract the target configuration data marked with change identifiers from the cache to obtain the changed configuration data set; Based on the data index, the data items in multiple currently running data items that have the same data index as the changed configuration data set are replaced with the corresponding target configuration data in the changed configuration data set, thus obtaining the updated configuration data set.

[0071] In one possible embodiment, the merging processing module 803 is further configured to: If the target configuration data contains configuration data items corresponding to multiple target gateway programs, then traverse the multiple target gateway programs and send configuration data read requests to each target gateway program in turn; Receive the current running configuration data returned by each target gateway program, and obtain the current running configuration data corresponding to each target gateway program.

[0072] In one possible embodiment, the data writing module 804 is further configured to: Based on the correspondence, determine the storage path corresponding to the identity identifier of the target gateway program; If a full write method is used, the entire updated configuration data set will be written to the target configuration file under the storage path; If incremental write is used, the changed configuration data items in the updated configuration data set will be written to the target configuration file under the storage path.

[0073] In one possible embodiment, the device further includes a cleanup management module, which is specifically used for: After the gateway device restarts and loads the updated configuration data set, the change flags corresponding to the updated target configuration data in the cache are cleared.

[0074] It is worth noting that in the above-described embodiments of the data caching processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not configured to limit the protection scope of the embodiments of this application.

[0075] Figure 8 This is a schematic diagram of the structure of a data caching processing device provided in an embodiment of this application, as shown below. Figure 8 As shown, the device includes a processor 901, a memory 902, an input device 903, and an output device 904.

[0076] The number of processors 901 can be one or more. Figure 8 Taking a processor 901 as an example; the processor 901, memory 902, input device 903, and output device 904 can be connected via a bus or other means. Figure 8 Taking a bus connection as an example, the memory 902, as a computer-readable storage medium, can be configured to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the data caching processing method in this embodiment. The processor 901 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 902, thereby implementing the aforementioned data caching processing method. The input device 903 can be configured to receive input digital or character information and generate key signal inputs related to user settings and function control of the device. The output device 904 may include a display screen or other display device for displaying the configuration interface and configuration data information.

[0077] This application also provides a non-volatile storage medium containing computer-executable instructions. When executed by a computer processor, the computer-executable instructions are configured to perform a data caching method described in the above embodiments. The method includes: sending a configuration data read request to a target gateway program and receiving target configuration data returned by the target gateway program; storing the target configuration data in a cache according to a preset data structure format and establishing a correspondence between the target configuration data and the identity identifier of the target gateway program; configuring the target configuration data in the cache in response to a configuration operation instruction for the target configuration data and adding a change identifier to the configured target configuration data; obtaining currently running configuration data from the target gateway program in response to a save instruction for the target configuration data, and performing difference merging processing on the target configuration data marked with the change identifier in the cache and the currently running configuration data to obtain an updated configuration data set; writing the updated configuration data set to the storage path corresponding to the target gateway program according to the correspondence, and sending a restart instruction to the gateway device running the target gateway program so that the gateway device loads the updated configuration data set after restarting.

[0078] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments provided herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the claims.

Claims

1. A data caching processing method, characterized in that, The method includes: Send a configuration data read request to the target gateway program, receive the target configuration data returned by the target gateway program, store the target configuration data in the cache according to a preset data structure format, and establish a correspondence between the target configuration data and the identity identifier of the target gateway program; In response to a configuration operation instruction for the target configuration data, the target configuration data is configured in the cache area, and a change identifier is added to the configured target configuration data; In response to the save command for target configuration data, the current running configuration data is obtained from the target gateway program, and the target configuration data marked with the change identifier in the cache is merged with the current running configuration data to obtain an updated configuration data set; According to the correspondence, the updated configuration data set is written to the storage path corresponding to the target gateway program, and a restart command is sent to the gateway device running the target gateway program so that the gateway device loads the updated configuration data set after restarting.

2. The data caching processing method according to claim 1, characterized in that, The step of merging the target configuration data marked with the change identifier in the cache with the current running configuration data includes: The current running configuration data is parsed to obtain multiple current running data items and their corresponding data indexes; Extract the target configuration data marked with the change identifier from the cache area to obtain a set of changed configuration data; Based on the data index, the data items in the multiple currently running data items that have the same data index as the changed configuration data set are replaced with the corresponding target configuration data in the changed configuration data set to obtain the updated configuration data set.

3. The data caching processing method according to claim 1, characterized in that, The change identifier includes a data change type identifier, which is used to characterize the data change type of the target configuration data; Adding a change identifier to the configured target configuration data includes: Based on the operation type of the configuration operation instruction, determine the data change type identifier corresponding to the target configuration data; The data change type identifier is merged and stored with the target configuration data.

4. The data caching processing method according to claim 1, characterized in that, The step of obtaining the current running configuration data from the target gateway program includes: If the target configuration data contains configuration data items corresponding to multiple target gateway programs, then the multiple target gateway programs are traversed, and configuration data read requests are sent to each target gateway program in turn. Receive the current running configuration data returned by each target gateway program, and obtain the current running configuration data corresponding to each target gateway program.

5. The data caching processing method according to claim 1, characterized in that, The cache area includes several storage partitions divided according to the target gateway program, and each storage partition contains target configuration data corresponding to each target gateway program; Configuring the target configuration data in the cache includes: The target storage partition is determined based on the target gateway program to which the target configuration data belongs; Perform configuration operations on the target configuration data within the target storage partition.

6. The data caching processing method according to claim 1, characterized in that, The step of writing the updated configuration data set into the storage path corresponding to the target gateway program according to the correspondence includes: Based on the correspondence, determine the storage path corresponding to the identity identifier of the target gateway program; If a full write method is used, the entire updated configuration data set will be written to the target configuration file under the storage path; If incremental writing is used, the changed configuration data items in the updated configuration data set will be written to the target configuration file under the storage path.

7. The data caching processing method according to claim 1, characterized in that, After the gateway device restarts and loads the updated configuration data set, the method further includes: Clear the change identifier corresponding to the updated target configuration data in the cache area.

8. A data caching processing apparatus, characterized in that, include: The data caching module is used to send a configuration data read request to the target gateway program, receive the target configuration data returned by the target gateway program, store the target configuration data in the cache area according to a preset data structure format, and establish a correspondence between the target configuration data and the identity identifier of the target gateway program. A status flag module is used to configure the target configuration data in the cache area in response to a configuration operation instruction for the target configuration data, and to add a change flag to the configured target configuration data. The merging processing module is used to respond to the save instruction of the target configuration data, obtain the current running configuration data from the target gateway program, and perform difference merging processing on the target configuration data marked with the change identifier in the cache and the current running configuration data to obtain an updated configuration data set; The data writing module is used to write the updated configuration data set into the storage path corresponding to the target gateway program according to the correspondence, and send a restart command to the gateway device running the target gateway program so that the gateway device loads the updated configuration data set after restarting.

9. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data caching processing method as described in any one of claims 1-7.

10. A storage medium for storing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the data caching processing method as described in any one of claims 1-7.