Internet of things platform and data processing method

By employing local storage resources in the IoT platform to provide a lightweight caching architecture, the problem of increased system complexity and cost caused by relying on middleware servers is solved, achieving efficient and reliable data storage and access, and meeting the requirements of high performance and low latency.

WO2026044715A1PCT designated stage Publication Date: 2026-03-05BOE TECHNOLOGY GROUP CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/116010
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2026-03-05

AI Technical Summary

Technical Problem

Existing IoT platforms rely on middleware servers in scenarios with a small number of connected devices, which increases system complexity and cost, leading to increased development, maintenance and deployment costs, and failing to meet the requirements for high performance and low latency.

Method used

It adopts local storage resources to provide a lightweight local caching architecture, utilizes local memory and file system for data access, reduces dependence on middleware servers, and provides an efficient and reliable data storage and access solution.

Benefits of technology

It achieves high-performance, low-cost data storage and access, meeting the IoT platform's requirements for high performance and low latency, while reducing system complexity and resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024116010_05032026_PF_FP_ABST
    Figure CN2024116010_05032026_PF_FP_ABST
Patent Text Reader

Abstract

The present invention provides an Internet of Things platform and a data processing method, for use in reducing the dependence on a middleware server, and providing a lightweight local caching architecture on the basis of local storage resources, thereby enhancing interaction performance and satisfying the requirement of the Internet of Things platform for high performance and low latency. The Internet of Things platform comprises a processor and a memory, wherein the memory is used for storing a program executable by the processor, and the processor is used for reading the program in the memory and executing the following steps: determining target data of the Internet of Things platform; and performing an access operation on the target data within local storage resources of the Internet of Things platform.
Need to check novelty before this filing date? Find Prior Art

Description

An Internet of Things (IoT) platform and data processing method Technical Field

[0001] This disclosure relates to the field of Internet of Things (IoT) technology, and in particular to an IoT platform and data processing method. Background Technology

[0002] With the rapid development of information technology and the continuous maturation of IoT technology, IoT platforms have been widely used across various industries. As a bridge connecting the physical and digital worlds, IoT platforms enable the monitoring, management, and control of various IoT devices, bringing significant convenience and efficiency improvements to people's lives and work. In the architectural design of IoT platforms, data storage and access are crucial aspects, directly affecting the platform's performance, reliability, and scalability.

[0003] IoT platforms rely on middleware servers to provide rich functionality and features, enabling stable and highly available data storage and access services during the delivery of IoT platforms. However, in scenarios with a small number of connected devices, relying on middleware servers increases the complexity of the system and the costs of development, maintenance, and deployment.

[0004] Summary of the Invention

[0005] This disclosure provides an Internet of Things (IoT) platform and data processing method to reduce reliance on middleware servers, provide a lightweight local caching architecture based on local storage resources, improve interactive performance, and meet the IoT platform's requirements for high performance and low latency.

[0006] In a first aspect, an Internet of Things (IoT) platform is provided by an embodiment of this disclosure, including a processor and a memory. The memory is used to store a program executable by the processor, and the processor is used to read the program in the memory and perform the following steps:

[0007] Identify the target data for the IoT platform;

[0008] Access operations are performed on the target data within the local storage resources of the IoT platform.

[0009] This embodiment provides an IoT platform that is designed and reconstructed based on existing modules in existing IoT platforms. It utilizes the local storage resources of the IoT platform to provide a local caching and storage solution, achieving efficient and reliable data storage and access. Furthermore, the entire IoT platform architecture does not rely on middleware servers, providing a lightweight, high-performance, and low-cost local caching solution. This not only meets the IoT platform's requirements for high performance and low latency but also provides different local storage solutions for different types of data, offering a more comprehensive and convenient data processing method.

[0010] As an optional implementation, the local storage resource includes local memory; the processor is specifically configured to execute:

[0011] In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

[0012] This embodiment utilizes local memory to provide local caching services, replacing the middleware server. Since caching technology can effectively improve data access speed and response speed, the caching method provided in this embodiment can replace the middleware server, providing high-frequency access for data that needs to be accessed frequently and has high response speed requirements in the Internet of Things platform, thereby improving data response speed.

[0013] As an optional implementation, the caching service program includes a local memory-based storage component; the processor is specifically configured to execute:

[0014] The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

[0015] As an optional implementation, the cache service program is used to perform access operations on data with different data structures; and / or,

[0016] The key-value (KV) settings of the storage component of the cache service program have expiration times.

[0017] The caching service program in this embodiment is compatible with data of different data structures. It provides more comprehensive data caching processing for different data from different devices connected to the IoT platform. It is versatile and can meet the needs of simultaneous access to data with different data structures. It provides a fast response mechanism through caching technology.

[0018] As an optional implementation, the local storage resource further includes a local file system; the processor is specifically configured to execute:

[0019] Store the target data in the cache service program to the local file system; and / or,

[0020] The target data is read from the local file system and stored in the cache service program.

[0021] In practice, persistent data processing is provided through the local file system. By storing the target data in the cache service program to the local file system, it is beneficial to achieve fast storage of large amounts of data. On the one hand, data can be directly stored from the cache into the local file system to achieve data persistence. On the other hand, target data can be directly read from the local file system and stored in the cache to achieve data caching operations and provide richer data processing methods.

[0022] As an optional implementation, the processor is specifically configured to execute:

[0023] Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; and / or,

[0024] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0025] As an optional implementation, the caching service program is also used to provide publish / subscribe functionality and / or distributed locking functionality;

[0026] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0027] This embodiment can also provide publish / subscribe functionality, supporting real-time data transmission and communication, which not only improves communication efficiency but also decouples service dependencies.

[0028] As an optional implementation, the processor is specifically configured to execute:

[0029] By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

[0030] As an optional implementation, the processor is specifically configured to determine the cache servicing program in the following manner:

[0031] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory;

[0032] The cache service program is determined based on the target client settings.

[0033] As an optional implementation, the processor is specifically configured to execute:

[0034] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0035] As an optional implementation, the data structure includes a hash data structure; the processor is specifically configured to execute:

[0036] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0037] As an optional implementation, the data structure includes an ordered set data structure; the processor is specifically configured to execute:

[0038] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0039] As an optional implementation, the data structure includes a linked list data structure; the processor is specifically configured to execute:

[0040] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0041] As an optional implementation, the processor is further configured to execute:

[0042] It is determined that the target data is stored in the cache service program;

[0043] The target data is read from the cache service program, and the target data is processed to obtain feedback data.

[0044] The feedback data is sent to the device connected to the Internet platform.

[0045] As an optional implementation, the IoT platform further includes a cache server; the processor is specifically configured to execute:

[0046] When the switching conditions are met, the switch between the cache service program and the cache server is executed.

[0047] As an optional implementation, the local storage resource includes a local database; the local database includes different types of databases; the processor is specifically configured to execute:

[0048] Within the local database, access operations are performed on the target data.

[0049] As an optional implementation, the processor is specifically configured to determine the local database in the following manner:

[0050] Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database.

[0051] By defining the operation method of the target database adapter, the operation method for the target database is set;

[0052] Based on the set target database, the local database is determined, wherein the local database includes the target database.

[0053] As an optional implementation, the processor is specifically configured to execute:

[0054] Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

[0055] Secondly, an embodiment of this disclosure provides a data processing method, comprising:

[0056] Identify the target data for the IoT platform;

[0057] Access operations are performed on the target data within the local storage resources of the IoT platform.

[0058] As an optional implementation, the local storage resource includes local memory; within the local storage resource of the IoT platform, performing access operations on the target data includes:

[0059] In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

[0060] As an optional implementation, the caching service program includes a local memory-based storage component; the caching service program in the local memory performs access operations on the target data, including:

[0061] The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

[0062] As an optional implementation, the cache service program is used to perform access operations on data with different data structures; and / or,

[0063] The key-value (KV) settings of the storage component of the cache service program have expiration times.

[0064] As an optional implementation, the local storage resource further includes a local file system; the method further includes:

[0065] Store the target data in the cache service program to the local file system; and / or,

[0066] The target data is read from the local file system and stored in the cache service program.

[0067] As an optional implementation, a serialization mechanism is used to serialize the target data stored by the cache service program into a byte stream, and the byte stream is stored in the local file system; and / or,

[0068] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0069] As an optional implementation, the caching service program is also used to provide publish / subscribe functionality and / or distributed locking functionality;

[0070] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0071] As an optional implementation, the publish / subscribe functionality is provided in the following manner:

[0072] By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

[0073] As an optional implementation, the cache service program is determined in the following manner:

[0074] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory;

[0075] The cache service program is determined based on the target client settings.

[0076] As an optional implementation, creating a target client that conforms to the cache client interface definition includes:

[0077] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0078] As an optional implementation, the data structure includes a hash data structure; the step of setting the target client to perform access operations on data of at least one data structure in the local memory includes:

[0079] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0080] As an optional implementation, the data structure includes an ordered set data structure; the step of setting the target client to perform access operations on data of at least one data structure in the local memory includes:

[0081] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0082] As an optional implementation, the data structure includes a linked list data structure; the step of setting the target client to perform access operations on data of at least one data structure in the local memory includes:

[0083] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0084] As an optional implementation, the method further includes:

[0085] It is determined that the target data is stored in the cache service program;

[0086] The target data is read from the cache service program, and the target data is processed to obtain feedback data.

[0087] The feedback data is sent to the device connected to the Internet platform.

[0088] As an optional implementation, the IoT platform further includes a cache server; the method further includes:

[0089] When the switching conditions are met, the switch between the cache service program and the cache server is executed.

[0090] As an optional implementation, the local storage resource includes a local database; the local database includes different types of databases; the method further includes:

[0091] Within the local database, access operations are performed on the target data.

[0092] As an optional implementation, the local database is determined in the following manner:

[0093] Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database.

[0094] By defining the operation method of the target database adapter, the operation method for the target database is set;

[0095] Based on the set target database, the local database is determined, wherein the local database includes the target database.

[0096] As an optional implementation, determining the local database based on the set target database includes:

[0097] Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

[0098] Thirdly, embodiments of this disclosure also provide an electronic device, including a processor and a memory, wherein the memory is used to store a program executable by the processor, and the processor is used to read the program in the memory and perform the following steps:

[0099] Identify the target data for the IoT platform;

[0100] Access operations are performed on the target data within the local storage resources of the IoT platform.

[0101] As an optional implementation, the local storage resource includes local memory; the processor is specifically configured to execute:

[0102] In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

[0103] As an optional implementation, the caching service program includes a local memory-based storage component; the processor is specifically configured to execute:

[0104] The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

[0105] As an optional implementation method,

[0106] The cache service program is used to perform access operations on data with different data structures; and / or,

[0107] The key-value (KV) settings of the storage component of the cache service program have expiration times.

[0108] As an optional implementation, the local storage resource further includes a local file system; the processor is specifically configured to execute:

[0109] Store the target data in the cache service program to the local file system; and / or,

[0110] The target data is read from the local file system and stored in the cache service program.

[0111] As an optional implementation, the processor is specifically configured to execute:

[0112] Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; and / or,

[0113] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0114] As an optional implementation, the caching service program is also used to provide publish / subscribe functionality and / or distributed locking functionality;

[0115] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0116] As an optional implementation, the processor is specifically configured to execute:

[0117] By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

[0118] As an optional implementation, the processor is specifically configured to determine the cache servicing program in the following manner:

[0119] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory;

[0120] The cache service program is determined based on the target client settings.

[0121] As an optional implementation, the processor is specifically configured to execute:

[0122] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0123] As an optional implementation, the data structure includes a hash data structure; the processor is specifically configured to execute:

[0124] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0125] As an optional implementation, the data structure includes an ordered set data structure; the processor is specifically configured to execute:

[0126] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0127] As an optional implementation, the data structure includes a linked list data structure; the processor is specifically configured to execute:

[0128] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0129] As an optional implementation, the processor is further configured to execute:

[0130] It is determined that the target data is stored in the cache service program;

[0131] The target data is read from the cache service program, and the target data is processed to obtain feedback data.

[0132] The feedback data is sent to the device connected to the Internet platform.

[0133] As an optional implementation, the IoT platform further includes a cache server; the processor is specifically configured to execute:

[0134] When the switching conditions are met, the switch between the cache service program and the cache server is executed.

[0135] As an optional implementation, the local storage resource includes a local database; the local database includes different types of databases; the processor is specifically configured to execute:

[0136] Within the local database, access operations are performed on the target data.

[0137] As an optional implementation, the processor is specifically configured to determine the local database in the following manner:

[0138] Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database.

[0139] By defining the operation method of the target database adapter, the operation method for the target database is set;

[0140] Based on the set target database, the local database is determined, wherein the local database includes the target database.

[0141] As an optional implementation, the processor is specifically configured to execute:

[0142] Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

[0143] Fourthly, embodiments of this disclosure also provide a data processing apparatus, comprising:

