Key value data storage method driven by multiple data sources in Android system
By defining standardized data source interfaces and multi-data source drivers on the Android platform, SharedPreferences' storage capacity, data type support and multi-threaded access problems are solved, providing a flexible, secure and efficient key-value data storage solution.
Patent Information
- Application Number
- CN202510471995.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-08-01
AI Technical Summary
SharedPreferences has problems such as limited storage capacity, insufficient data type support, poor security, and inconsistency of multi-thread access on the Android platform, and lacks flexibility and uniformity.
Define a standardized data source interface, supports multiple data source drivers, realizes encryption processing and multi-threaded secure access, simplify operations through unified interfaces and life cycle management, and provides flexible data storage solutions.
It improves storage efficiency and data access speed, enhances data security and system stability, adapts to different application scenarios, supports custom expansion, and ensures data consistency and reliability in high concurrency environments.
Smart Images

Figure CN120407650A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of key-value data storage, and particularly to a key-value data storage method driven by multiple data sources in an Android system. Background Art
[0002] As a simple and efficient data storage method, key-value data storage is widely used in mobile applications, embedded systems, and distributed environments, and is suitable for storing lightweight unstructured data such as application configurations, user settings, and cached data. On the Android platform, SharedPreferences is the most commonly used key-value storage tool, which can save the configuration information and user preference settings of an application in the form of "key-value" pairs.
[0003] Currently, SharedPreferences has some significant limitations in practical applications. First, it stores data based on XML files, which is suitable for storing a small amount of simple data, but as the amount of data increases, the performance and storage efficiency gradually decline. Second, SharedPreferences only supports the storage of basic data types and lacks direct support for complex data structures (such as sets or objects, etc.). Developers need to manually perform serialization and deserialization, which increases the development complexity. In addition, SharedPreferences lacks a built-in encryption mechanism, and the data is stored in plain text, posing potential security risks, especially when storing sensitive information. Finally, SharedPreferences is prone to data inconsistency problems in a multi-threaded environment and lacks native thread safety support, which may lead to data loss or reading errors during high-concurrency access.
[0004] Although there are some improvement solutions in the prior art, such as using SQLite databases, encrypted storage, etc., these methods are often independent solutions for specific problems and lack flexibility and unity. Therefore, there is an urgent need for a new storage tool that can provide higher storage flexibility, optimized performance, and security to solve many limitations in the prior art. Summary of the Invention
[0005] The present invention aims to provide a key-value data storage method driven by multiple data sources in an Android system, which solves the limitations of SharedPreferences in the prior art, especially its deficiencies in storage capacity, supported data types, security, and multi-threaded access.
[0006] To achieve the above object, the present invention provides the following method:
[0007] A key-value data storage method driven by multiple data sources in an Android system provided by the present invention is:
[0008] S1: By defining a standardized data source interface, clarify the basic functions that each data source should implement, and perform data storage, reading, deletion, and batch operations.
[0009] S2: According to the defined standardized data source standard interface, implement multiple common data source drivers. Through encapsulation and optimization of the built-in data sources, enable them to seamlessly access the unified interface of the tool, and provide multiple storage options with stable performance and convenient use for the application layer.
[0010] S3: Maintain instances of all available data sources, and dynamically allocate and switch data sources according to application requirements. By implementing a unified life cycle management and configuration interface, enable flexible combination and use of different data sources, and simplify the operation complexity of the application layer for multiple data sources.
[0011] S4: Implement encryption processing of data through an integrated encryption algorithm, and at the same time design a key management mechanism to ensure the security and performance of encryption operations. The key management mechanism adds encryption / decryption steps based on the configuration of data source operations.
[0012] S5: By implementing read-write locks and thread synchronization strategies, ensure the security and consistency when multiple threads access data simultaneously. Adopt a shared lock strategy to allow multiple threads to read data simultaneously, and adopt an exclusive lock to ensure the integrity of write operations. Support complex batch operations through a transaction mechanism, optimize the access efficiency in a multi-threaded environment, and ensure the accuracy of data.
[0013] Preferably, while performing the step of defining a standardized data source interface, clarifying the basic functions that each data source should implement, and performing data storage, reading, deletion, and batch operations, it further includes: monitoring the standardized data source interface; if it is detected that the data source interface receives a query instruction sent to at least one data source, determine whether the terminal account corresponding to the query instruction has query permission; if it does not have query permission, detect whether the query instruction contains target input parameters, where the target input parameters include ccif information and ecif information; if the query instruction contains target input parameters, generate monitoring data corresponding to the query instruction.
[0014] Preferably, determine the proprietary index results corresponding to the proprietary indexes among all the index results in the index result storage area of the data source standard interface; determine the proprietary exception rules among all the exception rules in the preset exception rule storage area, and detect whether the proprietary index results match the proprietary exception rules. If the proprietary index results match the proprietary exception rules, use the matching proprietary exception rules as the matching exception rules.
[0015] Preferably, the abnormal event includes a first abnormal event. The step of determining that there is an abnormal event in the target data source and outputting the abnormal alarm information corresponding to the abnormal event includes: determining the important abnormal rules among all the abnormal rules that are at the important level; if the matched abnormal rule matches the important abnormal rule, determining that there is a first abnormal event in the target data source, storing the first abnormal event in a preset abnormal event storage area, generating the abnormal alarm information corresponding to the first abnormal event, and outputting the abnormal alarm information corresponding to the first abnormal event.
[0016] Preferably, the abnormal event includes a second abnormal event. After the step of determining the important abnormal rules among all the abnormal rules that are at the important level, it includes: if the matched abnormal rule does not match the important abnormal rule, determining that there is a second abnormal event in the target data source, generating the abnormal alarm information corresponding to the second abnormal event, and outputting the abnormal alarm information corresponding to the second abnormal event.
[0017] Preferably, before the step of detecting whether the index results in the data source index result storage area match the abnormal rules in the preset abnormal rule storage area, it includes: determining the general indexes and proprietary indexes in the target data source; for the general indexes, setting general abnormal rules according to the interface type, data dimension, and general preset threshold of the data source interface; for the proprietary indexes, setting proprietary abnormal rules according to the data dimension and proprietary preset threshold; using the general abnormal rules and the proprietary abnormal rules as abnormal rules, setting different rule levels for different abnormal rules, and storing all the abnormal rules with set rule levels in a preset abnormal rule storage area, where the rule levels include the important level and the general level.
[0018] Preferably, after the step of maintaining all available data source instances, dynamically allocating and switching data sources according to application requirements, enabling flexible combination and use of different data sources through implementing a unified life cycle management and configuration interface, and simplifying the operation complexity of the application layer for multiple data sources, it further includes: this step also supports extending custom data sources through a standard interface, thereby improving the adaptation ability of the tool and its future scalability.
[0019] Preferably, after ensuring the security and consistency when multiple threads access data simultaneously by implementing a read-write lock and a thread synchronization strategy, adopting a shared lock strategy to allow multiple threads to read data simultaneously, adopting an exclusive lock to ensure the integrity of write operations, and supporting complex batch operations through a transaction mechanism to optimize the access efficiency in a multi-threaded environment and ensure the accuracy of data, the steps include: providing a simple and easy-to-use call interface for the application layer, hiding the complex implementation details at the bottom layer. The interface includes methods for adding, deleting, modifying, and querying data, supports the storage and retrieval of basic data types and complex data types, and provides thread-safe call guarantees and optional encryption configurations; the interface supports dynamic switching between multiple data sources and custom configurations, and storage operations can be completed without paying attention to the differences in the underlying data sources.
[0020] Preferably, after providing a simple and easy-to-use call interface for the application layer and hiding the complex implementation details at the bottom layer, the steps further include: improving the running efficiency of the tool through a performance optimization and data consistency guarantee mechanism; the performance optimization includes cache design for data access and storage operations, improvement of the efficiency of batch operations, and optimization of IO operations to reduce latency and resource consumption during the storage process; data consistency is guaranteed through transaction management and a write log mechanism to ensure that data will not be lost or damaged in the event of a power outage, abnormal interruption, or concurrent write scenario; overall performance is further improved while ensuring consistency by introducing a deferred write and dirty data refresh strategy.
[0021] Preferably, receive the data to be sent at the current moment from a data source interface; in the case where the first data in the data to be sent at the current moment fails to be sent, store the first data in a database, where the first data is at least part of the data to be sent at the current moment; the database is further configured to receive data from the data source interface after storing the first data; in the case where the amount of unsent data stored in the database is greater than or equal to a preset data amount, read a preset data amount of data from the unsent data stored in the database and send the read preset data amount of data to a target device; in the case where the amount of unsent data stored in the database is less than the preset data amount, read the unsent data stored in the database and send the unsent data to the target device.
[0022] The beneficial effects of the present invention are as follows: Through a key-value data storage architecture driven by multiple data sources, the present invention defines a standard data source interface and supports flexible switching among multiple data sources such as SQLite, mmap, and file storage, providing a more flexible storage solution than SharedPreferences. It can select the optimal data storage method according to different application scenarios, improving storage efficiency, data access speed, and adaptability. At the same time, it supports custom extension of new data sources, enhancing the scalability of the system; it implements a built-in data encryption mechanism, supports encryption processing of stored data, and provides a flexible key management scheme to ensure data security, avoid storing data in plain text, prevent leakage of sensitive information, improve the security of data storage, and is applicable to scenarios that require protecting user privacy or key business data without the need for developers to implement additional encryption logic, reducing security risks; it provides a multi-threaded secure access mechanism, optimizes concurrent read and write strategies, ensures data consistency and access efficiency in a high-concurrency environment, avoids problems such as data inconsistency and data loss that may occur when accessing SharedPreferences in a multi-threaded manner, provides stable and reliable concurrent read and write support, improves the reliability of data storage and the stability of the system, and is applicable to data storage requirements with multi-threaded and high-frequency access. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.
[0024] Figure 1 It is a schematic flow chart of a method for storing key-value data driven by multiple data sources in an Android system provided by an embodiment of the present invention;
[0025] Figure 2 It is a detailed operation flow schematic diagram of a method for storing key-value data driven by multiple data sources in an Android system provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] In order to enable those skilled in the art to better understand the solution of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0027] In the description, claims and the above drawings of the present invention, the terms "first", "second", etc. are used to distinguish different objects rather than to describe a specific order. In addition, the terms "comprise" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or terminal comprising a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally further include other steps or units inherent to these processes, methods, products or terminals.
[0028] Reference to "embodiment" herein means that a particular feature, structure or characteristic described in connection with the embodiment can be included in at least one embodiment of the present invention. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0029] Currently, SharedPreferences has some significant limitations in practical applications. First, it stores data based on XML files, which is suitable for storing a small amount of simple data. However, as the amount of data increases, the performance and storage efficiency gradually decline. Second, SharedPreferences only supports the storage of basic data types and lacks direct support for complex data structures (such as sets or objects, etc.). Developers need to manually perform serialization and deserialization, increasing the development complexity. In addition, SharedPreferences lacks a built-in encryption mechanism, and the data is stored in plain text, presenting potential security risks, especially when storing sensitive information. Finally, SharedPreferences is prone to data inconsistency problems in a multi-threaded environment and lacks native thread safety support, which may lead to data loss or read errors during high-concurrency access.
[0030] Although there have been some improvement solutions in the prior art, such as using SQLite databases, encrypted storage, etc., these methods are often independent solutions for specific problems and lack flexibility and unity. Therefore, there is an urgent need for a new storage tool that can provide higher storage flexibility, optimized performance and security to solve many limitations in the prior art.
[0031] The present invention aims to provide a key-value data storage method driven by multiple data sources in the Android system, which solves the limitations of SharedPreferences in the prior art, especially its deficiencies in storage capacity, supported data types, security and multi-threaded access.
[0032] Such as Figure 1 、Figure 2 As shown, a key-value data storage method driven by multiple data sources in an Android system is provided in a specific implementation manner of the present invention, including the following steps:
[0033] S1: By defining a standardized data source interface to clarify the basic functions that each data source should implement, perform data storage, reading, deletion, and batch operations.
[0034] In an embodiment of the present invention: while performing steps of storing, reading, deleting, and batch operating data by defining a standardized data source interface to clarify the basic functions that each data source should implement, it further includes: monitoring the standardized data source interface; if it is detected that the data source interface receives a query instruction sent to at least one data source, determining whether the terminal account corresponding to the query instruction has query permission; if it does not have query permission, detecting whether the query instruction contains target input parameters, where the target input parameters include ccif information and ecif information; if the query instruction contains the target input parameters, generating monitoring data corresponding to the query instruction; determining the proprietary index results corresponding to the proprietary indexes among all the index results in the index result storage area of the data source standard interface; determining the proprietary exception rules among all the exception rules in the preset exception rule storage area, and detecting whether the proprietary index results match the proprietary exception rules. If the proprietary index results match the proprietary exception rules, using the matching proprietary exception rules as the matching exception rules; the exception events include a first exception event. The step of determining that there is an exception event in the target data source and outputting the exception alarm information corresponding to the exception event includes: determining the important exception rules among all the exception rules that are at the important level; if the matching exception rules match the important exception rules, determining that there is a first exception event in the target data source, storing the first exception event in the preset exception event storage area, and generating the exception alarm information corresponding to the first exception event, and outputting the exception alarm information corresponding to the first exception event; the exception events include a second exception event. After the step of determining the important exception rules among all the exception rules that are at the important level, it includes: if the matching exception rules do not match the important exception rules, determining that there is a second exception event in the target data source, generating the exception alarm information corresponding to the second exception event, and outputting the exception alarm information corresponding to the second exception event; before the step of detecting whether the index results in the data source index result storage area match the exception rules in the preset exception rule storage area, it includes: determining the general indexes and proprietary indexes in the target data source; for the general indexes, setting general exception rules according to the interface type, data dimension, and general preset threshold of the data source interface; for the proprietary indexes, setting proprietary exception rules according to the data dimension and proprietary preset threshold; using the general exception rules and the proprietary exception rules as the exception rules, and setting different rule levels for different exception rules, and storing all the exception rules with the set rule levels in the preset exception rule storage area, where the rule levels include the important level and the general level.
[0035] S2: According to the defined standardized data source standard interface, implement various common data source drivers. By encapsulating and optimizing the built-in data sources, enable them to seamlessly access the unified interface of the tool, and provide multiple storage options with stable performance and convenient use for the application layer.
[0036] S3: Maintain instances of all available data sources, dynamically allocate and switch data sources according to application requirements. By implementing a unified lifecycle management and configuration interface, different data sources can be flexibly combined and used, and the operation complexity of the application layer for multi-data sources can be simplified.
[0037] In the embodiments of the present invention, it also supports extending custom data sources through standard interfaces, thereby improving the adaptation ability of the tool and future scalability.
[0038] S4: Implement data encryption processing through an integrated encryption algorithm, and at the same time design a key management mechanism to ensure the security and performance of encryption operations. The key management mechanism adds encryption / decryption steps based on the configuration of data source operations.
[0039] S5: Ensure the security and consistency when multiple threads access data simultaneously by implementing read-write locks and thread synchronization strategies. Adopt a shared lock strategy to allow multiple threads to read data simultaneously, and adopt an exclusive lock to ensure the integrity of write operations. Support complex batch operations through a transaction mechanism, optimize the access efficiency in a multi-threaded environment, and ensure the accuracy of data.
[0040] In the embodiments of the present invention: After ensuring the security and consistency when multiple threads access data simultaneously by implementing a read-write lock and a thread synchronization strategy, adopting a shared lock strategy to allow multiple threads to read data simultaneously, adopting an exclusive lock to ensure the integrity of write operations, and supporting complex batch operations through a transaction mechanism to optimize the access efficiency in a multi-threaded environment and ensure the accuracy of data, the following steps are included: providing a simple and easy-to-use call interface for the application layer to shield complex underlying implementation details. The interface includes methods for adding, deleting, modifying, and querying data, supports the storage and access of basic data types and complex data types, and provides thread-safe call guarantees and optional encryption configurations; the interface supports dynamic switching between multiple data sources and custom configurations, and storage operations can be completed without paying attention to the differences in underlying data sources; after providing a simple and easy-to-use call interface for the application layer to shield complex underlying implementation details, the following steps are further included: improving the running efficiency of the tool through a performance optimization and data consistency guarantee mechanism; performance optimization includes cache design for data storage and access operations, improvement of batch operation efficiency, and optimization of IO operations to reduce latency and resource consumption during storage; data consistency is guaranteed through transaction management and a write log mechanism to ensure that data will not be lost or damaged in the event of a power outage, abnormal interruption, or concurrent write scenario; overall performance is further improved while ensuring consistency by introducing a delayed write and dirty data refresh strategy; receiving data to be sent at the current moment from a data source interface; in the case where the first data in the data to be sent at the current moment fails to be sent, storing the first data in a database, where the first data is at least part of the data to be sent at the current moment; the database is further used to receive data from the data source interface after storing the first data; in the case where the amount of unsent data stored in the database is greater than or equal to a preset data amount, reading a preset data amount of data from the unsent data stored in the database and sending the read preset data amount of data to a target device; in the case where the amount of unsent data stored in the database is less than the preset data amount, reading the unsent data stored in the database and sending the unsent data to the target device. Specific embodiments:
[0042] Step S01: Define a standard data source interface
[0043] Function: Define a unified standard data source interface to standardize the functions and behaviors of different data sources and ensure that each data source can be accessed and operated in a consistent manner.
[0044] Description: By defining a standardized data source interface, the basic functions that each data source should implement are clarified, such as data storage, reading, deletion, and batch operations. This interface serves as the core abstraction layer of the tool, shielding underlying storage details, providing a unified call entry for upper-level modules, and providing standardized support for subsequent expansion of new data sources.
[0045] Step S02: Implement built-in data sources
[0046] Function: Implement support for multiple built-in data sources (such as SQLite, mmap, file storage) to meet data storage requirements in different scenarios and enhance the flexibility and applicability of the tool.
[0047] Description: According to the defined standard interface of data sources, implement multiple common data source drivers. SQLite database storage is suitable for structured data and medium-capacity requirements, mmap memory-mapped files are suitable for efficient random access scenarios, and file storage is suitable for lightweight unstructured data storage. Through the encapsulation and optimization of these built-in data sources, they can be seamlessly connected to the unified interface of the tool, providing multiple storage options with stable performance and convenient use for the application layer.
[0048] Step S03: Implement a data source management module
[0049] Function: Manage and coordinate the use of multiple data sources, providing the ability of dynamic switching, unified configuration, and extension support to ensure the efficient operation and flexible use of data sources.
[0050] Description: The data source management module is responsible for maintaining instances of all available data sources and dynamically allocating and switching data sources according to application requirements. It simplifies the operation complexity of the application layer for multiple data sources by implementing a unified lifecycle management and configuration interface. In addition, this module supports extending custom data sources through a standard interface, thereby improving the adaptability of the tool and its future scalability.
[0051] Step S04: Implement data encryption functionality
[0052] Function: Ensure the security of stored data, protect sensitive information through an encryption mechanism, and prevent data from being stolen or tampered with during storage and transmission.
[0053] Description: The data encryption functionality provides transparent encryption support for stored data, including encrypted storage and decrypted reading. This function implements data encryption through the integration of common encryption algorithms (such as AES or RSA), and at the same time designs a key management mechanism to ensure the security and performance of encryption operations. Developers can choose to enable or disable the encryption function, and the tool will add encryption / decryption steps based on data source operations according to the configuration, providing additional security protection for sensitive stored data.
[0054] Step S05: Implement a multi-threaded secure access mechanism
[0055] Function: Ensure the security of concurrent access to stored data in a multi-threaded environment, and avoid data competition, data loss, or inconsistent situations.
[0056] Description: The multi-threaded secure access mechanism ensures the security and consistency when multiple threads access data simultaneously by implementing strategies such as read-write locks and thread synchronization. For read operations, a shared lock strategy is adopted, allowing multiple threads to read data simultaneously; for write operations, an exclusive lock is used to ensure the integrity of write operations. Meanwhile, a transaction mechanism is designed to support complex batch operations, avoiding data integrity issues caused by mid-operation failures. This mechanism optimizes the access efficiency in a multi-threaded environment while ensuring data accuracy, and is applicable to high-concurrency scenarios.
[0057] Step S06: Implement the application layer call interface
[0058] Function: Provide a simple and easy-to-use call interface for the application layer, shielding complex underlying implementation details, enabling developers to efficiently operate data storage in a unified manner.
[0059] Description: The application layer call interface is the entry point for interaction between the tool and developers. Its design follows the usage habits of SharedPreferences and extends its functions. The interface includes methods for adding, deleting, modifying, and querying data, supporting the storage and retrieval of basic data types and complex data types. At the same time, it provides thread-safe call guarantees and optional encryption configurations. In addition, the interface supports dynamic switching between multiple data sources and custom configurations, allowing developers to complete storage operations without concerning about differences in underlying data sources. This design significantly reduces the learning cost for developers and improves the applicability and usability of the tool.
[0060] Step S07: Implement the performance optimization and data consistency guarantee mechanism
[0061] Function: Through the performance optimization and data consistency guarantee mechanism, improve the running efficiency of the tool, ensuring the accuracy and stability of data operations in high-concurrency scenarios.
[0062] Description: Performance optimization mainly includes cache design for data access and storage operations, efficiency improvement of batch operations, and optimization of IO operations to reduce latency and resource consumption during the storage process. Meanwhile, data consistency guarantee is achieved through mechanisms such as transaction management and Write-Ahead Logging (WAL), ensuring that data will not be lost or damaged in scenarios such as power outages, abnormal interruptions, or concurrent writes. In addition, the tool also introduces strategies for delayed writing and dirty data flushing to further improve overall performance while ensuring consistency. These optimization measures provide reliable support for the tool in resource-constrained devices or environments with high-concurrency requirements.
[0063] The beneficial effects of the present invention are reflected in that: through a key-value data storage architecture driven by multiple data sources, the present invention defines a standard data source interface and supports flexible switching between multiple data sources such as SQLite, mmap, and file storage, providing a more flexible storage solution than SharedPreferences. It can select the optimal data storage method according to different application scenarios, improve storage efficiency, data access speed, and adaptability. At the same time, it supports custom extension of new data sources to enhance the scalability of the system; it implements a built-in data encryption mechanism, supports encryption processing of stored data, and provides a flexible key management scheme to ensure data security, avoid storing data in plain text, prevent leakage of sensitive information, improve the security of data storage, and is applicable to scenarios that require protecting user privacy or critical business data without the need for developers to implement additional encryption logic, reducing security risks; it provides a multi-threaded secure access mechanism, optimizes concurrent read and write strategies, ensures data consistency and access efficiency in a high-concurrency environment, avoids problems such as data inconsistency and data loss that may occur when accessing SharedPreferences in a multi-threaded manner, provides stable and reliable concurrent read and write support, improves the reliability of data storage and the stability of the system, and is applicable to data storage requirements with multi-threaded and high-frequency access.
[0064] The above are only embodiments of the present invention. Specific technical solutions or common knowledge such as well-known features are not described in detail herein; it should be noted that for those skilled in the art, without departing from the scope of the present invention, several modifications and improvements can be made, which should also be regarded as the protection scope of the present invention, and these will not affect the effects of the present invention and the practicality of the patent. The protection scope required by this application shall be subject to the content of its claims, and the specific implementation manners described in the specification can be used to interpret the content of the claims.
Claims
1. A key-value data storage method driven by multiple data sources in the Android system, characterized in that The method includes: S1: By defining a standardized data source interface, clarify the basic functions that each data source should implement, and perform data storage, reading, deletion, and batch operations. S2: According to the defined standardized data source standard interface, implement multiple common data source drivers. Through encapsulation and optimization of the built-in data sources, enable them to seamlessly access the unified interface of the tool, and provide multiple storage options with stable performance and convenient use for the application layer. S3: Maintain instances of all available data sources, and dynamically allocate and switch data sources according to application requirements. By implementing a unified life cycle management and configuration interface, enable flexible combination and use of different data sources, and simplify the operation complexity of the application layer for multiple data sources. S4: Implement encryption processing of data through an integrated encryption algorithm, and at the same time design a key management mechanism to ensure the security and performance of encryption operations. The key management mechanism adds encryption / decryption steps based on the configuration of data source operations. S5: By implementing read-write locks and thread synchronization strategies, ensure the security and consistency when multiple threads access data simultaneously. Adopt a shared lock strategy to allow multiple threads to read data simultaneously, and adopt an exclusive lock to ensure the integrity of write operations. Support complex batch operations through a transaction mechanism, optimize the access efficiency in a multi-threaded environment, and ensure the accuracy of data.
2. The method for storing key-value data driven by multiple data sources in an Android system according to claim 1, wherein When performing the step of defining a standardized data source interface, clarifying the basic functions that each data source should implement, and performing data storage, reading, deletion, and batch operations, it further includes: Monitor the standardized data source interface. If it is detected that the data source interface receives a query instruction sent to at least one data source, determine whether the terminal account corresponding to the query instruction has query permission. If it does not have query permission, detect whether the query instruction contains target input parameters, where the target input parameters include ccif information and ecif information. If the query instruction contains target input parameters, generate monitoring data corresponding to the query instruction.
3. The key-value data storage method for multi-data source drivers in an Android system according to claim 2, characterized in that: Determine the proprietary index results corresponding to the proprietary indexes among all the index results in the index result storage area of the data source standard interface. Determine the proprietary exception rules among all the exception rules in the preset exception rule storage area, and detect whether the proprietary index results match the proprietary exception rules. If the proprietary index results match the proprietary exception rules, use the matching proprietary exception rules as the matching exception rules.
4. A key-value data storage method driven by multiple data sources in an Android system according to claim 2, characterized in that, The exception event includes a first exception event. The step of determining that there is an exception event in the target data source and outputting the exception warning information corresponding to the exception event includes: Determine the important exception rules among all the exception rules that are at the important level. If the matched abnormal rule and the important abnormal rule match, it is determined that there is a first abnormal event in the target data source, the first abnormal event is stored in a preset abnormal event storage area, and abnormal alarm information corresponding to the first abnormal event is generated and the abnormal alarm information corresponding to the first abnormal event is output.
5. A key-value data storage method driven by multiple data sources in an Android system according to claim 2, characterized in that, The abnormal event includes a second abnormal event. After the step of determining the important abnormal rules with important levels among all the abnormal rules, it includes: If the matched abnormal rule and the important abnormal rule do not match, it is determined that there is a second abnormal event in the target data source, abnormal alarm information corresponding to the second abnormal event is generated, and the abnormal alarm information corresponding to the second abnormal event is output.
6. The method for storing key-value data driven by multiple data sources in an Android system according to claim 2, characterized in that: Before the step of detecting whether the index result in the data source index result storage area matches the abnormal rule in the preset abnormal rule storage area, it includes: Determine the general index and the proprietary index in the target data source; For the general index, set general abnormal rules according to the interface type, data dimension and general preset threshold of the data source interface; For the proprietary index, set proprietary abnormal rules according to the data dimension and proprietary preset threshold; Use the general abnormal rule and the proprietary abnormal rule as abnormal rules, set different rule levels for different abnormal rules, and store all the abnormal rules with set rule levels in a preset abnormal rule storage area, where the rule levels include important levels and general levels.
7. A key-value data storage method driven by multiple data sources in an Android system according to claim 1, characterized in that, After the step of maintaining instances of all available data sources, dynamically allocating and switching data sources according to application requirements, and enabling flexible combination and use of different data sources by implementing a unified lifecycle management and configuration interface, and simplifying the operation complexity of the application layer for multiple data sources, it further includes: This step also supports extending custom data sources through standard interfaces, thereby improving the adaptation ability of the tool and future scalability.
8. A method for storing key-value data driven by multiple data sources in an Android system according to any one of claims 1-7, characterized in that, After the step of ensuring the security and consistency when multiple threads access data simultaneously by implementing read-write locks and thread synchronization strategies, adopting a shared lock strategy to allow multiple threads to read data simultaneously, and adopting an exclusive lock to ensure the integrity of write operations and supporting complex batch operations through a transaction mechanism to optimize the access efficiency in a multi-threaded environment and ensure the accuracy of data, it includes: Provide a simple and easy-to-use call interface for the application layer, shielding the complex implementation details at the bottom layer. The interface includes methods for adding, deleting, modifying and querying data, supports the access of basic data types and complex data types, and provides thread-safe call guarantees and optional encryption configurations; The interface supports dynamic switching and custom configuration of multiple data sources, and storage operations can be completed without paying attention to the differences of underlying data sources.
9. A key-value data storage method driven by multiple data sources in an Android system according to claim 8, characterized in that, After the step of providing a simple and easy-to-use call interface for the application layer and shielding the complex implementation details at the bottom layer, it further includes: Improve the operation efficiency of the tool through performance optimization and data consistency guarantee mechanisms; The performance optimization includes cache design for data access operations, efficiency improvement of batch operations, and optimization of IO operations to reduce latency and resource consumption during storage; Data consistency is ensured through transaction management and a write log mechanism to prevent data loss or corruption in the event of power failure, abnormal interruption, or concurrent writing scenarios; By introducing a delayed write and dirty data refresh strategy, the overall performance is further enhanced while ensuring consistency.
10. A key-value data storage method driven by multiple data sources in an Android system according to any one of claims 1-7, characterized in that, It includes: Receiving the data to be sent at the current moment from the data source interface; In the case where the first data among the data to be sent at the current moment fails to be sent, storing the first data in the database, where the first data is at least part of the data to be sent at the current moment; the database is further configured to receive data from the data source interface after storing the first data; When the amount of unsent data stored in the database is greater than or equal to a preset data volume, reading a preset data volume of data from the unsent data stored in the database and sending the read preset data volume of data to the target device; When the amount of unsent data stored in the database is less than the preset data volume, reading the unsent data stored in the database and sending the unsent data to the target device.
Citation Information
Patent Citations
Data processing method and device, equipment and medium
CN116455975A
Big data workbench for intelligent operation and maintenance
CN117131034A
Data packet processing method and device and smart home system
CN117440432A
Data source management method and device, equipment and storage medium
CN117632649A
Method and device for realizing unified access of heterogeneous data sources
CN118312551A