Data hybrid storage method and device and computer equipment
By adopting a data hybrid storage method in the memory database of the power acquisition terminal, using the data change notification mechanism asynchronously update the memory database, and prioritizing the query of the memory database, the problem of low data storage and query efficiency of the power acquisition terminal is solved, and load balancing and performance improvement is achieved.
Patent Information
- Application Number
- CN202510181291.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-03-18
AI Technical Summary
The data storage and query efficiency of the power acquisition terminal is low, resulting in load imbalance and performance bottlenecks in relational databases when querying data.
The data mixed storage method of the in-memory database is adopted, and the in-memory database is updated asynchronously through the data change notification mechanism, and the in-memory database is queried first. If it is not queried, it will switch to the main database for retrieval.
Load balancing is realized, the load on the main database is reduced, the number of accesses to the main database is solved, and the performance bottleneck of relational databases is solved when querying batch data.
Smart Images

Figure CN119646001A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage in power collection terminals, and in particular to a method, a device and a computer device for hybrid data storage. Background Art
[0002] With the continuous development of low-voltage electricity information collection technology, the system resources of power collection terminals are becoming more and more abundant. At the same time, in order to improve the real-time monitoring of the operation status of the power grid, achieve accurate load forecasting and timely fault warning, power companies have also put forward higher requirements for the timeliness of data reporting by collection terminals and the data processing capabilities of edge computing. Since the new power collection terminal specification adopts an APP solution, while improving the reliability of the entire power system, it also causes a decline in system performance, making it difficult to meet the power company's requirements for more efficient and accurate collection and edge computing.
[0003] At present, power collection terminal data centers generally use relational databases to store and manage collected data, mainly in the following aspects: Message communication and low retrieval efficiency: The data center based on relational database has low efficiency in asynchronous data retrieval.
[0004] Load imbalance: As a data aggregation node, the acquisition terminal often needs to process a large amount of data at the same time when responding to the data call of the main station, while the system is idle most of the time.
[0005] Relational databases are unable to meet the requirements of complex applications for data timeliness and high-concurrency access. For example, if users require data to be "reported immediately after collection" or "incrementally reported", this is difficult to achieve in an APP-based distributed terminal system, causing performance bottlenecks in relational databases when querying data. Summary of the invention
[0006] In view of this, the present invention provides a method, apparatus and computer device for hybrid data storage to solve the problems of load imbalance and performance bottleneck of relational databases during data query.
[0007] In a first aspect, the present invention provides a method for hybrid data storage, which is applied to a memory database, and the method comprises: When the meter reading data is written into the main database of the power collection terminal, the data change notification sent by the main database is received; Based on the data change notification, the meter reading data is recorded into the data cache in a key-value manner; the key value includes the data type, data ID and data storage time of the meter reading data; Based on the preset data retrieval requirements, the corresponding meter reading data in the data cache is queried first. If no data is found, the data is switched to the main database to continue data retrieval.
[0008] The present invention provides a data hybrid storage method, which uses a memory database mechanism to save the current meter reading data of the system. When storing data, the data is written into the main database, and the data change notification mechanism of the main database is used to update the memory database with an asynchronous update strategy to achieve data synchronization between the memory database and the main database, thereby avoiding a large amount of data accessing the main database at the same time, thereby reducing the load of the main database and achieving load balancing. When retrieving data, the memory database is queried first, and when the memory database cannot be found, it is switched to the main database for retrieval, which greatly reduces the number of accesses to the main database and solves the performance bottleneck of batch data query in relational databases.
[0009] In an optional implementation, recording meter reading data into a data cache in a key-value manner based on a data change notification includes: Divide meter reading data into data types according to data real-time performance, and obtain the data ID and data storage time of meter reading data; The meter reading data is recorded in the data buffer based on the data type, data ID and data storage time.
[0010] The present invention provides a method for hybrid data storage, in which a memory database uses a key value mechanism to cache data, wherein the key value consists of a data type, a data ID, and a storage time, so as to facilitate efficient synchronization with a main database.
[0011] In an optional implementation, the method for hybrid data storage further includes: The meter reading data is divided according to different measurement points of the power collection terminal, and the meter reading data of each measurement point is managed by a data management block of a self-balancing binary tree.
[0012] In an optional implementation, a data management block of a self-balancing binary tree is used to perform data management, including: The data management block is set up to include the data type of meter reading data, data ID, storage records of different data types and access information; The data type, data ID, storage records of different data types and access information of meter reading data are organized into a tree structure based on a self-balancing binary tree, and the meter reading data is managed according to the tree structure.
[0013] The present invention provides a method for mixed data storage, which divides meter reading data according to different measurement points, and each measurement point independently maintains a data management block. The data management block includes the address of each tree, storage records of different types of data, access information, etc., which facilitates application programs to access data and can support data statistics services.
[0014] In an optional implementation, based on the preset data retrieval requirements, the corresponding meter reading data in the data cache is preferentially queried, and if no data is found, the data is switched to the main database to continue the data retrieval, including: If corresponding meter reading data is found in the data cache based on the preset data retrieval requirements, the meter reading data is loaded into the data cache; If the corresponding meter reading data is not found when switching to the main database for data retrieval, the corresponding meter reading data will be marked as query failure.
[0015] The present invention provides a data hybrid storage method. When corresponding meter reading data is queried in a data cache based on a preset data retrieval requirement, the meter reading data is loaded into the data cache. If the corresponding meter reading data is not queried when switching to a main database for data retrieval, the corresponding meter reading data is marked as a query failure, thereby avoiding a large number of simultaneous accesses to the main database, resulting in resource shortages and performance degradation, thereby reducing the load on the main database and achieving load balancing.
[0016] In an optional implementation, the method for hybrid data storage further includes: Based on the different access hotspots of data types at different measurement points of the power collection terminal, a timeout recovery mechanism of periodic management and lazy deletion is used to recycle the data cache.
[0017] The present invention provides a method for hybrid data storage, in which the memory database automatically maintains the data cache according to the resource situation of the power collection terminal, and adopts a timeout recovery mechanism to release the memory space that is no longer used. The dual mechanism of periodic management and lazy deletion ensures the reasonable use of memory resources and avoids leakage and waste of resources of the memory database.
[0018] In a second aspect, the present invention provides a method for hybrid data storage, which is applied to a main database, and the method comprises: Write the meter reading data of the electric energy meter and send a data change notification to the memory database, so that the memory database records the meter reading data into the data cache of the memory database in a key-value manner based on the data change notification; the key value includes the data type, data ID and data storage time of the meter reading data; If the corresponding meter reading data is not found in the data cache of the memory database based on the preset data retrieval requirement, the data retrieval continues according to the preset data retrieval requirement.
[0019] In a third aspect, the present invention provides a device for hybrid data storage, which is applied to a memory database, and the device includes: A change notification receiving module is used to receive a data change notification sent by the main database when the meter reading data of the electric energy meter is written into the main database of the electric power collection terminal; A data recording module is used to record meter reading data into a data cache in a key-value manner based on data change notification; the key value includes the data type, data ID and data storage time of the meter reading data; The first data retrieval module is used to preferentially query the corresponding meter reading data in the data cache based on the preset data retrieval requirements, and if no corresponding meter reading data is found, switch to the main database to continue the retrieval.
[0020] In a fourth aspect, the present invention provides a device for hybrid data storage, which is applied to a main database, and includes: A change notification sending module is used to write the meter reading data of the electric energy meter and send a data change notification to the memory database, so that the memory database records the meter reading data into the data cache of the memory database in a key-value manner based on the data change notification; The second data retrieval module is used to continue to perform data retrieval according to the preset data retrieval requirement if the corresponding meter reading data is not found in the data cache of the memory database based on the preset data retrieval requirement.
[0021] In a fifth aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method for data hybrid storage of the first aspect or any corresponding embodiment thereof or the method for data hybrid storage of the second aspect by executing the computer instructions.
[0022] In a sixth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for data hybrid storage of the first aspect or any corresponding embodiment thereof or to execute the method for data hybrid storage of the second aspect.
[0023] In a seventh aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the method for data mixing storage of the above-mentioned first aspect or any corresponding embodiment thereof, or to execute the method for data mixing storage of the above-mentioned second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1is a flow chart of a method for hybrid data storage according to an embodiment of the present invention; Figure 2 is a flow chart of another method for hybrid data storage according to an embodiment of the present invention; Figure 3 is a flow chart of another method for hybrid data storage according to an embodiment of the present invention; Figure 4 is a flow chart of yet another method for hybrid data storage according to an embodiment of the present invention; Figure 5 is a structural block diagram of a device for hybrid data storage according to an embodiment of the present invention; Figure 6 is a structural block diagram of a device for hybrid data storage according to an embodiment of the present invention; Figure 7 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0027] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0028] According to an embodiment of the present invention, a method embodiment of data hybrid storage is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] In this embodiment, a method for hybrid data storage is provided, which can be used for a memory database. Figure 1 is a flow chart of a method for hybrid data storage according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps: Step S101, when the meter reading data of the electric energy meter is written into the main database of the electric power collection terminal, a data change notification sent by the main database is received.
[0030] Specifically, the memory database refers to a local database that stores the meter reading data of the electric energy meter, which is stored in the form of data cache.
[0031] Meter reading data refers to the electric energy meter data collected by the power collection terminal, which can also be understood as electricity consumption information data. The master database is a relational database used by the power collection terminal for data storage and management, such as the latest version of the terminal data center. A relational database refers to a database based on a relational model that uses tables (or relations) to store and represent data. Each table contains multiple rows of data records and multiple columns, and the relationship between tables is established through primary keys and foreign keys. A relational database has a unified data structure and supports complex relationships such as many-to-many and one-to-many.
[0032] The data change notification mechanism is an APP responsible for data storage management and data services based on the data storage APP of the power collection terminal. When data changes occur, the main database sends data change notifications to the memory database through the internal message bus.
[0033] Step S102: Based on the data change notification, the meter reading data is recorded in the data cache in a key value manner; the key value includes the data type, data ID and data storage time of the meter reading data.
[0034] Specifically, in the database, the key value is used to uniquely identify and retrieve data records. The above-mentioned memory database is also called a key-value database, which is a data storage system based on key-value pairs. It uses a unique key to represent data and values, and there is no fixed structure or pattern between the key and the value. The key-value database is suitable for storing simple data structures and large-scale distributed systems. The key value in this embodiment can be written as Key-Value. The specific content of Key-Value consists of data type, data ID and data storage time. The specific composition steps of the specific key value refer to the mature related technical content, which will not be repeated here.
[0035] Step S103: Based on the preset data retrieval requirements, the corresponding meter reading data in the data cache is preferentially queried. If no data is found, the data is switched to the main database to continue the data retrieval.
[0036] Specifically, the in-memory database is queried first during data retrieval. If the in-memory database cannot be found, the main database is switched to perform data retrieval.
[0037] The data hybrid storage method provided in this embodiment saves the current meter reading data of the system by adopting the mechanism of the memory database. When storing data, it is written into the main database, and the data change notification mechanism of the main database is used to update the memory database with an asynchronous update strategy to achieve data synchronization between the memory database and the main database, thereby avoiding a large amount of data accessing the main database at the same time, thereby reducing the load of the main database and achieving load balancing. When retrieving data, the memory database is queried first, and when the memory database cannot be found, it is switched to the main database for retrieval, which greatly reduces the number of accesses to the main database and solves the performance bottleneck of batch data query in relational databases.
[0038] In this embodiment, a method for hybrid data storage is provided, which can be used for a memory database. Figure 2 is a flow chart of a method for hybrid data storage according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps: Step S201: When the meter reading data of the electric energy meter is written into the main database of the electric power collection terminal, a data change notification sent by the main database is received. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0039] Step S202: Based on the data change notification, the meter reading data is recorded into the data cache in a key-value manner; including the data type, data ID and data storage time of the meter reading data.
[0040] Specifically, the above step S202 includes: Step S2021, dividing the meter reading data into data types according to the real-time nature of the data, and obtaining the data ID and data storage time of the meter reading data.
[0041] Specifically, when the power collection terminal collects meter reading data from the energy meter, it will collect data in real time, including real-time data, minute frozen data, daily frozen data, and monthly frozen data. The data ID of the meter reading data refers to the address of the meter reading data, that is, the address of the power collection terminal corresponding to each meter reading data. The data storage time refers to the time corresponding to when the power collection terminal collects the meter reading data.
[0042] Step S2022: Record the meter reading data into the data cache based on the data type, data ID and data storage time.
[0043] Specifically, the in-memory database uses the data change notification of the main database to reversely query the main database. When data is written, the main database publishes a data change notification, and the in-memory database queries the main database based on the content of the data change notification and inserts the query results into the in-memory database, achieving efficient data synchronization with the main database.
[0044] Step S203, dividing the meter reading data according to different measuring points of the power collection terminal, wherein the meter reading data of each measuring point is managed by a data management block of a self-balancing binary tree.
[0045] Specifically, the above step S203 includes: Step S2031, setting the data management block includes the data type of the meter reading data, data ID, storage records of different data types and access information.
[0046] Specifically, in order to reduce the height of the self-balancing binary tree and improve data retrieval efficiency, the meter reading data is divided according to different measurement points of the power collection terminal, and each measurement point independently maintains a data management block. The data management block is recorded using a hash algorithm based on the information of each measurement point. The data management block includes the address of each tree, storage records of data of different data types, access information, etc., which facilitates application programs to access data.
[0047] Step S2032: The data type, data ID, storage records of different data types and access information of the meter reading data are organized into a tree structure based on a self-balancing binary tree, and data management is performed on the meter reading data according to the tree structure.
[0048] Specifically, the self-balancing binary tree is a special binary search tree that maintains the balance of the tree through rotation operations to ensure that the height difference between the left and right subtrees of each node does not exceed 1. It is an efficient data query and insertion algorithm. Based on the self-balancing binary tree, the data type, data ID, storage records of different data types and access information of the meter reading data are organized into a tree structure, and the meter reading data is managed according to the tree structure.
[0049] The self-balancing binary tree uses the Key-Value method to store the measurement point data. The Key content consists of data type + data ID + data time stamp. The data type, data ID, and data time stamp correspond to the data type, primary data ID, secondary data ID, and data storage time in the main database, respectively, to ensure data uniqueness and consistency.
[0050] The value is consistent with the data content in the main database. At the same time, the self-balancing binary tree records the data life cycle to facilitate data maintenance.
[0051] Step S204: Based on the preset data retrieval requirements, the corresponding meter reading data in the data cache is preferentially queried. If no data is found, the data is switched to the main database to continue data retrieval. Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0052] In the data hybrid storage method provided in this embodiment, the memory database uses a key value mechanism for data caching, where the key value consists of the data type, data ID and storage time, which facilitates efficient synchronization with the main database. The meter reading data is divided according to different measurement points, and each measurement point independently maintains a data management block. The data management block includes the address of each tree, storage records of different categories of data, access information and other contents, which facilitates the application to access the data and can support data statistics services.
[0053] In this embodiment, a method for hybrid data storage is provided, which can be used for a memory database. Figure 3 is a flow chart of a method for hybrid data storage according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps: Step S301: When the meter reading data of the electric energy meter is written into the main database of the electric power collection terminal, a data change notification sent by the main database is received. Figure 2 Step S201 of the illustrated embodiment will not be described in detail here.
[0054] Step S302: Based on the data change notification, the meter reading data is recorded in the data cache in a key value manner; the key value includes the data type, data ID and data storage time of the meter reading data. Figure 2 Step S202 of the illustrated embodiment will not be described in detail here.
[0055] Step S303: Based on the preset data retrieval requirements, the corresponding meter reading data in the data cache is preferentially queried. If no data is found, the data is switched to the main database to continue the data retrieval.
[0056] Specifically, the above step S303 includes: Step S3031: if corresponding meter reading data is found in the data cache based on the preset data retrieval requirement, the meter reading data is loaded into the data cache.
[0057] Specifically, the preset data retrieval requirements are set according to the actual needs of the user. When searching for data, the data cache is searched first. When the data cache query fails, the main database query is directly switched.
[0058] Step S3032: If the corresponding meter reading data is not found when switching to the main database for data retrieval, the corresponding meter reading data is marked as a query failure.
[0059] Specifically, if the required meter reading data is found in the main database, the meter reading data is loaded into the data cache. If the query still fails in the main database, a failure is returned and marked in the memory database to avoid returning to the main database when the query fails again.
[0060] Step S304 , based on the different access hotspots of data types at different measurement points of the power collection terminal, a timeout recovery mechanism of periodic management and lazy deletion is used to recycle the data cache.
[0061] Specifically, the access hotspots of different measurement point data types of the power collection terminal are different. For example, the access hotspot of daily frozen data is usually at most 1 day, and the access hotspot of monthly frozen data is 1 month. For different users, the access hotspot of minute frozen data may be the data of the most recent hour or the most recent day.
[0062] The power collection terminal can set the corresponding validity period of the data according to the data type and the characteristics of the user accessing the data. When the corresponding expiration period is exceeded, it means that the data in the data cache is no longer used, and such data will be deleted from the data cache to release the memory space that is no longer used, ensuring the reasonable use of memory resources, avoiding leakage and waste of resources in the memory database, and achieving the effect of regular management and lazy deletion.
[0063] The data hybrid storage method provided in this embodiment is to load the meter reading data into the data cache when the corresponding meter reading data is queried in the data cache based on the preset data retrieval requirements; if the corresponding meter reading data is not queried when switching to the main database for data retrieval, the corresponding meter reading data is marked as query failure, thereby avoiding a large number of simultaneous accesses to the main database, resulting in resource shortage and performance degradation, thereby reducing the load on the main database and achieving load balancing.
[0064] In this embodiment, a method for hybrid data storage is provided, which can be used for a main database. Figure 4 is a flow chart of a method for hybrid data storage according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps: Step S401, write the meter reading data of the electric energy meter and send a data change notification to the memory database, so that the memory database records the meter reading data into the data cache of the memory database in a key value manner based on the data change notification; the key value includes the data type, data ID and data storage time of the meter reading data.
[0065] Specifically, when the meter reading data of the electric energy meter is obtained, the meter reading data is written into the main database of the power collection terminal, and a data change notification is sent to the memory database. The memory database uses a key value method to record the meter reading data into the data cache of the memory database based on the data change notification. For details, please refer to Figure 2 Step S202 of the illustrated embodiment will not be described in detail here.
[0066] Step S402: if the corresponding meter reading data is not found in the data cache of the memory database based on the preset data retrieval requirement, data retrieval is continued according to the preset data retrieval requirement.
[0067] Specifically, the preset data retrieval requirements are set according to the actual needs of the user. When searching for data, the data cache is searched first. When the data cache query fails, the query is directly switched to the main database. If the required meter reading data is found in the main database, the meter reading data is loaded into the data cache. If the query still fails in the main database, the failure is returned and marked in the memory database to avoid returning to the main database when the query fails again.
[0068] The data hybrid storage method provided in this embodiment requires a large number of accesses to the main database at the same time when the user needs to query the integrity statistics of one or more measurement points for one day. Since the main database and the application use a synchronous communication mechanism, the load will increase significantly in a short period of time, the data response is slow and the real-time performance is poor. The memory database using the kev-value mechanism (key value mechanism) can quickly realize data statistics. If you only rely on the main database to implement the "instant data collection and reporting" function, it is difficult to ensure the real-time and efficiency of data reporting. Through the memory database of the kev-value mechanism, the newly added meter reading data is managed, and the application can access the newly added meter reading data in the memory database in real time. It only needs to dynamically complete the data packaging and reporting according to the reporting strategy.
[0069] In the present embodiment, a device for mixed data storage is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0070] This embodiment provides a device for hybrid data storage, which is applied to a memory database, such as Figure 5 As shown, including: The change notification receiving module 501 is used to receive a data change notification sent by the main database when the meter reading data of the electric energy meter is written into the main database of the electric power collection terminal.
[0071] The data recording module 502 is used to record the meter reading data into the data cache in a key value manner based on the data change notification; the key value includes the data type, data ID and data storage time of the meter reading data.
[0072] The first data retrieval module 503 is used to preferentially query the corresponding meter reading data in the data cache based on the preset data retrieval requirements, and switch to the main database to continue the retrieval if no corresponding meter reading data is found.
[0073] In some optional implementations, the data recording module 502 includes: The data division and acquisition unit is used to divide the meter reading data into data types according to the real-time nature of the data, and to obtain the data ID and data storage time of the meter reading data.
[0074] The data cache recording unit is used to record the meter reading data into the data cache based on the data type, data ID and data storage time.
[0075] In some optional implementations, the first data retrieval module 503 includes: The data loading unit is used to query the corresponding meter reading data in the data cache based on the preset data retrieval requirement, and then load the meter reading data into the data cache.
[0076] The data marking unit is used to mark the corresponding meter reading data as failed if no corresponding meter reading data is found when switching to the main database for data retrieval.
[0077] In some optional implementations, the device for hybrid data storage further includes: The data management module is used to divide the meter reading data according to different measurement points of the power collection terminal, wherein the meter reading data of each measurement point is managed by a data management block of a self-balancing binary tree.
[0078] The memory recycling module is used to recycle the data cache based on the different access hotspots of data types at different measurement points of the power collection terminal, using a timeout recycling mechanism of periodic management and lazy deletion.
[0079] In some optional implementations, the data management module includes: The data acquisition unit is used to set the data management block including the data type of meter reading data, data ID, storage records of different data types and access information.
[0080] The data management unit is used to form a tree structure based on a self-balancing binary tree, including the data type, data ID, storage records of different data types and access information of the meter reading data, and to manage the meter reading data according to the tree structure.
[0081] This embodiment also provides a device for mixed data storage, which is applied to a main database, such as Figure 6 As shown, including: The change notification sending module 601 is used to write the meter reading data of the electric energy meter and send a data change notification to the memory database, so that the memory database records the meter reading data into the data cache of the memory database in a key value manner based on the data change notification; the key value includes the data type, data ID and data storage time of the meter reading data.
[0082] The second data retrieval module 602 is used to continue to perform data retrieval according to the preset data retrieval requirement if the corresponding meter reading data is not found in the data cache of the memory database based on the preset data retrieval requirement.
[0083] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0084] The data hybrid storage device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0085] The embodiment of the present invention also provides a computer device having the above Figure 5 and Figure 6 The data shown is mixed storage device.
[0086] See also Figure 7 , Figure 7 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 7 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 7 A processor 10 is taken as an example.
[0087] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0088] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0089] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0090] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0091] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 7 The example of connecting through bus is taken in the following.
[0092] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device may be a touch screen.
[0093] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0094] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0095] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for hybrid data storage, characterized in that: Applied to an in-memory database, the method comprises: When the meter reading data of the electric energy meter is written into the main database of the electric power collection terminal, receiving the data change notification sent by the main database; Based on the data change notification, the meter reading data is recorded into the data cache in a key value manner; the key value includes the data type, data ID and data storage time of the meter reading data; Based on the preset data retrieval requirements, the corresponding meter reading data in the data cache is preferentially queried, and if no data is found, the data is switched to the main database to continue the data retrieval.
2. The method according to claim 1, characterized in that Based on the data change notification, the meter reading data is recorded into the data cache in a key-value manner, including: Divide the meter reading data into data types according to the real-time nature of the data, and obtain the data ID and data storage time of the meter reading data; The meter reading data is recorded in a data buffer based on the data type, data ID and data storage time.
3. The method according to claim 1, characterized in that The method further comprises: The meter reading data is divided according to different measuring points of the power collection terminal, wherein the meter reading data of each measuring point is managed by a data management block of a self-balancing binary tree.
4. The method according to claim 3, characterized in that The data management block using the self-balancing binary tree for data management includes: The data management block is set up to include the data type of meter reading data, data ID, storage records of different data types and access information; The data type, data ID, storage records of different data types and access information of the meter reading data are combined into a tree structure based on a self-balancing binary tree, and data management of the meter reading data is performed according to the tree structure.
5. The method according to claim 1, characterized in that The method of first querying the corresponding meter reading data in the data cache based on the preset data retrieval requirement, and if no meter reading data is found, switching to the main database to continue data retrieval, includes: If corresponding meter reading data is found in the data cache based on a preset data retrieval requirement, the meter reading data is loaded into the data cache; If the corresponding meter reading data is not found when switching to the main database for data retrieval, the corresponding meter reading data will be marked as query failure.
6. The method according to claim 1, characterized in that The method further comprises: Based on the different access hotspots of data types at different measurement points of the power collection terminal, a timeout recovery mechanism of periodic management and lazy deletion is used to recycle the data cache.
7. A method for hybrid data storage, characterized in that: Applied to the main database, the method comprises: Write the meter reading data of the electric energy meter, and send a data change notification to the memory database, so that the memory database records the meter reading data into the data cache of the memory database in a key value manner based on the data change notification; the key value includes the data type, data ID and data storage time of the meter reading data; If the corresponding meter reading data is not found in the data cache of the memory database based on the preset data retrieval requirement, the data retrieval continues according to the preset data retrieval requirement.
8. A device for mixed data storage, characterized in that: Applied to an in-memory database, the device comprises: A change notification receiving module, used to receive a data change notification sent by the main database when the meter reading data of the electric energy meter is written into the main database of the electric power collection terminal; A data recording module, used to record the meter reading data into a data cache in a key value manner based on the data change notification; the key value includes a data type, a data ID and a data storage time of the meter reading data; The first data retrieval module is used to preferentially query the corresponding meter reading data in the data cache based on a preset data retrieval requirement, and switch to the main database to continue searching if no corresponding meter reading data is found.
9. A device for mixed data storage, characterized in that: Applied to a main database, the device comprises: A change notification sending module is used to write the meter reading data of the electric energy meter and send a data change notification to the memory database, so that the memory database records the meter reading data into the data cache of the memory database in a key value manner based on the data change notification; the key value includes the data type, data ID and data storage time of the meter reading data; The second data retrieval module is used to continue to perform data retrieval according to the preset data retrieval requirement if the corresponding meter reading data is not found in the data cache of the memory database based on the preset data retrieval requirement.
10. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for mixed data storage according to any one of claims 1 to 6 or the method for mixed data storage according to claim 7 by executing the computer instructions.
Citation Information
Patent Citations
High-concurrency database access method and method applied to multi-server system
CN103246696A
Method for synchronizing memory bank and relation bank of power grid monitoring system based on feature marks
CN113360571A
Multi-level distributed cache system and method
CN113420052A
Storage method and system based on low-voltage transformer area meter reading data, medium and equipment
CN117453695A
Data caching method and system, electronic equipment and storage medium
CN117971898A
Cited By
Intelligent fusion terminal meter reading data storage and retrieval method and system
CN122527137A