[0144] The data determination module is used to determine the target data for the IoT platform;

[0145] The local caching module is used to perform access operations on the target data within the local storage resources of the IoT platform.

[0146] As an optional implementation, the local storage resource includes local memory; the local cache module is specifically used for:

[0147] In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

[0148] As an optional implementation, the caching service program includes a local memory-based storage component; the local caching module is specifically used for:

[0149] The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

[0150] As an optional implementation, the cache service program is used to perform access operations on data with different data structures; and / or,

[0151] The key-value (KV) settings of the storage component of the cache service program have expiration times.

[0152] As an optional implementation, the local storage resource further includes a local file system; the local cache module is specifically used for:

[0153] Store the target data in the cache service program to the local file system; and / or,

[0154] The target data is read from the local file system and stored in the cache service program.

[0155] As an optional implementation, the local caching module is specifically used for:

[0156] Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; and / or,

[0157] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0158] As an optional implementation, the caching service program is also used to provide publish / subscribe functionality and / or distributed locking functionality;

[0159] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0160] As an optional implementation, the local caching module is specifically used to provide publish / subscribe functionality in the following manner:

[0161] By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

[0162] As an optional implementation, the local caching module is specifically used to determine the caching service program in the following manner:

[0163] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory;

[0164] The cache service program is determined based on the target client settings.

[0165] As an optional implementation, the local caching module is specifically used for:

[0166] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0167] As an optional implementation, the data structure includes a hash data structure; the local cache module is specifically used for:

[0168] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0169] As an optional implementation, the data structure includes an ordered set data structure; the local cache module is specifically used for:

[0170] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0171] As an optional implementation, the data structure includes a linked list data structure; the local cache module is specifically used for:

[0172] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0173] As an optional implementation, the local caching module is further used for:

[0174] It is determined that the target data is stored in the cache service program;

[0175] The target data is read from the cache service program, and the target data is processed to obtain feedback data.

[0176] The feedback data is sent to the device connected to the Internet platform.

[0177] As an optional implementation, the IoT platform further includes a cache server; the local cache module is specifically used for:

[0178] When the switching conditions are met, the switch between the cache service program and the cache server is executed.

[0179] As an optional implementation, the local storage resource includes a local database; the local database includes different types of databases; the local caching module is specifically used for:

[0180] Within the local database, access operations are performed on the target data.

[0181] As an optional implementation, the local caching module is specifically used to determine the local database in the following manner:

[0182] Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database.

[0183] By defining the operation method of the target database adapter, the operation method for the target database is set;

[0184] Based on the set target database, the local database is determined, wherein the local database includes the target database.

[0185] As an optional implementation, the local caching module is specifically used for:

[0186] Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

[0187] Fifthly, embodiments of this disclosure also provide a computer storage medium having a computer program stored thereon, which, when executed by a processor, is used to implement the steps of the method described in any of the second aspects above.

[0188] In a sixth aspect, this disclosure provides a computer program product comprising: computer program code, which, when run on a computer, causes the computer to perform the method described in any one of the second aspects.

[0189] These or other aspects of this disclosure will become more apparent in the following description of embodiments. Attached Figure Description

[0190] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0191] Figure 1 is a schematic diagram of a standard architecture of an existing Internet of Things platform provided in an embodiment of this disclosure;

[0192] Figure 2 is a schematic diagram of an Internet of Things (IoT) platform provided in an embodiment of this disclosure;

[0193] Figure 3 is a schematic diagram of a lightweight architecture of an Internet of Things platform provided in an embodiment of this disclosure;

[0194] Figure 4 is a schematic diagram of a process for an IoT platform to acquire device data according to an embodiment of this disclosure;

[0195] Figure 5 is a schematic diagram of an IoT platform architecture that supports local caching of Redis according to an embodiment of this disclosure;

[0196] Figure 6 is a schematic diagram of a lightweight Internet of Things platform provided in an embodiment of this disclosure;

[0197] Figure 7 is a flowchart illustrating a data processing method according to an embodiment of this disclosure.

[0198] Figure 8 is a schematic diagram of an electronic device provided in an embodiment of this disclosure;

[0199] Figure 9 is a schematic diagram of a data processing apparatus provided in an embodiment of this disclosure. Detailed Implementation

[0200] To make the objectives, technical solutions, and advantages of this disclosure clearer, the disclosure will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0201] In this disclosure, the term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0202] The application scenarios described in this disclosure are for the purpose of more clearly illustrating the technical solutions of this disclosure and do not constitute a limitation on the technical solutions provided in this disclosure. Those skilled in the art will understand that with the emergence of new application scenarios, the technical solutions provided in this disclosure are also applicable to similar technical problems. In the description of this disclosure, unless otherwise stated, "multiple" means two or more.

[0203] Before introducing the IoT platform and data processing method provided in the embodiments of this disclosure, the technical background of the embodiments of this disclosure will be described in detail below for ease of understanding.

[0204] An IoT platform is an integrated platform encompassing device management, secure data communication, and message subscription capabilities. It supports connecting massive numbers of devices and uploading device data to the cloud; it provides cloud APIs, allowing servers to send commands to devices via cloud SDKs for remote control. As the middleware layer of an IoT system, the IoT platform provides connectivity, communication, data management, and application development functions, enabling IoT devices and applications to interact and collaborate. Through the IoT platform, interconnectivity between devices can be achieved, enabling intelligent control and management. The core functions of the IoT platform include connectivity and communication, connecting various IoT devices to the cloud for data transmission and communication between devices. Furthermore, the IoT platform can collect, store, and analyze data generated by devices, providing users with valuable information and insights to support decision-making and optimization.

[0205] The characteristics of IoT platforms include massive data volumes, high real-time requirements, heterogeneity, and high data security requirements. First, with the increasing number of IoT devices and the continuous generation of data, IoT platforms need to process massive amounts of data, placing extremely high demands on data storage and access efficiency. Second, due to the diversity of IoT application scenarios, IoT platforms often need to support multiple types of devices and data formats, exhibiting a certain degree of heterogeneity. Third, IoT applications have high real-time requirements for data, requiring real-time collection, processing, and analysis of data, and timely responses. Furthermore, since IoT involves user privacy data and important business data, data security and privacy protection are also crucial considerations in IoT platform design.

[0206] In the architecture design of IoT platforms, data storage and access are crucial, directly impacting the platform's performance, reliability, and scalability. Caching is a key component for improving performance and reducing system load. By storing frequently accessed data in the cache, the number of accesses to the underlying database can be reduced, data retrieval speed can be accelerated, and latency caused by network transmission can be reduced. Therefore, IoT platforms can use Redis servers as caches to store data. However, standard IoT platforms do not directly support Redis (Remote Dictionary Server). Redis is a high-performance key-value (KV) database and an in-memory data structure store, typically used for caching, message queues, etc., and is not suitable for data storage of IoT devices. If Redis needs to be used on an IoT platform, an adaptation layer needs to be added. This adaptation layer can be a microservice or a function that communicates with the IoT platform and forwards the data that needs to be stored to the Redis server. In a practical IoT platform, an interface needs to be implemented that allows IoT devices to register, send data, and allow applications to query this data. This interface then communicates with the Redis server to store the data in a Redis data structure.

[0207] Redis is a high-performance, open-source, in-memory database characterized by fast read / write speeds and support for rich data structures and functionalities. It is widely used in caching, session management, and message queues. As a data storage engine for IoT platforms, Redis offers the following advantages: First, as an in-memory database, Redis enables rapid data read / write operations, making it suitable for handling real-time IoT data. Second, Redis supports various data structures, including strings, lists, hash tables, and sets, meeting the storage needs of different data types. Third, Redis features persistence, allowing data in memory to be periodically written to disk, ensuring data durability and reliability. Furthermore, Redis provides a wealth of functionalities and commands, such as transactions, publish / subscribe, and Lua scripting (a lightweight scripting language), facilitating data processing for IoT platforms.

[0208] Besides relying on Redis servers for caching, IoT platforms can also depend on middleware servers such as MinIO (a high-performance open-source object storage server), file servers, database servers, MQTT (Message Queuing Telemetry Transport) servers, and TDengine (a time-series database server) for storage services. While these middleware servers provide rich functionality and features, ensuring stable and highly available data storage and access during platform delivery, their reliance on a small number of devices increases system complexity, development, maintenance, and deployment costs, and incurs additional hardware resource overhead. In the process of privately-delivering IoT platforms, customers do not require all the platform's functionalities; therefore, achieving cost reduction and efficiency improvement, and enhancing delivery efficiency, has become a pressing technical challenge.

[0209] Based on this, the embodiments of this disclosure provide an Internet of Things (IoT) platform and a data processing method. The method is designed and reconstructed based on existing modules developed in existing IoT platforms, and utilizes the local storage resources of the IoT platform to provide a local caching implementation scheme, achieving efficient and reliable data storage and access. Simultaneously, the entire IoT platform architecture design does not rely on middleware servers, providing a lightweight, high-performance, and low-cost local caching solution, thereby meeting the IoT platform's requirements for high performance and low latency, and promoting the further development and application of IoT technology.

[0210] As shown in Figure 1, this embodiment provides a standard architecture for an existing IoT platform, connecting business application services, device terminals, and operation terminals. The business application services provide different services, the device terminals refer to the terminals where the IoT devices are located, and the operation terminals refer to the terminals that perform operations on the background of the IoT platform. The standard architecture IoT platform includes multiple functional modules and several dependent middleware servers, namely a Redis cache server, a MinIO file server, a relational database (Postgres or MySQL) server, an EMQX message server (Erlang / Enterprise / Elastic MQTT Broker, an open-source IoT MQTT message server developed based on the Erlang / OTP platform), and a TDengine time-series database server. It supports millions of device connections and provides functions such as device management, data acquisition and storage, real-time monitoring and alerts, data analysis and visualization, remote control and operation, security management, rule engine and automation, integration and open interfaces, etc. The functions of each module are as follows:

[0211] The device authentication module provides device authentication and authorization, as well as security management services. The protocol access module ensures compatibility with different communication protocols, enabling rapid device access through configuration. Supported communication protocols include, but are not limited to: MQTT (Message Queuing Telemetry Transport), TCP (Transmission Control Protocol), UDP (User Datagram Protocol), Modbus, BACnet (a communication protocol for smart buildings), OPC-UA (OLE (Object Linking and Embedding) for Process Control Unified Architecture), and CoAP (The Constrained Application Protocol). The device management module provides a device management interface for managing connected IoT devices. The device model module handles device object models, abstracting specific types of devices. The device monitoring module monitors device parameters such as resource usage, CPU, and memory usage. The message forwarding module provides configurable forwarding services for messages reported by devices, such as forwarding to other message servers or storing them in a database. The IoT platform is divided into several modules: OTA (Over-the-Air Technology) upgrade module for upgrading device software / applications; Device maintenance module for device operation and maintenance, such as device logging, fault analysis, and remote connection; Protocol plugin module for defining standard interfaces that support implementation using different programming languages ​​to enable device access; Data analysis module for querying and analyzing device time-series data and statistically analyzing device parameters; Device simulation module for simulating device operation and management / maintenance; User application module for managing and authorizing platform users and third-party applications; Web resource module for embedding front-end resources into the IoT platform, allowing direct loading of static resources without additional front-end deployment; and System management module for configuring the IoT platform itself, such as key management and authorization management for software authentication. The IoT platform and business application services can communicate via message queues, which can also serve as a communication medium between devices and the IoT platform.

[0212] The standard architecture IoT platform, relying on middleware servers such as Redis, MySQL, TDengine, EMQX, and MinIO, boasts rich functionality and performance advantages, capable of meeting the IoT needs of various devices in industrial parks, finance, transportation, business, and brand product sectors. For example, industrial park services include a digital platform and a park navigation system; financial services include a financial data platform and a financial information dissemination system; transportation services include a traffic control platform and a digital platform; and innovative IoT services include an ESL pricing platform and a student card platform. External customer services include IoT platform X and IoT platform Y. The middleware servers provide rich functionality and features to meet the diverse needs of the IoT platform, such as data storage, data caching, and real-time processing.

[0213] IoT platforms relying on middleware servers demonstrate excellent stability and reliability, helping to build a robust infrastructure. Optimized middleware servers offer high performance and throughput, meeting the high concurrency and low latency requirements of IoT platforms. However, using middleware servers also presents challenges such as complexity, resource consumption, and dependency risks.

[0214] Complexity: Relying on multiple middleware servers increases the complexity of IoT platform systems, requiring the management of multiple components and configurations, which may increase development, maintenance, and deployment costs.

[0215] Dependency Risks: Each middleware server on which the IoT platform relies may pose risks, such as performance issues, security vulnerabilities, and version compatibility, requiring regular monitoring and maintenance.

[0216] Resource consumption: Each middleware server consumes a certain amount of system resources from the IoT platform, including memory, CPU (Central Processing Unit), and storage. It is necessary to plan resources reasonably to avoid resource bottlenecks affecting system performance.

[0217] Currently, in the delivery of IoT platforms, it is generally recommended that customers purchase high-performance servers (8 cores, 16GB memory) to provide stable and highly available services through the deployment of a standard architecture. However, many small and medium-sized enterprises (SMEs) purchase only a few dozen devices, yet these customers still have device access needs. To facilitate user use and meet the requirements of low-cost private deployment, this embodiment provides low-cost device discovery, device connection, and device management capabilities for terminal devices (such as Xinfa digital signage, conference all-in-one machines, ESL price tags, etc.). This embodiment has undergone module trimming (removing non-essential functional modules) and middleware removal (not relying on additional middleware servers) to provide a lightweight IoT platform that consumes very few hardware resources (such as 1GB memory and 1 CPU).

[0218] The IoT platform provided in this embodiment utilizes IoT local storage resources to implement local caching services, local file storage services, and local database storage services, thereby replacing middleware servers, providing a lightweight IoT architecture, effectively reducing network latency (the time from the IoT platform to the middle server and back), and greatly reducing deployment complexity and server costs.

[0219] As shown in Figure 2, this embodiment provides an Internet of Things (IoT) platform, which includes a processor 200 and a memory 201. The memory 201 stores programs executable by the processor 200, and the processor 200 reads the programs from the memory 201 and performs the following steps:

[0220] Identify the target data for the IoT platform; perform access operations on the target data within the local storage resources of the IoT platform.

[0221] It's important to note that in IoT platforms, target data typically refers to data types that require frequent access and have high response speed requirements. This data is crucial to system performance and user experience; therefore, access caching technology can effectively address the demands of high-frequency access and accelerate data response times.

[0222] Optionally, the target data in this embodiment includes, but is not limited to, real-time data from sensors, current status data of devices, user preference settings data, real-time location data, and data from various functional modules of the IoT platform. The number of functional modules included in the IoT platform in this embodiment can be determined according to the actual needs of the user.

[0223] After determining the target data of the IoT platform, the target data is stored in the local storage resources of the IoT platform, and / or the target data is read from the local storage resources.

[0224] Optionally, the local storage resources of the IoT platform in this embodiment include, but are not limited to, local memory, local file systems, and local databases. This embodiment does not impose excessive limitations on these resources. Local memory is the fastest storage area, used to store currently used data and programs, and is extremely fast. A local file system is a method used by the operating system to organize and store files. It allows users and programs to store data in the form of files and folders. Local file systems use various strategies to optimize performance, such as caching in memory and grouping related data blocks together, to improve the speed and efficiency of data access. A local database is a system used to store, retrieve, manage, and process data. It is typically used to store large amounts of structured data and provides efficient data query and management functions.

[0225] In practice, this embodiment implements local caching services through local memory, provides persistent data processing through a local file system, and provides local storage services through a local database.

[0226] Caching of target data can be achieved by performing access operations on the target data in local memory. Here are some examples of target data that are suitable for caching:

[0227] 1) Real-time data from the sensors;

[0228] Real-time data from the sensor is used to represent the latest environmental data collected by the sensor.

[0229] For example, real-time data from sensors includes, but is not limited to, any one or more of the following: current readings from temperature sensors, instantaneous data from humidity sensors, PM2.5 index from air quality sensors, etc.

[0230] In practice, by caching this real-time data, the IoT platform can quickly provide the latest data when it receives a request from a user or device, without having to query the database every time, thus reducing the database load.

[0231] 2) Current status data of the device;

[0232] The device's current status data is used to indicate the operating or configuration status of IoT devices.

[0233] For example, the current status data of the device includes, but is not limited to, any one or more of the following: the on / off status of the smart light bulb, the current temperature setting of the smart air conditioner, the locking status of the smart door lock, etc.

[0234] In practice, by caching device status information, the IoT platform can quickly respond to user query requests, provide the latest device status, and improve the real-time feedback of user operations.

[0235] 3) User preference settings data;

[0236] User preference settings data are used to represent the user's personalized configurations and preferences on the IoT platform.

[0237] For example, user preference settings data include, but are not limited to, any one or more of the following: smart home scene modes set by the user (such as "away mode"), preset temperature values ​​of thermostats, volume and playlist settings of smart speakers, etc.

[0238] In practice, caching user preference settings allows the IoT platform to quickly load relevant configurations when users log in or operate devices, thus improving the user experience.

[0239] 4) Real-time location data;

[0240] Real-time location data is used to represent the geographical location of IoT devices or users.

[0241] For example, real-time location data includes, but is not limited to, any one or more of the following: the current location information of the vehicle's GPS system, the real-time trajectory of a smartwatch, and the location data of logistics and transportation vehicles.

[0242] In practice, by caching location data, the IoT platform can quickly provide geolocation information, supporting real-time tracking and navigation services.

[0243] In some examples, the access operations performed on target data for different local storage resources are as follows:

[0244] a) Access operations for target data in the cache;

[0245] Accessing target data in the cache is actually accessing target data in local memory. Access operations include storage operations and retrieval (read) operations.

[0246] Storage operations are used to store target data (such as real-time sensor data, device status, etc.) into a cache so that it can be quickly accessed in a short period of time.

[0247] In practice, when new data is generated, the system writes the data to a memory cache (such as Redis) and sets an expiration date to control the frequency of data updates; this data is the target data.

[0248] The fetch operation is used to quickly retrieve target data from the cache, avoiding access to the underlying database or file system.

[0249] In practice, when a user or device requests data, the system first checks the cache. If the data is in the cache, it is returned directly; otherwise, it is retrieved from the local database or local file system and the cache is updated. This operation of directly retrieving data from the cache has the following advantages:

[0250] Because the cache resides in memory, read speeds are much faster than disk operations. Using a cache can significantly reduce response time and improve system real-time performance. By caching frequently accessed data, the query load on the database is reduced, extending the database's lifespan and enhancing the overall system scalability.

[0251] b) Access operations for target data in the local database;

[0252] Access operations on target data in the local database include storage operations and retrieval operations, as detailed below:

[0253] Storage operations are used to indicate storing data in a local relational database such as SQLite.

[0254] In practice, data is written to the database using standard SQL statements, which may include operations such as insert, update, and delete.

[0255] The retrieval operation is used to indicate retrieving the target data stored in the local relational database.

[0256] In practice, the IoT platform retrieves target data from its local database based on a query request and returns it to the user or application. This operation typically involves executing the query statement and utilizing indexes.

[0257] In this embodiment, the access operations to target data in the local database can guarantee data consistency and durability. Compared with cache storage, database-stored data has higher durability and consistency, ensuring that data remains available after system restarts or failures. It also possesses complex query capabilities; the database excels at handling complex queries and data operations, especially joins, sorting, and aggregation operations involving multiple tables, outperforming caching in these areas.

[0258] c) Access operations for target data in the local file system;

[0259] Access operations for target data in the local file system include storage operations and retrieval operations, as detailed below:

[0260] Storage operations are used to represent storing target data as a file in the operating system's file system.

[0261] In practice, the target data is saved as a file in text, binary or other formats and stored in the system directory. File I / O operations (such as writing, saving, etc.) are typically used for data storage.

[0262] The retrieval operation is used to indicate reading the target data stored in the file system.

[0263] In practice, the system retrieves data from the file system through file I / O operations (such as opening and reading files) and loads it into memory for further processing.

[0264] This embodiment demonstrates access operations to target data within the local file system, which is beneficial for storing large amounts of data. The file system is suitable for storing large-scale data files, such as logs, images, and videos, which may not be suitable for storage in a database. It provides simple storage and backup functions; file system operations are relatively simple, and data backup and recovery are more intuitive, making it suitable for storing data that does not require frequent access.

[0265] As shown in Figure 3, this embodiment provides a lightweight architecture diagram of an IoT platform. It should be noted that the lightweight architecture provided in this embodiment is only an example. In actual practice, personalized functional modules and business applications can be provided according to the number of user devices and usage needs. The number of functional modules and business applications can be customized according to user requirements. Caching is implemented through local memory, persistent storage through a local file system, and local storage through a local database. MQTT services can also be provided by integrating third-party libraries within the IoT platform. For example, the business application is user-facing, and the device represents an IoT device, such as a shared bicycle. The user communicates with the business application service through the terminal's APP (e.g., scanning to unlock). The IoT platform establishes communication between the device and the business application service, sending the scanned unlock information to the device to control it to unlock.

[0266] The lightweight IoT platform provided in this embodiment can use a limited number of functional modules, such as device authentication, device modeling, device management, device monitoring, device simulation, message forwarding, web resources, and system management. The lightweight IoT platform can provide only basic device management capabilities, or it can provide necessary business functions, such as park services, financial services, transportation services, and external customer services. The IoT platform provided in this embodiment can be deployed on a server or a minicomputer. As shown in the table below, this embodiment provides a correspondence between a standard architecture IoT platform and a lightweight architecture IoT platform.

[0267] Table 1. Comparison of IoT Platform Architectures

[0268] The lightweight IoT platform of this embodiment can implement the caching function of a Redis caching server through local memory, the function of a MinIO file server through a local file system, the function of a database server through a local database, and the function of an MQTT server through integrated third-party libraries, such as MochiMQTT, an MQTT broker (also known as a broker) written in Erlang. Compared with the standard IoT platform architecture, the lightweight IoT platform provided in this embodiment reduces response time. Due to its middleware-free server architecture, the lightweight architecture reduces network latency (the time from the IoT platform to the server and back), eliminating network data transmission time. It also improves performance in areas such as cache server interaction, file server interaction, and messaging compared to the standardized architecture. Furthermore, it enhances service stability and reduces deployment complexity. With a standardized IoT architecture, if a middleware server becomes unavailable, the entire IoT platform becomes unavailable; the lightweight architecture, by using local storage resources and not relying on additional middleware servers, enhances service stability. Meanwhile, the lightweight architecture eliminates the need to deploy servers such as Redis, databases, MinIO, EMQX, and TDengine, significantly reducing deployment complexity and server costs.

[0269] In some embodiments, the local storage resource includes local memory; a caching service program utilizing the local memory performs access operations on the target data within the local memory. Optionally, the access operations on the target data are performed within the caching service program in the local memory; wherein the caching service program is used to provide caching services.

[0270] In implementation, the target data is stored in and / or read from the local memory of the IoT platform. The caching service program provides a local caching service. Since the caching service program is created in local memory, the target data can be stored in and / or read from the caching service program. It should be noted that since the caching service program performs data caching and retrieval operations based on local memory, any access operations performed on the caching service program are essentially access operations performed on local memory. Because Redis is a memory-based database that allows for fast data read and write, this embodiment achieves a memory-based caching service by creating a caching service program based on local memory, replacing the functionality of a Redis server. This avoids the IoT platform's dependence on a server, improves interaction efficiency, and reduces the hardware cost of deploying a server.

[0271] In some embodiments, the caching service program includes a local memory-based storage component; the local memory-based caching service program stores the target data in the local memory storage component and / or reads the target data from the local memory storage component. Optionally, the target data is stored in the storage component of the caching service program and / or reads the target data from the storage component of the caching service program.

[0272] In implementation, a storage component is set up in local memory, and a caching service program is used to cache the target data in the storage component, that is, to cache the target data in the caching service program. When there is a need to read, the target data can be read from the caching service program, thereby reducing the interaction process of accessing the middleware server when accessing data, improving interaction efficiency, and reducing response time.

[0273] In some embodiments, the caching service program is used to perform access operations on data with different data structures; and / or, the key-value pairs of the storage component of the caching service program have expiration times.

[0274] In implementation, the caching service in this embodiment can support data with different data structures, including but not limited to: strings, hashes, lists, sets, sorted sets, etc., suitable for different caching scenarios and needs. The caching mechanism is implemented by setting the expiration time of the key-value pairs in the storage component.

[0275] In some embodiments, the target data includes data with different data structures; access operations are performed on the data with different data structures in the value key-value object of the storage component of the local memory cache service program. In this embodiment, data with different data structures is stored in the key-value object of the storage component; and / or, data with different data structures is read from the key-value object of the storage component.

[0276] In implementation, the storage component stores data in a key-value (Key-Value) format and allows setting expiration times for these keys. Optionally, the storage component can use `cache.Cache`, a lightweight, in-memory KV storage component that supports expiration. The expiration time for key-value pairs is primarily used for memory and resource management. By setting an expiration time for key-value pairs, data is ensured to be automatically deleted after a certain period, thus preventing data from occupying memory space for extended periods. This mechanism is particularly important in in-memory databases because it helps manage memory usage and prevents expired data from consuming excessive storage space. Furthermore, appropriately setting the expiration time for key-value pairs can optimize data storage strategies based on business needs and data access frequency, improving system performance and efficiency.

[0277] In some embodiments, the caching service program in this embodiment includes, but is not limited to, any of the following: RedisClient (Redis client), Redis Desktop Manager (Redis desktop management tool), RedisStudio (Redis visual management tool), AnotherRedisDesktopManager (Redis graphical management tool), Jedis (a Redis client library for Java that provides a set of APIs for interacting with the Redis database), Lettuce (a high-performance Java Redis client), Redisson (a Java in-memory data grid implemented on top of Redis, a framework for distributed Java objects and services based on Java that provides rich functionality and APIs), Go-Redis (a Redis client library specifically designed for the Go language), redigo (a wrapper API), etc.

[0278] In implementation, a suitable caching service program can be selected and stored in local memory to provide local caching functionality. This avoids remote interaction between the IoT platform and the cache server, improves interaction efficiency, ensures the ability to quickly access data, and enhances platform performance. This embodiment does not impose excessive limitations on the specific caching service program.

[0279] In some embodiments, this embodiment can also utilize a caching service program to provide persistent data processing. The specific implementation process is as follows:

[0280] The local storage resource further includes a local file system; the cache service program is used to store the target data in the local memory into the local file system; and / or, the cache service program is used to read target data from the local file system and store the read target data into the local memory. Optionally, the target data in the cache service program is stored into the local file system; and / or, target data is read from the local file system and stored into the cache service program.

[0281] In practice, a cache service program can be used to persist the target data in the cache service program to the local file system (local disk). When the application is started or the cache data needs to be restored, the target data can be read from the local file system, realizing the persistent storage and restoration of local cache data, preventing data loss. Moreover, storing the target data of the cache service program in the local file system is more efficient than reading data from the database and then storing it in the local file system. It can retain device shadow data and ensure data persistence and security.

[0282] In some embodiments, the cache service program in this embodiment is also used to provide publish / subscribe functionality and / or distributed lock functionality;

[0283] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0284] In implementation, a caching service program can be used to implement publish / subscribe functionality, supporting real-time data transmission and communication. Within the IoT ecosystem, using publish / subscribe for communication between functional modules is more efficient than RPC (Remote Procedure Call) and decouples service dependencies. Publish / subscribe is a messaging pattern that allows a sender (publisher) to send messages to multiple receivers (subscribers). This pattern involves two main roles: publisher and subscriber. The publisher is responsible for publishing messages to specific channels or topics, while subscribers subscribe to these channels or topics to receive messages. When a publisher publishes a message on a channel, all subscribers to that channel will receive the message. A key characteristic of this pattern is its decoupling; the publisher does not need to know the subscribers' specific information, and similarly, the subscriber does not need to know the publisher's specific information, only how to receive messages. This pattern is widely used in various scenarios, such as real-time data updates and event notifications. Redis's publish / subscribe functionality is a typical example. In Redis, publish / subscribe functionality is implemented by executing specific commands. Subscribers subscribe to one or more channels by executing the `SUBSCRIBE` command, waiting to receive messages from these channels. Publishers, on the other hand, publish messages to specified channels using the `PUBLISH` command. When a message is published to a subscribed channel, the subscriber will receive it immediately. Furthermore, subscribers can unsubscribe from a specified channel using the `UNSUBSCRIBE` command, ceasing to receive messages from that channel. It's important to note that in Redis's publish-subscribe model, messages are broadcast to all subscribers; subscribers cannot filter messages.

[0285] In implementation, a distributed lock can also be implemented using a caching service program to achieve collaboration and synchronization among multiple clients, avoiding resource contention and concurrency issues. It ensures that only one service can modify a resource at a time. For scheduled tasks on IoT platforms, the distributed lock function can also solve the problem of a task being executed multiple times. The main function of a distributed lock is to ensure data integrity and avoid duplicate data processing. A distributed lock is a mechanism used to synchronize access to shared resources in a distributed system, ensuring that only one thread or process can access certain critical resources at a time, thereby avoiding data inconsistency. Its main functions include: ensuring data integrity, such as applying locks to resources that need to be accessed synchronously; and avoiding duplicate data processing, such as preventing scheduled tasks or other operations from being executed repeatedly on multiple machines. For example, after a cache expires, all requests will try to load the database; distributed locks prevent the repeated processing of the same data. The characteristics of distributed locks include: mutual exclusion: ensuring that only one thread or process can acquire the lock at any given time, thus guaranteeing exclusive access to resources; reentrancy: once a thread or process has acquired the lock, it should be able to acquire the same lock again without causing a deadlock; high availability: even if some nodes fail, the lock mechanism can still work normally, ensuring service availability; high performance: supporting high concurrency and low latency operations to meet the needs of large-scale data processing; and support for blocking and non-blocking operations: providing both blocking and non-blocking lock acquisition methods to adapt to different application scenarios.

[0286] Redis distributed locks (provided by the Redis caching service) ensure that in a distributed system, when multiple nodes access shared resources, only one node can obtain execution privileges, thus avoiding resource contention and conflicts. In a distributed system, multiple nodes may simultaneously access and modify the same data, potentially leading to data inconsistency or other concurrency issues. To address this, a mechanism is needed to control access to these shared resources. This is the role of distributed locks. By using Redis as the distributed lock manager, it ensures that only one node can acquire the lock and execute the corresponding operation at any given time, while other nodes are blocked until the acquired node releases the lock. This mechanism effectively solves problems that may arise when multiple nodes concurrently access shared resources, such as overselling and data inconsistency. Specifically, Redis distributed locks are implemented based on key-value pair set and delete operations. When a node needs to access a shared resource, it attempts to set a key-value pair in Redis to indicate that it has acquired the lock. If the setting is successful, the node has execution privileges; if the setting fails (because the lock is already held by another node), the node must wait until it acquires the lock or gives up after a timeout. After the operation is complete, the node that acquired the lock deletes the key-value pair to release the lock, and other waiting nodes can then acquire the lock and continue execution. Furthermore, Redis distributed locks support reentrancy, meaning the same thread can acquire the same lock multiple times without causing a deadlock. This is achieved by using a state variable at the underlying level to record the number of lock re-entries. The count is incremented each time the lock is acquired and decremented each time it is released, until the count reaches zero, indicating the lock has been completely released. In summary, Redis distributed locks provide an effective mechanism to ensure thread-safe and consistent access to and modification of shared resources in a distributed environment, thereby avoiding potential problems caused by concurrent access from multiple nodes.

[0287] It should be noted that in this embodiment, since local memory is used to provide caching services, that is, the caching service program stored in local memory is used to implement data caching. At this time, the cache is also local memory. The access operations performed by the caching service program are essentially access operations performed in local memory. That is, the local memory in this embodiment can be understood as the cache. The cache is implemented through the caching service program. The cache and the caching service program essentially use memory resources.

[0288] In some embodiments, this embodiment also provides a process for an IoT platform to process target data, as shown below:

[0289] Step 1) Determine that the target data is stored in the cache service program;

[0290] In practice, you can first check if there is cached data corresponding to target data X in the local memory (cache). If it exists, then read the cached data corresponding to target data X from the local memory (i.e., the cache service program).

[0291] Step 2) Read the target data from the cache service program, and process the target data to obtain feedback data;

[0292] In practice, since the caching service program provides caching services based on local memory, it can be understood that it reads the cached data corresponding to the target data X from the local memory cache, performs necessary transformations and processing on the cached data, and obtains the feedback data Y required by the device.

[0293] Step 3) Send the feedback data to the device connected to the Internet platform.

[0294] In practice, feedback data can be returned to the client or downstream services. For example, if a certain piece of data is used frequently, it can first be checked in the cache service program (cache). If it exists, it is read from the cache service program; otherwise, it is queried / read from the local database. Then, the read data is transformed and processed to meet the data requirements of the device, and the transformed and processed data is sent to the device.

[0295] As shown in Figure 4, this embodiment provides a schematic diagram of the process by which an IoT platform acquires device data. The specific process is as follows:

[0296] Step 400: The device sends a request message carrying the device identifier to the IoT platform;

[0297] Step 401: The IoT platform receives the request message and loads device information from the cache service program;

[0298] Step 402: The IoT platform determines whether the target data is stored in the cache service program;

[0299] Step 403: If the cache service program stores target data, then read the target data, convert the target data into device data, and send it to the device.

[0300] Step 404: If the target data is not stored in the cache service program, the target data is read from the local database and sent to the device.

[0301] The local database stores device information. When the target data is device-related, the device-related target data can be read from the device information in the local database. Optionally, the device information can be stored in the local database in the form of a device table.

[0302] It should be noted that in this embodiment, "target data" and "data" essentially refer to data from the IoT platform in a general sense. Target data does not specifically refer to any type of data from the IoT platform; it can be any data from the IoT platform. For example, in this embodiment, target data includes data from various functional modules, and target data includes data with different data structures.

[0303] The caching service program in this embodiment can replace the functionality of a Redis caching server, implementing a memory-based caching service, improving interaction efficiency, and reducing network latency. As a supporting module for all functionalities of the IoT platform, the caching service program in this embodiment provides the following resources and functions:

[0304] (1) Data Caching: Since the Redis server supports various data structures, the caching service program in this embodiment is designed to support multiple data structures, including but not limited to strings, hashes, lists, sets, and sorted sets. These data structures can be used for different caching scenarios and needs. Frequently used data can be cached in memory to speed up data access and reduce the pressure on the backend database. It supports modules such as device management and user authentication. For example, device information or user data can be stored in the caching service program. When device data or user data is needed, it is first loaded from the caching service program. This reduces response time and improves the throughput of the IoT platform compared to directly querying the database.

[0305] (2) Persistence Support: Since the Redis server supports persisting data to disk, the cache service program in this embodiment is designed to support persisting data to the local disk (i.e., the local file system) to prevent data loss. In implementation, two persistence methods can be provided: RDB (Redis Database, snapshot) and AOF (Append Only File) logs. The appropriate method can be selected based on actual needs. RDB and AOF logs are two persistence methods. RDB snapshots are a persistence method that saves a complete snapshot of the data in local memory at a certain point in time to disk. By generating a snapshot file, a snapshot of all data in memory is saved. AOF logs are a persistence method that appends each write operation to a file in the form of a log. It generates a log file that records all write operations. The AOF log's write strategy ensures data persistence and consistency; even after a system crash, data can be recovered by re-executing the commands in the log. Through the persistence processing of the cache service program, the IoT platform can retain device shadow data (device attribute information), which is more efficient than database storage.

[0306] (3) Publish / Subscribe Functionality: Since the Redis server supports publish / subscribe functionality, the cache service program in this embodiment is designed to support publish / subscribe functionality to implement message queues, event notifications, and other functions, supporting real-time data transmission and communication. When various functional modules within the IoT platform communicate, the publish / subscribe functionality is more efficient than RPC (Remote Procedure Call) communication and can decouple service dependencies.

[0307] (4) Distributed Lock Support: Since the Redis server provides distributed lock functionality, the cache service program in this embodiment is designed to support distributed lock functionality to achieve collaboration and synchronization among multiple clients, avoiding resource contention and concurrency issues. As a distributed service, the IoT platform involves resource modifications that are subject to competition. To ensure data consistency, using Redis distributed locks ensures that only one service can modify a resource at a time. Furthermore, for platforms with scheduled tasks, Redis distributed locks can solve the problem of a task being executed multiple times.

[0308] Currently, Redis server architecture modes include standalone mode, master-slave mode, Sentinel mode, and cluster mode. In IoT platforms, Redis standalone / master-slave mode, Sentinel mode, and cluster mode are suitable for different scenarios and requirements, as detailed below:

[0309] Standalone mode / master-slave mode: Suitable for small-scale IoT applications or development environments with small data volumes and low requirements for high availability and horizontal scaling. In standalone mode / master-slave mode, there is only one Redis instance, and the data is stored on a single node. There is no data backup or redundancy. Standalone mode / master-slave mode is simple and easy to use, and is suitable for rapid setup and development.

[0310] Sentinel Mode: Sentinel mode is suitable for IoT applications requiring high availability and fault recovery capabilities, necessitating guaranteed system stability and availability. Building upon single-machine mode, Sentinel mode introduces Sentinel nodes to monitor the status of the Redis master node and automatically switch to a standby node when the master node fails. Through Sentinel mode, master-slave failover and fault tolerance can be achieved, improving system availability.

[0311] Cluster Mode: Cluster mode is suitable for large-scale IoT applications or scenarios with large data volumes, requiring data distribution and horizontal scaling. In cluster mode, data is distributed across multiple nodes, with each node responsible for storing and processing a portion of the data. High availability and load balancing are achieved through data sharding and replication. Cluster mode allows for dynamic scaling up and down by adding or removing nodes, adapting to IoT applications of different sizes and needs.

[0312] In practical applications, a suitable Redis deployment mode can be selected based on the scale, performance requirements, and availability needs of the IoT platform. Standalone mode is suitable for small-scale, simple applications; Sentinel mode is suitable for scenarios requiring high availability and fault recovery; and cluster mode is suitable for large-scale, high-performance, and high-availability IoT applications.

[0313] Taking Go-Redis clients as an example, Go-Redis has corresponding client implementation methods for each architecture mode. These include creating Redis clients in single-machine / master-slave mode, Sentinel mode, and cluster mode. In Go, class implementation of interfaces is similar to subclass inheritance of parent classes; there's no keyword like `implement` (used in Java to explicitly declare which interfaces a class implements). A class implements an interface if it implements all the methods required by that interface.

[0314] Based on this, this embodiment can implement at least some of the Redis server's functionality by defining a target client that conforms to the cache client interface definition and implements the methods defined in Cmdable. Cmdable is a key concept in the Go-Redis client library, representing an object capable of executing Redis commands. In the Go-Redis client library implementation, the Cmdable interface is defined as a function type, allowing the definition of methods for manipulating Redis commands, such as Get and Set. These methods are typically used to execute specific Redis commands, such as retrieving or setting key-value pairs. Furthermore, the implementation of the Cmdable interface involves some low-level processing, such as request retries and network timeout handling; this logic is typically implemented in the Process method. In summary, Cmdable plays a crucial role in the Go-Redis client library, providing an abstract way to execute Redis commands, allowing users to interact with Redis in a unified manner without needing to concern themselves with the details of underlying network communication and command execution.

[0315] In some embodiments, the cache service program can be determined in the following manner:

[0316] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory; determine the cache service program based on the configured target client.

[0317] Optionally, the Redis caching client in this embodiment includes, but is not limited to: RedisClient, Redis Desktop Manager, RedisStudio, AnotherRedisDesktopManager, Jedis, Lettuce, Redisson, Go-Redis, and redigo. Caching clients allow developers to directly access and manipulate Redis instances within their applications, providing a convenient, flexible, and efficient way to operate on Redis data. Caching clients can be command-line based tools or client libraries provided by various programming languages, suitable for different use cases and needs. Users can choose the appropriate client based on their actual situation. Caching clients also provide rich APIs or commands, enabling developers to manipulate cached data more conveniently. For example, through caching clients, developers can perform operations such as setting, retrieving, and deleting key-value pairs, and utilize data structures provided by the caching client, such as lists, sets, and hashes, to implement more complex data operations.

[0318] In implementation, taking the creation of a Go-Redis client as an example, an in-process Go-Redis client implementation can be added, implementing the methods defined in Cmdable, thereby enabling local Redis caching. Specifically, a local in-memory Go-Redis client conforming to the Go-Redis client interface definition is defined, and cache.Cache is used as the storage component of the Go-Redis client. cache.Cache is a lightweight, in-memory key-value storage component that supports expiration. This removes the dependency on the Redis server from the caching service layer, eliminating the need to modify every part of the business logic code that calls Redis.

[0319] Go-Redis is a Redis client library specifically developed for the Go programming language. It provides a simple and efficient API (Application Programming Interface) for easy operation of Redis databases within Go. Compared to Redis client libraries in other languages, Go-Redis has the following advantages: First, Go-Redis is developed based on Go, conforming to the characteristics and conventions of Go, making it more natural and convenient to use; second, Go-Redis's API interface is concise and clear, offering rich functionality and options to meet the needs of different scenarios; third, Go-Redis boasts excellent performance and stability, supporting high-concurrency, large-scale IoT platform applications.

[0320] In some embodiments, the target client is created in the following manner:

[0321] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0322] The client-side factory class is a design pattern, specifically an application of the factory method pattern. In the client-side factory class, through the implementation of an abstract factory role (which can be an interface or abstract class) and concrete factory roles, the client can select a concrete factory of a subclass (such as server-side or client-side) according to its needs. The concrete subclass factory then produces its corresponding object for the client to use. This approach isolates object usage and creation, decoupling the system and making object creation and usage more flexible and scalable. This design pattern is very useful in software development, especially when handling multiple object creation logics, as it can improve code maintainability and scalability.

[0323] In implementation, the following approach was taken: By modifying the IoT platform client factory class to add local memory support, the following steps were taken:

[0324] Go-Redis provides client implementations for different Redis server architectures. To enable the IoT platform to support Redis servers with various architectures, a client factory class is needed. This class can create corresponding Redis clients based on the Redis server's architecture. Optionally, an environment variable (i.e., the Redis mode) can be added to identify the Redis server architecture. This environment variable can be stored in the IoT platform's program configuration file. When the IoT platform starts, it first loads the environment variable, and then the platform uses the client factory class to create different types of Redis clients based on the configured Redis mode.

[0325] (1) If the Redis mode is redisModeMemory (local cache mode), a target client is created that stores a cache implementation in local memory. When using this Redis mode (local cache mode), there is no need to deploy and configure a Redis server to store data. Instead, the data is stored using a local memory cache service program (cache), avoiding network overhead and providing a lightweight local data caching service.

[0326] (2) If the Redis mode is redisModeStandalone (single machine / master-slave), then create a Redis client in single machine / master-slave mode.

[0327] (3) If the Redis mode is redisModeSentinel, then create a Redis client in Sentinel mode.

[0328] (4) If the Redis mode is redisModeCluster, then create a Redis client in cluster mode.

[0329] If the Redis mode is not any of the above, log a fatal error and terminate the program execution.

[0330] In implementation, after creating a target client that conforms to the cache client interface definition, it is also necessary to set up access methods for different data structures, thereby enabling the target client to perform access operations on data of different data structures. Each data structure requires a corresponding access operation method to be built and stored in the key-value component of the target client's storage component in local memory.

[0331] The following section explains how to implement storage operations for different data structures.

[0332] In some embodiments, the data structure includes a hash data structure; access to the hash data is defined as follows:

[0333] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0334] Optionally, the target client includes a storage component that stores hash data into the key-value object of the storage component by calling the HSet method, and / or reads hash data from the key-value object of the storage component by calling the HSet method. The HSet method is a Redis method used to add or modify key-value pairs in a hash table. The HSet method allows users to insert one or more key-value pairs into a specified hash table. The basic principle of hashing is to transform an input of arbitrary length into a fixed-length output using a hash algorithm.

[0335] In implementation, the local in-memory Redis client's implementation of the Redis data type Hash (i.e., defining the operations for storing and retrieving data) primarily utilizes Go's `sync.Map`. `sync.Map` is a thread-safe Map type designed for safely sharing and manipulating data among multiple goroutines. A goroutine is a lightweight thread in Go, also known as a coroutine. `sync.Map` is designed with performance in mind, providing higher query efficiency than lock-based maps even in read-heavy, write-light scenarios. `sync.Map` is highly efficient in read operations while ensuring the correctness of concurrent writes. Furthermore, the read, insert, and delete operations of `sync.Map` maintain constant-time complexity, making it a preferred data structure for high-concurrency scenarios. `sync.Map` has the following key characteristics:

[0336] (1) Concurrency safety: sync.Map implements a concurrency-safe data access mechanism, which allows for safe read and write operations between multiple goroutines.

[0337] (2) No locking required: Unlike traditional map, sync.Map uses a special concurrency-safe algorithm that avoids the use of locks. This ensures that concurrent reads will not block other read operations.

[0338] (3) Dynamic growth: sync.Map can dynamically grow and shrink its internal data structure to adapt to different concurrent loads.

[0339] (4) Memory safety: sync.Map uses pointer references and garbage collection mechanisms to ensure that memory leaks or invalid references will not occur due to concurrent access.

[0340] In IoT platforms, hashes are typically used to store device-related information and data. This data includes, but is not limited to:

[0341] (1) Device information: Hash can store basic device information, such as device ID, device name, device type, manufacturer, model, software version, etc.

[0342] (2) Device status: Hash can store real-time status information of the device, such as device online status, connection status, running status, power status, working mode, etc.

[0343] (3) Device shadow data: Hash can store device attribute information, such as sensor data such as temperature, humidity, pressure, and light.

[0344] (4) Equipment historical data: Hash can store the historical data of the equipment, such as the time series information of sensor data, which can be used to analyze and trace the operation of the equipment.

[0345] (5) Device commands and control: Hash can store device commands and control information, such as remote control commands, upgrade instructions, configuration changes, etc.

[0346] In implementation, within the device management module, the device information of any device object is converted into a JSON (JavaScript Object Notation) string. Then, the HSet method of the Go-Redis client in local memory is called to store the string in the local object sync.Map, which is the key-value object of the storage component in local memory. When needed, the HGet method of the Go-Redis client in local memory is called to first obtain the JSON string, and then the string is converted into a device information object for business use.

[0347] In practice, the implementation approach for accessing hash data in this embodiment is as follows:

[0348] Sets the value of a hash table in local memory. It accepts a key and one or more values ​​as parameters and performs corresponding operations based on the existence of the key. If the specified key already exists in local memory, it means that a corresponding hash table is stored in local memory. In this case, the value corresponding to the key in the hash table is updated, and the result value is set to 1 (the result value represents the execution result returned to the caller; 1 indicates success). If the specified key does not exist, it means that a corresponding hash table does not exist in local memory. In this case, a new hash table is created, the key-value pair is stored in the new hash table, and the result value is set to 1. If the type of the parameter value is not supported, an error will be thrown.

[0349] This embodiment uses hashing to store device-related information and data, enabling the IoT platform to achieve fast data access, flexible data querying and manipulation, thereby realizing device management, monitoring and control. Simultaneously, the hash structure can be easily expanded and managed to adapt to different types and scales of IoT application scenarios. Because it uses local memory for caching operations, it provides a local high-speed caching client, eliminating network interaction overhead and offering a lightweight solution that does not rely on a Redis server, thus improving data interaction efficiency.

[0350] In some embodiments, the data structure includes an ordered set data structure; the processor is specifically configured to perform access operations on the ordered set data in the following manner:

[0351] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0352] Sorted Sets are a hybrid data type similar to Lists and Hashes. Like sets, sorted sets consist of unique, non-repeating string elements. However, the elements within a sorted set are not ordered; each element is associated with a floating-point value called a score, and the elements are sorted according to their scores. Because each element maps to a value (score), sorted sets also resemble hash data types.

[0353] In implementation, a SortedSet structure is first defined, which includes members, scores mapped to the members' scores, and an Add method. When a member is added, the members are reordered according to their scores, thereby enabling the target client (such as a Go-Redis client) to access and store data in the SortedSet.

[0354] The implementation approach is as follows: Define a structure named `SortedSet` to represent an ordered set data structure. Then, define a series of methods to operate on this ordered set, that is, to perform storage and retrieval operations on the data within it. The methods that need to be implemented are as follows:

[0355] (1) newSortedSet(): Creates a new SortedSet instance and initializes the member variables of the sorted set.

[0356] (2) Add(member string, score float64): Adds an element to the sorted set and dynamically sorts it according to its score. If the element already exists, its score is updated.

[0357] (3)RangeByScore(min,max float64)[]string: Get the element based on the score range.

[0358] (4)GetScore(member string)(float64,bool): Get the score of the specified element.

[0359] (5) Remove(member string): Removes the specified element from the sorted set and re-sorts it according to the score.

[0360] (6) Length()int64: Get the length of the sorted set.

[0361] (7)RevRange(start,stop int)[]string: Retrieves elements in reverse order based on the index range.

[0362] (8) ZAdd(ctx context.Context,key string,members...redis.Z)*redis.IntCmd: Adds one or more members to a sorted set and sorts them according to their scores. If the value (V) for the specified key (K) does not exist, a new SortedSet instance is created.

[0363] The above functions implement a memory-based ordered set data structure and provide a series of operation methods, including adding, deleting, retrieving scores, and querying by score range. Optionally, a mutex lock can be used to ensure concurrency safety, preventing data races caused by multiple goroutines accessing the data simultaneously.

[0364] In some embodiments, the data structure includes a linked list data structure; the processor is specifically configured to perform access operations on the linked list data of the linked list data structure in the following manner:

[0365] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0366] The linked list data structure includes List, which is equivalent to an array or sequential list, where the index of the leftmost element is 0. Redis lists are simple lists of strings, sorted according to insertion order. Users can add an element to the head (left) or tail (right) of the list, making it a flexible data structure suitable for scenarios requiring the preservation of element insertion order. Redis Lists provide operations such as insertion, deletion, and retrieval of list elements, which are very useful in many application scenarios, such as message queues and task scheduling.

[0367] In implementation, a doubly linked list is used to implement data access operations, and methods for these operations are defined. A doubly linked list is a data structure where each node contains two pointers: one pointing to its previous node and the other to its next node. This structure allows data elements to be traversed in both directions, providing greater flexibility. Key features of a doubly linked list include: each node has two pointer fields: one pointing to its immediate predecessor (prev) and the other to its immediate successor (next). This structure allows for easy access to both the predecessor and successor nodes given any node, without needing to traverse from the head or tail. A doubly linked list can be circular, meaning the predecessor pointer of the head node can point to the last node, and the successor pointer of the last node can point to the head node, forming a doubly circular linked list. Doubly linked lists are very useful in scenarios requiring frequent access to previous and next nodes, such as in implementing certain algorithms or data structures, such as undo operations, inserting or deleting elements in the middle, etc. Furthermore, doubly linked lists are also commonly used to implement efficient queues and stacks. Therefore, the IoT platform in this embodiment can improve the efficiency of data access operations in scenarios where frequent access to previous and next nodes is required through the data access operations of a doubly linked list, thereby achieving efficient data access operations, increasing access speed, and reducing response speed.

[0368] In some embodiments, this implementation achieves the publish / subscribe functionality for the target client (such as a Go-Redis client) in the following manner:

[0369] In some embodiments, the publish / subscribe functionality of the caching service program is configured by defining a PubSub (publish / subscribe) structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel.

[0370] In implementation, the Go-Redis client in local memory primarily uses Go's channels for publishing / subscribing. A channel can be understood as a first-in, first-out queue, used for communication via pipes. Publish / subscribe is a message communication pattern that allows a sender (publisher) to send messages to multiple receivers (subscribers). This pattern uses channels for message publishing and subscription, where channels act as a conduit for messages, distinguishing different types or topics. Subscribers can choose to subscribe to channels of interest to receive corresponding messages. The publish / subscribe pattern is stateless; that is, after sending a message, the publisher does not need to worry about whether any subscribers have received it, nor does it need to maintain subscriber information. When a publisher publishes a message to a channel, all subscribers to that channel will receive the same message. This mechanism decouples message publishers and subscribers and supports one-to-many message delivery, i.e., broadcast. The Go-Redis client's publish / subscribe pattern has a wide range of applications, including real-time communication, data update notifications, real-time message delivery, and subscription services.

[0371] The implementation approach is as follows: Define a RedisPubSub structure to handle Redis publish / subscribe functionality. The specific implementation methods include any one or more of the following:

[0372] (1) The necessary packages have been imported, as shown below:

[0373] context: Used for handling context.

[0374] go-redis / v9: Redis client library.

[0375] go-level-logger: A logging library.

[0376] (2) Define the RedisPubSub structure, which contains two fields as shown below:

[0377] redisClient: A client used to execute Redis commands.

[0378] PubSub: An object used for publish / subscribe.

[0379] (3) Define the NewRedisPubSub() function to create a new RedisPubSub instance;

[0380] In practice, inside the function, a new Redis client is first created. If client creation fails, the error is logged and an error message is returned. Otherwise, a RedisPubSub instance containing the newly created Redis client is returned.

[0381] A Redis PubSub instance involves using Redis's publish-subscribe (PubSub) mechanism for message communication. This mechanism allows clients to publish messages to channels, and other clients can subscribe to these channels to receive these messages. The following are the basic implementation steps and examples of the Redis PubSub mechanism: Publishing a message: Clients use the PUBLISH command to publish messages to a specific channel; when a message is published, Redis internally looks up all clients subscribed to this channel in its data structure and sends the message to those clients; Subscribing to messages: Clients use the SUBSCRIBE command to subscribe to one or more channels. When new messages are published to these channels, Redis sends the messages to the clients subscribed to these channels. The Redis PubSub structure also involves two parts: pubsub_channels and pubsub_patterns. These two fields are used to store the channels and patterns subscribed to by clients, respectively. pubsub_channels is a dictionary where the keys are channel names and the values ​​are lists of clients subscribed to those channels. This dictionary stores information about the channels subscribed to by clients, with the channel as the key and the list of clients subscribed to that channel as the value. This data structure allows Redis to efficiently manage and look up clients subscribed to a specific channel. `pubsub_patterns` is a list used to store patterns that clients subscribe to. Each element is a pattern, representing the set of patterns a client subscribes to. This list is used to handle pattern-based subscriptions, where clients can subscribe to messages matching specific patterns, not just specific channels. This design allows Redis to implement a flexible publish-subscribe mechanism, supporting both channel-based and pattern-based subscriptions. By using both dictionary and list data structures, Redis can effectively manage and track subscription relationships, thereby achieving efficient message publishing and delivery.

[0382] (4) Define the Publish() method to publish messages to the specified channel;

[0383] In practice, this method calls the Redis client's Publish() method and returns the result.

[0384] (5) Define the Subscribe() method to subscribe to one or more channels and specify the message processing callback function;

[0385] In implementation, the method first subscribes to the specified channel. A goroutine (a lightweight thread in Go used for concurrent programming) is used to listen for messages and pass the received messages to a callback function for processing. If the subscription fails, an error message is returned.

[0386] (6) Define the Unsubscribe() method to unsubscribe from the specified channel;

[0387] In practice, if the pubsub object exists, its Unsubscribe() method is called to unsubscribe from the specified channel.

[0388] (7) Define the Close() method to close the RedisPubSub instance;

[0389] In practice, if the PubSub object exists, its Close() method is called to close the publish / subscribe mechanism. If the redisClient object exists, its Close() method is called to close the Redis client.

[0390] The above methods implement the publish-subscribe functionality of a local memory Redis client, including operations such as publishing messages, subscribing to channels, unsubscribing to channels, and closing publish-subscribe instances. It should be noted that this embodiment does not impose too many restrictions on the execution order of the above methods (1) to (7), and the above execution order can be defined by oneself.

[0391] In some embodiments, this embodiment can store target data in the cache service program (i.e., the target client) into the local file system, or read target data from the local file system and store the read target data into the cache service program, thereby realizing persistent storage and recovery of local memory (cache) data.

[0392] Optionally, this embodiment achieves persistent storage and retrieval of data in local memory (cache) in the following manner:

[0393] Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; and / or,

[0394] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0395] In implementation, Go's gob mechanism can be used to achieve persistent storage and retrieval of locally cached data. The gob mechanism is a serialization and deserialization mechanism provided by Go, which allows Go data structures to be converted into binary format for storage or network transmission. It can serialize Go objects into byte streams for storage and transmission, and deserialize the byte streams back into the original objects when needed. The specific method for implementing this step is as follows:

[0396] Step a: Define the data structure;

[0397] First, you need to define the data structure to be cached. These data structures can be Go language structs, containing the various fields of the cached data. For example:

[0398] The DataType values ​​are string, hash, list, set, and sortedset, representing the basic Redis data structures: string, hash, list, set, and sorted set.

[0399] Step b: Serialize the data;

[0400] When cached data is updated or changed, the data is serialized into a byte stream. The `Encode` method provided by the `gob` package is used to serialize the data into a byte stream and store it in a file on the local file system (local disk).

[0401] Optionally, for data in the local cache, different CacheItem instances can be created according to string, hash, list, set, and sortedset. After merging, serializeCache is called to implement cache data storage. The CacheItem instance is an object used to store cached data, containing key information such as key-value pairs and expiration policies. After merging, cached data of different data structures are all placed in a single instance, and the entire cache data is stored in a single file. This facilitates unified data access and retrieval, avoids multiple file writes, improves access efficiency, enhances interaction efficiency, and saves time.

[0402] SerializeCache is a concept involving the process of serializing an object into a byte stream and storing it in a cache for later deserialization back to the original object. This process is typically used to preserve the state of an object in a storable and transmittable format, especially in distributed systems or where persistent data is required. In computer science, serialization is the process of converting an object's state information into a storable or transmittable format, while deserialization is the opposite process, restoring the data in this format to an executable object. Caching is a technique for storing data for fast access, reducing the need to access the original data source. Specifically, a SerializeCache object likely refers to a cache object that implements serialization and deserialization functionality. Such an object typically has the ability to convert an object into a byte stream and store it in the cache, and also to read a byte stream from the cache and convert it back to the original object. This mechanism is particularly useful when dealing with complex objects or large amounts of data because it allows the state of an object to be preserved as a simple byte stream, which can be stored in memory, on disk, or sent over a network.

[0403] Step c: Deserialize the data;

[0404] When starting the application or needing to restore cached data, the serialized byte stream is read from a file on the local file system and deserialized into the original data structure. The `Decode` method provided by the `gob` package is used for deserialization. In implementation, based on the `DataType` value in the parsed `CacheItem`, the corresponding `set` method of the target client object in local memory is called according to whether it is string, hash, list, set, or sortedset, loading the data into local memory (cache). The `Set` method of the Go-Redis client is used to store data in local memory. When using the Go-Redis `Set` method, you can specify the key, value, and expiration time. For example, creating a key-value pair with the key `mykey` and the value "data A", and setting its expiration time to 1 hour, will result in this key-value pair expiring after 1 hour. In this way, Redis can be easily used to store and retrieve data in the caching service program.

[0405] In some embodiments, this embodiment may also perform periodic data persistence, periodically storing target data from the cache service program into the local file system; and / or periodically reading target data from the local file system and storing the read target data into the cache service program.

[0406] In practice, to ensure persistent data storage, data persistence operations are performed periodically in the caching service program. For example, a timer can be set to perform a data persistence operation at regular intervals.

[0407] By following the steps above, the persistent storage and retrieval of local cached data is achieved using Go's gob mechanism. This method is simple, efficient, and suitable for small-scale cached data persistence scenarios.

[0408] In some embodiments, the IoT platform further includes a cache server; the processor is specifically configured to perform a switch between the cache service program and the cache server when a switching condition is met.

[0409] In practice, the cache service program in this embodiment can implement the functions of a Redis server and can replace a Redis server. When there is a switching requirement, the cache service program can be switched to a cache server, and the cache server can be used to perform data storage and retrieval operations. This embodiment can define a cache server based on the Go-Redis client interface, extend it to implement a target client based on local memory, and be compatible with various architectures of Redis server (single machine, master-slave, sentinel, cluster, local cache), and can seamlessly switch between various architectures.

[0410] As shown in Figure 5, this embodiment provides a schematic diagram of an IoT platform architecture that supports local caching of Redis. A target client based on local memory is created. Taking the Go-Redis client as an example, it supports basic Redis data structures such as strings, hashes, lists, sets, and sorted sets. It implements the methods defined in the Cmdable interface definition of the Go-Redis client, supports the above basic Redis data structures, supports local memory data storage, and can also automatically invalidate data in local memory (cache) upon expiration. It can also periodically write cached data to local disk files. When the IoT platform starts, it can load cached data from local disk files to complete the initialization of cached data.

[0411] Among numerous database products, SQL Server has become a popular choice for enterprise applications due to its powerful features, high performance, and reliability. However, in the Go language web development field, the Beego ORM (Object Relational Mapping) framework only supports MySQL (Relational Database Management System), PostgreSQL (Object-Relational Database Management System), and SQLite (Lightweight Relational Database Management System) by default, lacking direct support for SQL Server, which causes inconvenience for developers. To extend the support of IoT platforms for SQL Server databases, the SQL Server adapter in the Beego ORM persistence framework is extended, enabling IoT platforms to support various mainstream databases. By expanding the applicability of Beego ORM, it can connect to and manipulate SQL Server databases, thus meeting the needs of more developers. By implementing the SQL Server adapter, developers can use Beego ORM to perform database operations as easily as using other databases, without writing complex SQL statements or manually processing result sets, greatly improving development efficiency and providing greater flexibility and scalability. The following is a description of the specialized terminology involved:

[0412] A database is a warehouse for storing data. Essentially, it is a file system where data is stored in a specific format. Users can add, modify, delete, and query data in the database.

[0413] Structured Query Language (SQL) is a database query and programming language used to access, query, update, and manage relational database systems. It mainly includes:

[0414] (1) Data Definition Language (DDL) is used to define database objects: databases, tables, columns, etc. Keywords: create, alter, drop, etc.

[0415] (2) Data Manipulation Language (DML) is used to update records in tables within a database. Keywords: insert, delete, update, etc.

[0416] (3) Data Control Language (DCL) is used to define database access permissions and security levels, as well as to create users.

[0417] (4) Data Query Language (DQL), used to query records in tables of a database. Keywords: select, from, where, etc.

[0418] In Go, a struct is a user-defined type that represents a collection of fields (primitive data types or reference data types). Sometimes, it's more meaningful to treat multiple data sets as a whole than to use them individually; in such cases, a struct is suitable. For example, it makes sense to package an employee's name, age, and salary into a single struct called `employee`.

[0419] This embodiment implements support for SQL Server databases, ensuring that applications can fully utilize the functionality of Beego ORM and achieve seamless integration with SQL Server. By modifying the Beego ORM source code, including creating a SQL Server database driver, adjusting the SQL statement generator, and updating database operation methods, support for SQL Server databases was successfully implemented. After testing and optimization, it is ensured that the modified Beego ORM maintains good performance and stability.

[0420] In some embodiments, the local storage resource includes a local database; the local database includes different types of databases; the processor is specifically configured to perform access operations on the target data within the local database.

[0421] In practice, the target data is stored in the local database; and / or the target data is read from the local database.

[0422] In some embodiments, the processor is specifically configured to determine the local database in the following manner:

[0423] Step 1) Based on the Object Relational Mapping (ORM) framework, create a target database adapter, which is used to communicate with the target database;

[0424] In implementation, you can first choose a suitable database driver, such as using github.com / denisenkom / go-mssqldb as the driver for connecting to SQL Server. The selection of the database driver can consider the following factors:

[0425] Factor 1: Active community support; Factor 2: Stable functionality and performance; Factor 3: Good documentation and examples; Factor 4: Open source license.

[0426] During implementation, the Beego ORM source code can be analyzed and modified to ensure that the modified Beego ORM code is compatible with SQL Server databases as well as Postgres, MySQL, and SQLite. This allows Beego ORM to adapt to more database types while maintaining its existing functionality. Specifically, a target database adapter can be created. Taking SQL Server as an example, a new database adapter can be implemented to enable Beego ORM to communicate with SQL Server.

[0427] In implementation, the Beego ORM source code can be modified using an SQL generator to generate DDL for SQL Server databases and automatically create database objects (tables, indexes, etc.). The SQL generator is primarily responsible for generating corresponding DDL or DML statements based on the content of the custom tags in the parsed entity object model. First, the SQL generator verifies whether the database table corresponding to the entity object model exists. If the table does not exist, it generates the SQL statement (DDL) for creating the table based on the name and type of the column defined in the Beego ORM tags. Otherwise, the SQL executor iterates through all fields, checking if the column exists in the table. If the corresponding column already exists, it checks if the length or type has changed and generates a change SQL statement; if the corresponding column does not exist, it generates a statement to add the column. Unlike PostgreSQL and MySQL, SQL Server does not support `CREATE TABLE IF NOT EXISTS`. Therefore, the table creation statement generation code is modified to enable the modified SQL Server to support `CREATE TABLE IF NOT EXISTS`.

[0428] Step 2) By defining the operation method of the target database adapter, set the operation method for the target database;

[0429] In implementation, based on the selected SQL Server driver library, the methods required for the Beego ORM driver interface are implemented, namely, the methods for operating on the target database and the target database adapter interface definition. The specific implementation method is as follows:

[0430] (1) Register: Register the SQL Server driver to Beego ORM.

[0431] (2) Connect: Locate the driver and connect to the SQL Server database.

[0432] (3) Exec: Executes SQL statements, such as INSERT, UPDATE, and DELETE.

[0433] (4) Query: Executes a query statement, such as SELECT, and returns a result set.

[0434] (5) Mapping: Maps the database table structure to a Go struct.

[0435] (6) Other interface methods, such as transaction processing, database connection pool management, etc.

[0436] Step 3) Determine the local database based on the set target database, wherein the local database includes the target database.

[0437] Optionally, based on the syntax of the ORM framework, the target database after the settings are performed into a syntax transformation to obtain the local database. The syntax transformation includes any one or more of the following:

[0438] Method a: Define a set of keywords and add a keyword judgment function;

[0439] In practice, query keywords can be manipulated. Reserved words or keywords can be created in SQL Server as table or column names. When using them, the table or column name must be enclosed in square brackets ([]), for example:

[0440] CREATE TABLE[SELECT]([ID]INT,[Name]VARCHAR(50)).

[0441] To ensure proper execution of SQL statements and support keyword queries, a keyword set can be defined, a branch can be added to handle keywords, a keyword judgment function can be added to the adapter interface, and this judgment function can be called and encapsulated when generating SQL statements, so that the ORM framework can support keyword queries.

[0442] Method b: Add identification information for the auto-incrementing primary key used to retrieve inserted data;

[0443] In practice, because the driver does not support data insertion (i.e., the database driver github.com / denisenkom / go-mssqldb does not implement LastInsertId()), this embodiment modifies it to support data insertion by adding a method that returns the ID of the auto-incrementing primary key, and returns the ID of the inserted data. Specifically, this embodiment uses the SELECT IDENT_CURRENT('table name') method to obtain the ID of the inserted data.

[0444] Method c, modified to support pagination;

[0445] In practice, when the table stores a large amount of data, but only a few records need to be viewed, pagination can be used. Because SQL Server's pagination method is somewhat unique and does not support `LIMIT OFFSET`, the Beego ORM source code was modified to enable pagination in SQL Server.

[0446] Method d: Configure the application connection method.

[0447] In practice, to configure the application to connect to SQL Server, first, import the driver, and then connect to the SQL Server database.

[0448] Optionally, after performing syntax conversion on the SQL Server database using the methods described above, the SQL Server adapter can be tested and verified, as shown below:

[0449] (1) Unit testing: Write unit test cases to test the various functions of the SQL Server adapter, such as connecting to the database, executing SQL statements, and processing result sets.

[0450] (2) Integration testing: Integrate the SQL Server adapter into the Beego application and perform end-to-end testing to ensure its functionality and performance in real-world application scenarios.

[0451] (3) Performance testing: Use tools or scripts to perform performance testing on the SQL Server adapter, evaluate its efficiency and stability, and perform necessary optimizations.

[0452] This embodiment supports local databases including SQL Server, MySQL, PostgreSQL, and SQLite, ensuring that applications can fully utilize the functionality of Beego ORM and achieve seamless integration with SQL Server databases. Beego ORM provides rich features such as model definition, data querying, and relationships, helping developers quickly complete database operations, reducing development difficulty, and improving development efficiency. Using Beego ORM makes code clearer, easier to understand, easier to maintain and extend, and enhances code maintainability. This embodiment enriches the Beego ecosystem, making it more competitive.

[0453] As shown in Figure 6, this embodiment provides a schematic diagram of a lightweight IoT platform, including an implementation of a target client based on local memory and an implementation of a local SQL Server database based on an ORM framework. It provides caching services through local memory, using Redis (caching) as the primary data storage and interacting with it through a Go-Redis client library. By extending the Go-Redis client, it provides a local caching implementation scheme, achieving efficient and reliable data storage and access. The local database enables the IoT platform to support various mainstream databases. Support for SQL Server databases is implemented, ensuring that applications can fully utilize the functionality of Beego ORM and achieve seamless integration with SQL Server databases.

[0454] To reduce costs, increase efficiency, and improve delivery speed, the IoT platform provided in this embodiment features a lightweight design suitable for the edge side, offering a method for implementing an IoT platform architecture with extremely low hardware resources (such as 1GB of memory and 1 CPU). This solution has the following advantages: based on the interface definition of a caching service program (such as a Go-Redis client), it extends the implementation of a target client based on local memory, while being compatible with various Redis architectures (single-machine, master-slave, sentinel, cluster), allowing seamless switching between architectures. Data storage is achieved based on local memory, reducing remote interaction and improving platform performance compared to a Redis server architecture. It does not rely on a Redis server, saving hardware resources and reducing deployment costs, thus meeting the high-performance and low-latency requirements of IoT platforms.

[0455] The Internet of Things (IoT) platform is a continuously evolving system that requires constant improvement and optimization. After implementing local caching, continuous improvement and optimization are necessary to enhance system performance, reliability, and scalability to adapt to evolving business needs and technological challenges. The implementation method provided in this embodiment ensures that the IoT platform can successfully implement a lightweight architecture supporting local caching, achieving goals such as improving system performance, reducing system load, ensuring data consistency, and enhancing user experience.

[0456] Based on the same inventive concept, this disclosure also provides a data processing method that can be applied to an Internet of Things (IoT) platform. The principle of this method in solving the problem is similar to that of the IoT platform. Therefore, the implementation of this method can refer to the implementation of the IoT platform, and repeated details will not be described again.

[0457] As shown in Figure 7, the implementation process of this method is as follows:

[0458] Step 700: Determine the target data for the IoT platform;

[0459] Step 701: Perform access operations on the target data within the local storage resources of the IoT platform.

[0460] As an optional implementation, the local storage resource includes local memory; within the local storage resource of the IoT platform, performing access operations on the target data includes:

[0461] In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

[0462] As an optional implementation, the caching service program includes a local memory-based storage component; the caching service program in the local memory performs access operations on the target data, including:

[0463] The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

[0464] As an optional implementation, the cache service program is used to perform access operations on data with different data structures; and / or,

[0465] The key-value (KV) settings of the storage component of the cache service program have expiration times.

[0466] As an optional implementation, the local storage resource further includes a local file system; the method further includes:

[0467] Store the target data in the cache service program to the local file system; and / or,

[0468] The target data is read from the local file system and stored in the cache service program.

[0469] As an optional implementation, a serialization mechanism is used to serialize the target data stored by the cache service program into a byte stream, and the byte stream is stored in the local file system; and / or,

[0470] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0471] As an optional implementation, the caching service program is also used to provide publish / subscribe functionality and / or distributed locking functionality;

[0472] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0473] As an optional implementation, the publish / subscribe functionality is provided in the following manner:

[0474] By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

[0475] As an optional implementation, the cache service program is determined in the following manner:

[0476] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory;

[0477] The cache service program is determined based on the target client settings.

[0478] As an optional implementation, creating a target client that conforms to the cache client interface definition includes:

[0479] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0480] As an optional implementation, the data structure includes a hash data structure; the step of setting the target client to perform access operations on data of at least one data structure in the local memory includes:

[0481] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0482] As an optional implementation, the data structure includes an ordered set data structure; the step of setting the target client to perform access operations on data of at least one data structure in the local memory includes:

[0483] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0484] As an optional implementation, the data structure includes a linked list data structure; the step of setting the target client to perform access operations on data of at least one data structure in the local memory includes:

[0485] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0486] As an optional implementation, the method further includes:

[0487] It is determined that the target data is stored in the cache service program;

[0488] The target data is read from the cache service program, and the target data is processed to obtain feedback data.

[0489] The feedback data is sent to the device connected to the Internet platform.

[0490] As an optional implementation, the IoT platform further includes a cache server; the method further includes:

[0491] When the switching conditions are met, the switch between the cache service program and the cache server is executed.

[0492] As an optional implementation, the local storage resource includes a local database; the local database includes different types of databases; the method further includes:

[0493] Within the local database, access operations are performed on the target data.

[0494] As an optional implementation, the local database is determined in the following manner:

[0495] Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database.

[0496] By defining the operation method of the target database adapter, the operation method for the target database is set;

[0497] Based on the set target database, the local database is determined, wherein the local database includes the target database.

[0498] As an optional implementation, determining the local database based on the set target database includes:

[0499] Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

[0500] Based on the same inventive concept, this disclosure also provides an electronic device. Since this electronic device is the same as the electronic device in the method of this disclosure, and the principle of solving the problem by this electronic device is similar to that of this method, the implementation of this electronic device can refer to the implementation of the method, and the repeated parts will not be described again.

[0501] As shown in Figure 8, the electronic device includes a processor 800 and a memory 801. The memory 801 is used to store programs executable by the processor 800. The processor 800 is used to read the programs in the memory 801 and perform the following steps:

[0502] Identify the target data for the IoT platform;

[0503] Access operations are performed on the target data within the local storage resources of the IoT platform.

[0504] As an optional implementation, the local storage resource includes local memory; the processor is specifically configured to execute:

[0505] In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

[0506] As an optional implementation, the caching service program includes a local memory-based storage component; the processor is specifically configured to execute:

[0507] The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

[0508] As an optional implementation method,

[0509] The cache service program is used to perform access operations on data with different data structures; and / or,

[0510] The key-value (KV) settings of the storage component of the cache service program have expiration times.

[0511] As an optional implementation, the local storage resource further includes a local file system; the processor is specifically configured to execute:

[0512] Store the target data in the cache service program to the local file system; and / or,

[0513] The target data is read from the local file system and stored in the cache service program.

[0514] As an optional implementation, the processor is specifically configured to execute:

[0515] Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; and / or,

[0516] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0517] As an optional implementation, the caching service program is also used to provide publish / subscribe functionality and / or distributed locking functionality;

[0518] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0519] As an optional implementation, the processor is specifically configured to execute:

[0520] By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

[0521] As an optional implementation, the processor is specifically configured to determine the cache servicing program in the following manner:

[0522] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory;

[0523] The cache service program is determined based on the target client settings.

[0524] As an optional implementation, the processor is specifically configured to execute:

[0525] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0526] As an optional implementation, the data structure includes a hash data structure; the processor is specifically configured to execute:

[0527] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0528] As an optional implementation, the data structure includes an ordered set data structure; the processor is specifically configured to execute:

[0529] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0530] As an optional implementation, the data structure includes a linked list data structure; the processor is specifically configured to execute:

[0531] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0532] As an optional implementation, the processor is further configured to execute:

[0533] It is determined that the target data is stored in the cache service program;

[0534] The target data is read from the cache service program, and the target data is processed to obtain feedback data.

[0535] The feedback data is sent to the device connected to the Internet platform.

[0536] As an optional implementation, the IoT platform further includes a cache server; the processor is specifically configured to execute:

[0537] When the switching conditions are met, the switch between the cache service program and the cache server is executed.

[0538] As an optional implementation, the local storage resource includes a local database; the local database includes different types of databases; the processor is specifically configured to execute:

[0539] Within the local database, access operations are performed on the target data.

[0540] As an optional implementation, the processor is specifically configured to determine the local database in the following manner:

[0541] Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database.

[0542] By defining the operation method of the target database adapter, the operation method for the target database is set;

[0543] Based on the set target database, the local database is determined, wherein the local database includes the target database.

[0544] As an optional implementation, the processor is specifically configured to execute:

[0545] Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

[0546] Based on the same inventive concept, this disclosure also provides a data processing apparatus. Since this apparatus is the same as the apparatus in the method of this disclosure, and the principle of the apparatus in solving the problem is similar to that of the method, the implementation of the apparatus can refer to the implementation of the method, and the repeated parts will not be described again.

[0547] As shown in Figure 9, the device includes:

[0548] The data module 900 is used to determine the target data for the IoT platform.

[0549] The local cache module 901 is used to perform access operations on the target data within the local storage resources of the IoT platform.

[0550] As an optional implementation, the local storage resource includes local memory; the local cache module 901 is specifically used for:

[0551] In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

[0552] As an optional implementation, the caching service program includes a local memory-based storage component; the local caching module 901 is specifically used for:

[0553] The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

[0554] As an optional implementation, the cache service program is used to perform access operations on data with different data structures; and / or,

[0555] The key-value (KV) settings of the storage component of the cache service program have expiration times.

[0556] As an optional implementation, the local storage resource further includes a local file system; the local cache module 901 is specifically used for:

[0557] Store the target data in the cache service program to the local file system; and / or,

[0558] The target data is read from the local file system and stored in the cache service program.

[0559] As an optional implementation, the local cache module 901 is specifically used for:

[0560] Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; and / or,

[0561] Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

[0562] As an optional implementation, the caching service program is also used to provide publish / subscribe functionality and / or distributed locking functionality;

[0563] The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

[0564] As an optional implementation, the local caching module 901 is specifically used to provide publish / subscribe functionality in the following manner:

[0565] By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

[0566] As an optional implementation, the local caching module 901 is specifically used to determine the caching service program in the following manner:

[0567] Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory;

[0568] The cache service program is determined based on the target client settings.

[0569] As an optional implementation, the local cache module 901 is specifically used for:

[0570] By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

[0571] As an optional implementation, the data structure includes a hash data structure; the local cache module 901 is specifically used for:

[0572] By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

[0573] As an optional implementation, the data structure includes an ordered set data structure; the local cache module 901 is specifically used for:

[0574] By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

[0575] As an optional implementation, the data structure includes a linked list data structure; the local cache module 901 is specifically used for:

[0576] By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

[0577] As an optional implementation, the local cache module 901 is further configured to:

[0578] It is determined that the target data is stored in the cache service program;

[0579] The target data is read from the cache service program, and the target data is processed to obtain feedback data.

[0580] The feedback data is sent to the device connected to the Internet platform.

[0581] As an optional implementation, the IoT platform further includes a cache server; the local cache module 901 is specifically used for:

[0582] When the switching conditions are met, the switch between the cache service program and the cache server is executed.

[0583] As an optional implementation, the local storage resource includes a local database; the local database includes different types of databases; the local cache module 901 is specifically used for:

[0584] Within the local database, access operations are performed on the target data.

[0585] As an optional implementation, the local cache module 901 is specifically used to determine the local database in the following manner:

[0586] Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database.

[0587] By defining the operation method of the target database adapter, the operation method for the target database is set;

[0588] Based on the set target database, the local database is determined, wherein the local database includes the target database.

[0589] As an optional implementation, the local cache module 901 is specifically used for:

[0590] Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

[0591] Based on the same inventive concept, this disclosure provides a computer storage medium comprising: computer program code, which, when executed on a computer, causes the computer to perform any of the data processing methods described above. Since the principle by which the computer storage medium solves the problem is similar to that of the data processing method, the implementation of the computer storage medium can be referred to the implementation of the method, and repeated details will not be elaborated further.

[0592] In specific implementation, computer storage media can include: Universal Serial Bus Flash Drive (USB), portable hard drive, Read-Only Memory (ROM), Random Access Memory (RAM), magnetic disk or optical disk, and other storage media that can store program code.

[0593] Based on the same inventive concept, this disclosure also provides a computer program product, which includes computer program code that, when run on a computer, causes the computer to execute any of the data processing methods described above. Since the principle by which the above-described computer program product solves the problem is similar to that of the data processing method, the implementation of the above-described computer program product can be referred to the implementation of the method, and repeated details will not be elaborated further.

[0594] Computer program products may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0595] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0596] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more flowchart illustrations and / or one or more block diagrams.

[0597] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including an instruction device that implements the functions specified in one or more flowcharts and / or one or more block diagrams.

[0598] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.

[0599] Obviously, those skilled in the art can make various modifications and variations to this disclosure without departing from its spirit and scope. Therefore, if such modifications and variations fall within the scope of the claims of this disclosure and their equivalents, this disclosure is also intended to include such modifications and variations.

Claims

1. An Internet of Things (IoT) platform, wherein, The IoT platform includes a processor and a memory. The memory stores programs executable by the processor, and the processor reads the programs from the memory and performs the following steps: Identify the target data for the IoT platform; Access operations are performed on the target data within the local storage resources of the IoT platform.

2. The Internet of Things platform according to claim 1, wherein, The local storage resources include local memory; the processor is specifically configured to execute: In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

3. The Internet of Things platform according to claim 2, wherein, The caching service program includes a local memory-based storage component; the processor is specifically configured to execute: The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

4. The Internet of Things platform according to claim 2, wherein, The cache service program is used to perform access operations on data with different data structures; and / or, The key-value (KV) settings of the storage component of the cache service program have expiration times.

5. The Internet of Things platform according to claim 2, wherein, The local storage resources also include a local file system; the processor is further configured to execute: Store the target data in the cache service program to the local file system; and / or, The target data is read from the local file system and stored in the cache service program.

6. The Internet of Things platform according to claim 5, wherein, The processor is specifically configured to execute: Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; and / or, Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

7. The Internet of Things platform according to claim 2, wherein, The cache service program is also used to provide publish / subscribe functionality and / or distributed lock functionality; The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

8. The Internet of Things platform according to claim 7, wherein, The processor is specifically configured to execute: By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

9. The Internet of Things platform according to any one of claims 2 to 8, wherein, The processor is specifically configured to determine the cache service program in the following manner: Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory; The cache service program is determined based on the target client settings.

10. The Internet of Things platform according to claim 9, wherein, The processor is specifically configured to execute: By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

11. The Internet of Things platform according to claim 9, wherein, The data structure includes a hash data structure; the processor is specifically configured to execute: By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

12. The Internet of Things platform according to claim 9, wherein, The data structure includes an ordered set data structure; the processor is specifically configured to execute: By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

13. The Internet of Things platform according to claim 9, wherein, The data structure includes a linked list data structure; the processor is specifically configured to execute: By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

14. The Internet of Things platform according to claim 2, wherein, The processor is further configured to execute: It is determined that the target data is stored in the cache service program; The target data is read from the cache service program, and the target data is processed to obtain feedback data. The feedback data is sent to the device connected to the Internet platform.

15. The Internet of Things platform according to claim 2, wherein, The IoT platform also includes a cache server; the processor is further configured to execute: When the switching conditions are met, the switch between the cache service program and the cache server is executed.

16. The Internet of Things platform according to claim 1, wherein, The local storage resources include a local database; the local database includes different types of databases; the processor is specifically configured to execute: Within the local database, access operations are performed on the target data.

17. The Internet of Things platform according to claim 16, wherein, The processor is specifically configured to determine the local database in the following manner: Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database. By defining the operation method of the target database adapter, the operation method for the target database is set; Based on the set target database, the local database is determined, wherein the local database includes the target database.

18. The Internet of Things platform according to claim 17, wherein, The processor is specifically configured to execute: Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

19. A data processing method, wherein, The method includes: Identify the target data for the IoT platform; Access operations are performed on the target data within the local storage resources of the IoT platform.

20. The method according to claim 19, wherein, The local storage resource includes local memory; within the local storage resource of the IoT platform, performing access operations on the target data includes: In the local memory cache service program, access operations are performed on the target data; wherein the cache service program is used to provide cache services.

21. The method according to claim 20, wherein, The caching service program includes a local memory-based storage component; the caching service program in the local memory performs access operations on the target data, including: The target data is stored in the storage component of the cache service program, and / or the target data is read from the storage component of the cache service program.

22. The method according to claim 20, wherein, The cache service program is used to perform access operations on data with different data structures; and / or, The key-value (KV) settings of the storage component of the cache service program have expiration times.

23. The method according to claim 20, wherein, The local storage resource further includes a local file system; the method further includes: Store the target data in the cache service program to the local file system; and / or, The target data is read from the local file system and stored in the cache service program.

24. The method according to claim 23, wherein, Using a serialization mechanism, the target data stored by the cache service program is serialized into a byte stream, and the byte stream is stored in the local file system; And / or, Using a deserialization mechanism, the byte stream in the local file system is deserialized into target data, and the target data is stored in the cache service program.

25. The method according to claim 20, wherein, The cache service program is also used to provide publish / subscribe functionality and / or distributed lock functionality; The publish / subscribe function is used to enable communication between various functional modules within the IoT platform; the distributed lock function... This is used to enable collaboration and synchronization of data between multiple devices connected to the Internet platform.

26. The method of claim 25, wherein, The publish / subscribe functionality can be provided in the following ways: By defining the PubSub structure, defining methods for publishing messages to a specified channel, and defining methods for subscribing to a specified channel, the publish / subscribe functionality of the caching service program is configured.

27. The method according to any one of claims 20 to 26, wherein, The cache service program is determined in the following manner: Create a target client that conforms to the cache client interface definition, and configure the target client to perform access operations on data of at least one data structure in the local memory; The cache service program is determined based on the target client settings.

28. The method according to claim 27, wherein, Creating a target client that conforms to the cache client interface definition includes: By utilizing the client factory class of the IoT platform and the caching pattern defined in the IoT platform's program configuration file, a target client that conforms to the caching client interface definition is created.

29. The method according to claim 27, wherein, The data structure includes a hash data structure; the setting of the target client to perform access operations on data of at least one data structure in the local memory includes: By calling the HSet method, the target client is configured to perform access operations on the hash data in its local memory.

30. The method according to claim 27, wherein, The data structure includes an ordered set data structure; the setting of the target client to perform access operations on data of at least one data structure in the local memory includes: By defining the structure of the ordered set and the method for accessing the data in the ordered set, the target client is configured to perform access operations on the data in the ordered set in the local memory.

31. The method according to claim 27, wherein, The data structure includes a linked list data structure; the setting of the target client to perform access operations on data of at least one data structure in the local memory includes: By defining the access method for data in a doubly linked list, the target client is configured to perform access operations on the linked list data in its local memory.

32. The method according to claim 20, wherein, The method further includes: It is determined that the target data is stored in the cache service program; The target data is read from the cache service program, and the target data is processed to obtain feedback data. The feedback data is sent to the device connected to the Internet platform.

33. The method according to claim 20, wherein, The IoT platform also includes a cache server; the method further includes: When the switching conditions are met, the switch between the cache service program and the cache server is executed.

34. The method according to claim 19, wherein, The local storage resource includes a local database; the local database includes different types of databases; the method further includes: Within the local database, access operations are performed on the target data.

35. The method according to claim 34, wherein, The local database is determined in the following manner: Based on an Object Relational Mapping (ORM) framework, a target database adapter is created, which is used to communicate with the target database. By defining the operation method of the target database adapter, the operation method for the target database is set; Based on the set target database, the local database is determined, wherein the local database includes the target database.

36. The method according to claim 35, wherein, The step of determining the local database based on the set target database includes: Based on the syntax of the ORM framework, the target database after the settings are performed to convert the syntax and obtain the local database.

37. An electronic device, wherein, The device includes a processor and a memory for storing a program executable by the processor, and the processor for reading the program in the memory and performing the steps of the method according to any one of claims 19 to 36.

38. A computer storage medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the steps of the method as described in any one of claims 19 to 36.

Citation Information

Patent Citations

  • Storage method and storage system for Internet of Things monitoring big data

    CN109495537A

  • Data storage and verification method of cold chain online temperature and humidity monitor

    CN112073477A

  • Vehicle management method and device of operation platform, electronic equipment and storage medium

    CN116110224A

  • Data processing method and device based on Internet of Things

    CN117768508A

  • Data interaction method, device and system and storage medium

    CN118413565A