Data reading method and device, storage medium, electronic equipment and vehicle
By using the cache area to transmit messages between multiple threads and determine the existence of data, the problem of low data reading efficiency caused by database files not being shared between processes is solved, the cache area and the database are updated synchronously, and data reading is improved. speed.
Patent Information
- Application Number
- CN202410685472.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-24
AI Technical Summary
During the data reading process, the same database file is not shared between processes, resulting in slow database opening and synchronization speeds, which in turn results in low data reading efficiency.
By using the cache area to transfer target messages between multiple threads, it is determined whether the target object data exists in the cache area, and is read in the cache area or database based on the search results, triggering the update mechanism to ensure cache synchronization.
It improves the efficiency of data reading, reduces the number of accesses to the database, and optimizes system performance.
Smart Images

Figure CN118689665A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data reading, and in particular to a data reading method, device, storage medium, electronic equipment and vehicle. Background Art
[0002] During the data reading process, the same database file is not shared between processes, and users cannot share a database with multiple processes at any time. At this time, if the database content is large, the speed of opening and synchronizing the database will slow down, which will lead to technical problems such as low data reading efficiency.
[0003] Currently, no effective solution has been proposed for the above-mentioned technical problem of low data reading efficiency. Summary of the invention
[0004] Embodiments of the present invention provide a data reading method, device, storage medium, electronic device and vehicle to solve the technical problem of low data reading efficiency.
[0005] According to one aspect of an embodiment of the invention, a method for reading data is provided. The method may include: obtaining a request instruction corresponding to target object data, wherein the request instruction is used to request to read the target object data; in response to the request instruction, transmitting a target message between multiple threads through a cache area; based on the target message, determining whether the target object data exists in the cache area, and obtaining a search result; based on the search result, reading the target object data, and obtaining a read result, wherein the read result is used to indicate that the target object data has been successfully read.
[0006] Optionally, the cache area includes: a message queue and a memory pool, wherein the message queue is used to store request messages between multiple threads, and the memory pool is used to manage request data corresponding to the request messages.
[0007] Optionally, based on the target message, determining whether the target object data exists in the cache area to obtain the search result includes: determining identification information of the target object data; and searching the target object data in the cache area using the identification information to obtain the search result.
[0008] Optionally, based on the search result, the target object data is read to obtain a read result, including: in response to the search result that the target object data exists in the cache area, determining a first modification time and a second modification time of the target object data, wherein the first modification time is the modification time of the target object data in the cache area, and the second modification time is the modification time of the target object data in the target database; based on the first modification time and the second modification time, the target object data is read to obtain a read result.
[0009] Optionally, based on the first modification time and the second modification time, the target object data is read to obtain a reading result, including: comparing the first modification time and the second modification time to obtain a comparison result; in response to the comparison result that the first modification time and the second modification time are the same, reading the target object data stored in the cache area; in response to the comparison result that the first modification time and the second modification time are different, reading the target object data stored in the target database.
[0010] Optionally, based on the search result, the target object data is read to obtain a read result, including: in response to the search result that the target object data does not exist in the cache area, a read / write operation is generated; based on the read / write operation, an update mechanism of the target database is triggered; based on the update mechanism, the cache area is updated to obtain an update result, wherein the update result is used to characterize that the data in the cache area has been successfully updated; based on the update result, the target object data is read to obtain a read result.
[0011] Optionally, the method further includes: monitoring the target database to obtain monitoring information, wherein the monitoring information is used to indicate that the data update of the target database has been completed; and triggering an update mechanism based on the monitoring information.
[0012] Optionally, the method further includes: closing the cache area and multiple threads.
[0013] According to one aspect of an embodiment of the present invention, a data reading device is provided. The device may include: an acquisition unit, used to acquire a request instruction corresponding to target object data, wherein the request instruction is used to request to read the target object data; a transmission unit, used to transmit a target message between multiple threads through a cache area in response to the request instruction; a determination unit, used to determine whether the target object data exists in the cache area based on the target message, and obtain a search result; a reading unit, used to read the target object data based on the search result, and obtain a reading result, wherein the reading result is used to indicate that the target object data has been successfully read.
[0014] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the method in each embodiment of the present invention is executed when the program is running.
[0015] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0016] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0017] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0018] According to another aspect of the embodiments of the present invention, a computer program is further provided. When the computer program is executed by a processor, the methods in the embodiments of the present invention are implemented.
[0019] According to another aspect of an embodiment of the present invention, a vehicle is further provided. When the vehicle is executed, the method in each embodiment of the present invention is implemented.
[0020] In an embodiment of the present invention, a request instruction corresponding to the target object data is obtained, wherein the request instruction is used to request to read the target object data; in response to the request instruction, a target message is transmitted between multiple threads through a cache area; based on the target message, it is determined whether the target object data exists in the cache area, and a search result is obtained; based on the search result, the target object data is read to obtain a read result, wherein the read result is used to indicate that the target object data has been successfully read. That is, in an embodiment of the present invention, a request instruction corresponding to the target object data can be obtained first, and in response to the request instruction, a target message can be transmitted between multiple threads through a cache area, and then, according to the target message obtained above, it can be determined whether the target object data exists in the cache area, so as to obtain a search result, and finally, according to the search result, the target object data can be read to achieve a read result of successfully reading the target object data. Considering that in response to the request instruction corresponding to the acquired target object data, the target message can be transmitted between multiple threads through a cache area, and then, according to the target message, the search result can be determined, so as to read the target object data, so as to achieve the purpose of obtaining the read result, thereby solving the technical problem of low data reading efficiency and achieving the technical effect of improving data reading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0022] Figure 1 is a flow chart of a method for reading data according to an embodiment of the present invention;
[0023] Figure 2 is a flow chart of a user data storage according to an embodiment of the present invention;
[0024] Figure 3 is a schematic diagram of a data reading device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme 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 only embodiments of a part of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] Example 1
[0028] According to an embodiment of the present invention, a method for reading data is provided. It should be noted that in the flowchart of the accompanying drawings, the steps shown therein 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] The following is an introduction to a method for reading data according to an embodiment of the present invention.
[0030] Figure 1 is a flow chart of a method for reading data according to an embodiment of the present invention. Figure 1 As shown, the method may include the following steps:
[0031] Step S101, obtaining a request instruction corresponding to target object data.
[0032] In the technical solution provided in step S101 of the present invention, a request instruction corresponding to the target object data can be obtained. The request instruction is used to request to read the target object data. The target object can be a user. The target object data can be called user data. The request instruction corresponding to the target object data can be referred to as a user data request. For example, a user data request can be received.
[0033] Step S102, in response to the request instruction, the target message is transmitted between multiple threads through the buffer area.
[0034] In the technical solution provided in the above step S102 of the present invention, after obtaining the request instruction corresponding to the target object data, the target message can be transmitted between multiple threads through the cache area in response to the request instruction. The cache area can be used to temporarily store data so as to quickly access it when needed, and can be referred to as a cache.
[0035] Optionally, multiple threads are constructed, and one of the threads is used to read and write the database, and receive the message queue content in a loop. The target message can be a message that needs to be transmitted between multiple threads, such as a storage request message, a user data message, etc. This is only an example and is not specifically limited.
[0036] It should be noted that this is only a preferred implementation method for determining the target message, and the process and method for determining the target message are not specifically limited. As long as the process and method for transmitting the target message between multiple threads through the cache area in response to the request instruction are within the protection scope of the present invention, they will not be repeated here.
[0037] Step S103, based on the target message, determine whether the target object data exists in the cache area to obtain a search result.
[0038] In the technical solution provided in the above step S103 of the present invention, based on the target message obtained in step S102, it can be determined whether the target object data exists in the cache area to achieve the purpose of obtaining the search result.
[0039] Optionally, the search result is used to indicate that the target object data exists in the cache area, or that the target object data does not exist in the cache area. For example, according to the user data message, the cache area is searched to see whether the user data corresponding to the user data message exists, so as to obtain the search result.
[0040] It can be understood that the above is only a preferred implementation method for determining the search results based on the target message, and does not specifically limit the process and method for determining the search results based on the target message. As long as the process and method for determining the search results are based on the target message, they are within the protection scope of the present invention and will not be repeated here.
[0041] Step S104: based on the search result, read the target object data to obtain a reading result.
[0042] In the technical solution provided in the above step S104 of the present invention, the target object data may be read according to the obtained search result to obtain a reading result, wherein the reading result is used to indicate that the target object data has been successfully read.
[0043] For example, based on the user data message, a search is performed in the cache area to determine whether there is user data corresponding to the user data message. After obtaining the search result, the user data can be read based on the search result to achieve the purpose of successfully reading the user data.
[0044] It should be noted that this is only a preferred implementation method for reading the target object data based on the search results to obtain the read results, and the process and method for reading the target object data based on the search results to obtain the read results are not specifically limited. As long as the process and method for reading the target object data based on the search results to obtain the read results are within the protection scope of the present invention, they are not listed here.
[0045] In the above steps S101 to S104 of the present invention, a request instruction corresponding to the target object data is obtained, wherein the request instruction is used to request to read the target object data; in response to the request instruction, a target message is transmitted between multiple threads through the cache area; based on the target message, it is determined whether the target object data exists in the cache area, and a search result is obtained; based on the search result, the target object data is read to obtain a read result, wherein the read result is used to indicate that the target object data has been successfully read. That is to say, the embodiment of the present invention can first obtain the request instruction corresponding to the target object data, and in response to the request instruction, the target message can be transmitted between multiple threads through the cache area, and then according to the target message obtained above, it can be determined whether the target object data exists in the cache area, so as to obtain a search result, and finally according to the search result, the target object data can be read to achieve a reading result of successfully reading the target object data. Considering that in response to the request instruction corresponding to the acquired target object data, the target message can be transmitted between multiple threads through the cache area, and then according to the target message, the search result can be determined, so as to read the target object data, so as to achieve the purpose of obtaining the read result, thereby solving the technical problem of low data reading efficiency and achieving the technical effect of improving data reading efficiency.
[0046] The above method of this embodiment is further introduced below.
[0047] As an optional implementation manner, the cache area includes: a message queue and a memory pool, wherein the message queue is used to store request messages between multiple threads, and the memory pool is used to manage request data corresponding to the request messages.
[0048] In this embodiment, the buffer area may include: a message queue and a memory pool. The message queue may be a preset queue. The memory pool may be a preset memory space. This is only an example, and the method for obtaining the message queue and the memory pool is not specifically limited.
[0049] For example, a message queue may be defined in the cache area to store storage request messages transmitted between threads; a memory pool may also be defined to manage memory allocation for storage request data.
[0050] It should be noted that the contents contained in the cache area are merely exemplified here, and the contents and types contained in the cache area are not specifically limited.
[0051] As an optional implementation method, based on the target message, determining whether the target object data exists in the cache area to obtain the search result includes: determining the identification information of the target object data; and searching the target object data in the cache area using the identification information to obtain the search result.
[0052] In this embodiment, the identification information of the target object data can be determined, and then the target object data can be searched in the cache using the obtained identification information to obtain the search result. The target object data includes a data object.
[0053] Optionally, the identification information is used to uniquely identify the target object data, such as a user identification code (user ID), etc. Here, the identification information is only illustrated by way of example, and is not specifically limited.
[0054] For example, a user ID of the user data is determined, and a search is performed in the cache area according to the user ID to obtain a search result.
[0055] As an optional implementation method, based on the search result, the target object data is read to obtain a read result, including: in response to the search result that the target object data exists in the cache area, determining the first modification time and the second modification time of the target object data, wherein the first modification time is the modification time of the target object data in the cache area, and the second modification time is the modification time of the target object data in the target database; based on the first modification time and the second modification time, the target object data is read to obtain a read result.
[0056] In this embodiment, if the search result is that the target object data exists in the cache area, the first modification time and the second modification time of the target object data can be determined, and then the target object data can be read according to the first modification time and the second modification time obtained above to obtain the reading result. The first modification time can be the last modification time of the target object data in the cache area. The target database can be referred to as a database.
[0057] Optionally, in response to the search result indicating that the data object in the target object data exists in the cache area, the first modification time and the second modification time of the data object are determined. For example, if the data object is found in the cache, the first modification time and the second modification time of the data object need to be determined, and then the data object is read according to the first modification time and the second modification time.
[0058] As an optional implementation method, the target object data is read based on the first modification time and the second modification time to obtain a reading result, including: comparing the first modification time and the second modification time to obtain a comparison result; in response to the comparison result that the first modification time and the second modification time are the same, reading the target object data stored in the cache area; in response to the comparison result that the first modification time and the second modification time are different, reading the target object data stored in the target database.
[0059] In this embodiment, after obtaining the first modification time and the second modification time, the first modification time and the second modification time can be compared to obtain a comparison result. If the comparison result is that the first modification time and the second modification time are the same, the target object data stored in the cache area can be read; if the comparison result is that the first modification time and the second modification time are different, the target object data stored in the target database is read.
[0060] Optionally, after obtaining the first modification time and the second modification time, if the comparison result is that the first modification time and the second modification time are the same, the data object stored in the cache area can be read; if the comparison result is that the first modification time and the second modification time are not the same, the data object stored in the target database is read.
[0061] For example, when a user data request arrives and the business module needs to operate the database, it can first search the cache based on the user ID. If the data object is found in the cache, it can further check whether the last modification time of the data object is consistent with the modification time in the database. If they are consistent, the cached data object is directly returned. If they are inconsistent, it is read from the database.
[0062] As an optional implementation method, based on the search result, the target object data is read to obtain a read result, including: in response to the search result that the target object data does not exist in the cache area, a read and write operation is generated; based on the read and write operation, an update mechanism of the target database is triggered; based on the update mechanism, the cache area is updated to obtain an update result, wherein the update result is used to indicate that the data in the cache area has been successfully updated; based on the update result, the target object data is read to obtain a read result.
[0063] In this embodiment, if the search result is that the target object data does not exist in the cache area, a read / write operation can be generated, and then according to the read / write operation, the update mechanism of the target database is triggered. According to the above update mechanism, the cache area can be updated to obtain an update result, and based on the update result, the target object data can be read to obtain a read result. Among them, the update mechanism can be called an update notification mechanism.
[0064] Optionally, a read-write operation can be generated using a database read-write thread. It should be noted that this is only a preferred implementation for generating a read-write operation, and the process and method for generating a read-write operation are not specifically limited. As long as the process and method for generating a read-write operation based on a read-write thread are within the protection scope of the present invention, they will not be described in detail here.
[0065] For example, if the target object data does not exist in the cache, the database read and write thread performs the actual database read and write operations. After the database read and write operations are completed, the database update notification mechanism is triggered to update the cache. After the cache is successfully updated, the target object data can be read to obtain the read result.
[0066] As an optional implementation manner, the method further includes: monitoring the target database to obtain monitoring information, wherein the monitoring information is used to indicate that the data update of the target database has been completed; and triggering an update mechanism based on the monitoring information.
[0067] In this embodiment, the target database may be monitored to obtain monitoring information indicating that the data update of the target database has been completed, and then the update mechanism may be triggered according to the monitoring information obtained above.
[0068] For example, the database can be continuously monitored. If there is an update in the database, the update notification mechanism of the database needs to be triggered again immediately to ensure that the cache is updated synchronously. Then, the cache can be queried at regular intervals to obtain the update results.
[0069] It should be noted that this is only a preferred implementation method of the triggering update mechanism, and the process and method of the triggering update mechanism are not specifically limited. As long as the process and method of the triggered update mechanism are based on the monitoring information of the target database, they are within the protection scope of the present invention and are not listed here.
[0070] As an optional implementation manner, the method further includes: closing the cache area and multiple threads.
[0071] In this embodiment, the buffer area and multiple threads can be closed. Among them, multiple threads can be stored in a thread pool. For example, before the program exits, it is necessary to close the message queue, thread pool, memory pool, and release all resources.
[0072] In this embodiment, the request instruction corresponding to the target object data can be obtained first, and in response to the request instruction, the target message can be transmitted between multiple threads through the cache area, and then according to the target message obtained above, it can be determined whether the target object data exists in the cache area, so as to obtain the search result, and finally according to the search result, the target object data can be read to achieve the reading result of successfully reading the target object data. Considering that in response to the request instruction corresponding to the acquired target object data, the target message can be transmitted between multiple threads through the cache area, and then according to the target message, the search result can be determined, so as to read the target object data to achieve the purpose of obtaining the reading result, thereby solving the technical problem of low data reading efficiency and achieving the technical effect of improving data reading efficiency.
[0073] Example 2
[0074] The technical solution of the embodiment of the present invention is illustrated below in conjunction with preferred implementation modes.
[0075] Currently, in the adaptive automotive open system architecture, the persistent storage module provides the ability to save data to non-volatile memory in applications (such as Adaptive Platform), so that the data can be saved and used after the board is restarted.
[0076] The persistence module supports both key value storage and file storage. The same database file is not shared between processes, and users cannot share a database with multiple processes at any time. The performance of the database generated by the persistence module is closely related to the size of the database, and the more database content, the slower the database opening and synchronization speed. In the case of a large amount of data, if the database is frequently opened for read and write operations, it will increase the database read and write time, reduce system performance, and lead to technical problems such as low data reading efficiency.
[0077] In an achievable embodiment, a data processing method is proposed. For data security, the method frequently operates the database, sets the number of writes, and updates the database. This operation method ignores the impact on system performance, increases database read and write time, and leads to a technical problem of low data reading efficiency.
[0078] In another feasible embodiment, a data processing method, device, storage medium and electronic device are proposed. The method is applied to a persistent storage module and uses a target data table to implement the storage of database data. However, it is essentially a continuous operation of the database itself, and there may also be a technical problem of low data reading efficiency.
[0079] In another feasible embodiment, a thread decoupling method, device, electronic device and storage medium are proposed, and data in an original database is read through multiple reading threads to obtain original data. This operation mode ignores multi-thread blocking and system performance, resulting in a technical problem of low data reading efficiency.
[0080] In order to solve the above problems, the present invention proposes a user data storage method of a persistent storage module. When the user data is large, the method takes into account the user data cache problem. After the device is powered on, the data is first read from the database to the cache. When a request for user data is sent, the data is first retrieved from the cache and searched according to the user ID. If the corresponding data object is found in the cache, it is also necessary to check whether the last modification time of the data object is consistent with that in the database. If it is consistent, the data object in the cache is directly returned; if it is inconsistent, it is read from the database. If the corresponding data object does not exist in the cache, it is also necessary to read the latest data object from the database, and trigger the database update notification mechanism to update the cache, and continuously monitor the database. If there is an update, the database update notification mechanism is immediately triggered again to ensure that the cache is updated synchronously, thereby solving the technical problem of low data reading efficiency and achieving the technical effect of improving data reading efficiency.
[0081] In this embodiment, Figure 2 This is a flowchart of a user data storage according to an embodiment of the present invention, and the flowchart mainly includes the following steps:
[0082] Step S201, open a thread dedicated to database reading and writing, a message queue and a memory pool.
[0083] In this embodiment, a thread is opened to read and write the database and receive the content of the message queue cyclically. A message queue is defined to store storage request messages transmitted between threads; a memory pool can also be defined to manage memory allocation for storage request data.
[0084] In this embodiment, message queues and memory pools are used for message transmission between threads, and some database accesses are skipped through caching, which can reduce the number of database reads and optimize system performance.
[0085] Step S202, looping to receive the message queue content.
[0086] In this embodiment, a thread may be opened to cyclically receive the content of the message queue.
[0087] Step S203, determining whether there is a user data request.
[0088] In this embodiment, it can be determined whether there is a user data request, and if so, step S204 is executed, and if not, step S202 is executed.
[0089] Step S204, determining whether there is a data object corresponding to the user ID in the cache.
[0090] In this embodiment, if there is a user data request, it can be determined whether there is a data object corresponding to the user ID in the cache. If so, step S205 is executed; if not, step S207 is executed.
[0091] Step S205: Check whether the modification time of the data object is consistent with the modification time in the database.
[0092] In this embodiment, if there is a data object corresponding to the user ID in the cache, it is determined whether the modification time of the data object is consistent with the modification time in the database. If they are consistent, step S206 is executed; if they are inconsistent, step S207 is executed.
[0093] Step S206, reading data from the cache.
[0094] In this embodiment, if the modification time of the data object is consistent with the modification time in the database, the data needs to be read from the cache.
[0095] For example, when a user data request arrives and the business module needs to operate the database, it can first search the cache based on the user ID. If the data object is found in the cache, it can further check whether the last modification time of the data object is consistent with the modification time in the database. If they are consistent, the cached data object is directly returned. If they are inconsistent, it is read from the database.
[0096] Step S207, executing database read and write operations, triggering a database update notification mechanism.
[0097] In this embodiment, if the modification time of the data object is inconsistent with the modification time in the database, a database read and write operation may be performed to trigger a database update notification mechanism to update the cache.
[0098] For example, if the target object data does not exist in the cache, the database read and write thread performs the actual database read and write operations. After the database read and write operations are completed, the database update notification mechanism is triggered to update the cache. After the cache is successfully updated, the target object data can be read to obtain the read result.
[0099] Step S208: continuously monitor the database, and if there is an update, immediately trigger the database update notification mechanism again.
[0100] In this embodiment, the database can be continuously monitored. If there is an update in the database, the update notification mechanism of the database needs to be triggered again immediately to ensure that the cache is updated synchronously, and then the cache can be queried regularly to achieve the purpose of obtaining the update result.
[0101] Step S209: Before the program exits, the message queue, thread pool, memory pool, and all resources need to be closed.
[0102] In this embodiment, the request instruction corresponding to the target object data can be obtained first, and in response to the request instruction, the target message can be transmitted between multiple threads through the cache area, and then according to the target message obtained above, it can be determined whether the target object data exists in the cache area, so as to obtain the search result, and finally according to the search result, the target object data can be read to achieve the reading result of successfully reading the target object data. Considering that in response to the request instruction corresponding to the acquired target object data, the target message can be transmitted between multiple threads through the cache area, and then according to the target message, the search result can be determined, so as to read the target object data to achieve the purpose of obtaining the reading result, thereby solving the technical problem of low data reading efficiency and achieving the technical effect of improving data reading efficiency.
[0103] Example 3
[0104] According to an embodiment of the present invention, a data reading device is provided. It should be noted that the data reading device can be used to execute a data reading method in embodiment 1.
[0105] Figure 3 Schematic diagram of a data reading device according to an embodiment of the present invention. Figure 3 As shown, a data reading device 300 may include: an acquisition unit 301 , a transmission unit 302 , a determination unit 303 and a reading unit 304 .
[0106] The acquisition unit 301 is used to acquire a request instruction corresponding to the target object data, wherein the request instruction is used to request to read the target object data.
[0107] The transfer unit 302 is used to transfer the target message between multiple threads through the buffer area in response to the request instruction.
[0108] The determination unit 303 is used to determine whether the target object data exists in the cache area based on the target message, and obtain a search result.
[0109] The reading unit 304 is used to read the target object data based on the search result to obtain a reading result, wherein the reading result is used to indicate that the target object data has been successfully read.
[0110] Optionally, the cache area includes: a message queue and a memory pool, wherein the message queue is used to store request messages between multiple threads, and the memory pool is used to manage request data corresponding to the request messages.
[0111] Optionally, the determination unit 303 may include: a first determination module, configured to determine identification information of the target object data; and a search module, configured to search for the target object data in the cache area using the identification information to obtain a search result.
[0112] Optionally, the reading unit 304 may include: a second determination module, used to determine a first modification time and a second modification time of the target object data in response to a search result indicating that the target object data exists in the cache area, wherein the first modification time is the modification time of the target object data in the cache area, and the second modification time is the modification time of the target object data in the target database; and a first reading module, used to read the target object data based on the first modification time and the second modification time to obtain a reading result.
[0113] Optionally, the first reading module may include: a comparison submodule, used to compare the first modification time and the second modification time to obtain a comparison result; a first reading submodule, used to read the target object data stored in the cache area in response to the comparison result that the first modification time and the second modification time are the same; and a second reading submodule, used to read the target object data stored in the target database in response to the comparison result that the first modification time and the second modification time are different.
[0114] Optionally, the reading unit 304 may include: a generation module, used to generate a read / write operation in response to a search result indicating that the target object data does not exist in the cache area; a first trigger module, used to trigger an update mechanism of the target database based on the read / write operation; an update module, used to update the data in the cache area based on the update mechanism to obtain an update result, wherein the update result is used to indicate that the data in the cache area has been successfully updated; and a second reading module, used to read the target object data based on the update result to obtain a read result.
[0115] Optionally, the reading unit 304 may further include: a monitoring module, used to monitor the target database to obtain monitoring information, wherein the monitoring information is used to indicate that the data update of the target database has been completed; and a second triggering module, used to trigger the update mechanism based on the monitoring information.
[0116] Optionally, the device further includes: a closing unit, configured to close the cache area and multiple threads.
[0117] In this embodiment, a request instruction corresponding to the target object data is obtained by an acquisition unit, wherein the request instruction is used to request to read the target object data; a target message is transmitted between multiple threads through a cache area in response to the request instruction by a transmission unit; a search result is obtained by a determination unit based on the target message and determining whether the target object data exists in the cache area; and a read result is obtained by a reading unit based on the search result and reading the target object data, wherein the read result is used to indicate that the target object data has been successfully read, thereby solving the technical problem of low data reading efficiency and achieving the technical effect of improving data reading efficiency.
[0118] Example 4
[0119] An embodiment of the present invention further provides an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the method in each embodiment of the present invention is executed when the program is running.
[0120] Optionally, the cache area includes: a message queue and a memory pool, wherein the message queue is used to store request messages between multiple threads, and the memory pool is used to manage request data corresponding to the request messages.
[0121] Optionally, the electronic device is used to determine whether the target object data exists in the cache area based on the target message to obtain a search result, including: determining identification information of the target object data; and searching the target object data in the cache area using the identification information to obtain a search result.
[0122] Optionally, the electronic device is used to read the target object data based on the search result to obtain a read result, including: in response to the search result that the target object data exists in the cache area, determining a first modification time and a second modification time of the target object data, wherein the first modification time is the modification time of the target object data in the cache area, and the second modification time is the modification time of the target object data in the target database; based on the first modification time and the second modification time, reading the target object data to obtain a read result.
[0123] Optionally, the electronic device is used to read the target object data based on the first modification time and the second modification time to obtain a reading result, including: comparing the first modification time and the second modification time to obtain a comparison result; in response to the comparison result that the first modification time and the second modification time are the same, reading the target object data stored in the cache area; in response to the comparison result that the first modification time and the second modification time are different, reading the target object data stored in the target database.
[0124] Optionally, the electronic device is used to read the target object data based on the search result to obtain a read result, including: generating a read / write operation in response to the search result that the target object data does not exist in the cache area; triggering an update mechanism of the target database based on the read / write operation; updating the data in the cache area based on the update mechanism to obtain an update result, wherein the update result is used to characterize that the data in the cache area has been successfully updated; and reading the target object data based on the update result to obtain a read result.
[0125] Optionally, the electronic device is used to monitor the target database to obtain monitoring information, wherein the monitoring information is used to indicate that the data update of the target database has been completed; and is used to trigger an update mechanism based on the monitoring information.
[0126] Optionally, the electronic device is used to close the cache area and multiple threads.
[0127] Example 5
[0128] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0129] Optionally, the cache area includes: a message queue and a memory pool, wherein the message queue is used to store request messages between multiple threads, and the memory pool is used to manage request data corresponding to the request messages.
[0130] Optionally, the storage medium is used to determine whether the target object data exists in the cache area based on the target message to obtain a search result, including: determining identification information of the target object data; and searching for the target object data in the cache area using the identification information to obtain a search result.
[0131] Optionally, the storage medium is used to read the target object data based on the search result to obtain a read result, including: in response to the search result that the target object data exists in the cache area, determining a first modification time and a second modification time of the target object data, wherein the first modification time is the modification time of the target object data in the cache area, and the second modification time is the modification time of the target object data in the target database; based on the first modification time and the second modification time, reading the target object data to obtain a read result.
[0132] Optionally, the storage medium is used to read the target object data based on the first modification time and the second modification time to obtain a reading result, including: comparing the first modification time and the second modification time to obtain a comparison result; in response to the comparison result that the first modification time and the second modification time are the same, reading the target object data stored in the cache area; in response to the comparison result that the first modification time and the second modification time are different, reading the target object data stored in the target database.
[0133] Optionally, the storage medium is used to read the target object data based on the search result to obtain a read result, including: generating a read / write operation in response to the search result that the target object data does not exist in the cache area; triggering an update mechanism of the target database based on the read / write operation; updating the cache area based on the update mechanism to obtain an update result, wherein the update result is used to characterize that the data in the cache area has been successfully updated; and reading the target object data based on the update result to obtain a read result.
[0134] Optionally, the storage medium is used to monitor the target database to obtain monitoring information, wherein the monitoring information is used to indicate that the data update of the target database has been completed; and is used to trigger an update mechanism based on the monitoring information.
[0135] Optionally, the storage medium is used to close a cache area and multiple threads.
[0136] Example 6
[0137] An embodiment of the present invention further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0138] An embodiment of the present invention further provides a computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0139] An embodiment of the present invention further provides a computer program, which implements the methods in the above-mentioned embodiments of the present invention when executed by a processor.
[0140] Example 7
[0141] An embodiment of the present invention further provides a vehicle, which is used to implement the methods in the above-mentioned various embodiments of the present invention.
[0142] Optionally, the cache area includes: a message queue and a memory pool, wherein the message queue is used to store request messages between multiple threads, and the memory pool is used to manage request data corresponding to the request messages.
[0143] Optionally, the vehicle is used to determine whether target object data exists in a cache area based on a target message to obtain a search result, including: determining identification information of the target object data; and searching for the target object data in the cache area using the identification information to obtain a search result.
[0144] Optionally, the vehicle is used to read the target object data based on the search result to obtain a read result, including: in response to the search result that the target object data exists in the cache area, determining a first modification time and a second modification time of the target object data, wherein the first modification time is the modification time of the target object data in the cache area, and the second modification time is the modification time of the target object data in the target database; based on the first modification time and the second modification time, reading the target object data to obtain a read result.
[0145] Optionally, the vehicle is used to read the target object data based on the first modification time and the second modification time to obtain a reading result, including: comparing the first modification time and the second modification time to obtain a comparison result; in response to the comparison result that the first modification time and the second modification time are the same, reading the target object data stored in the cache area; in response to the comparison result that the first modification time and the second modification time are different, reading the target object data stored in the target database.
[0146] Optionally, the vehicle is used to read the target object data based on the search result and obtain a read result, including: generating a read / write operation in response to the search result that the target object data does not exist in the cache area; triggering an update mechanism of the target database based on the read / write operation; updating the cache area based on the update mechanism and obtaining an update result, wherein the update result is used to characterize that the data in the cache area has been successfully updated; and reading the target object data based on the update result and obtaining a read result.
[0147] Optionally, the vehicle is used to monitor the target database to obtain monitoring information, wherein the monitoring information is used to indicate that the data update of the target database has been completed; and is used to trigger an update mechanism based on the monitoring information.
[0148] Optionally, the vehicle is used to close caches and multiple threads.
[0149] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0150] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0151] In the several embodiments provided by the present invention, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic, for example, the division of units can be a logical function division, and there can be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0152] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0153] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0154] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0155] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for reading data, characterized in that: include: Obtaining a request instruction corresponding to the target object data, wherein the request instruction is used to request to read the target object data; In response to the request instruction, the target message is transmitted between the plurality of threads through the buffer area; Based on the target message, determine whether the target object data exists in the cache area to obtain a search result; Based on the search result, the target object data is read to obtain a reading result, wherein the reading result is used to indicate that the target object data has been successfully read.
2. The method according to claim 1, characterized in that The buffer area includes: a message queue and a memory pool, wherein the message queue is used to store request messages between multiple threads, and the memory pool is used to manage request data corresponding to the request messages.
3. The method according to claim 1, characterized in that: Based on the target message, determining whether the target object data exists in the cache area to obtain a search result includes: Determining identification information of the target object data; In the cache area, the target object data is searched using the identification information to obtain the search result.
4. The method according to claim 1, characterized in that: Based on the search result, the target object data is read to obtain a reading result, including: In response to the search result indicating that the target object data exists in the cache area, determining a first modification time and a second modification time of the target object data, wherein the first modification time is the modification time of the target object data in the cache area, and the second modification time is the modification time of the target object data in the target database; The target object data is read based on the first modification time and the second modification time to obtain the read result.
5. The method according to claim 4, characterized in that Based on the first modification time and the second modification time, the target object data is read to obtain the reading result, including: Compare the first modification time with the second modification time to obtain a comparison result; In response to the comparison result being that the first modification time and the second modification time are the same, reading the target object data stored in the cache area; In response to the comparison result that the first modification time and the second modification time are different, the target object data stored in the target database is read.
6. The method according to claim 1, characterized in that Based on the search result, the target object data is read to obtain a reading result, including: In response to the search result being that the target object data does not exist in the cache area, generating a read / write operation; Based on the read and write operations, trigger an update mechanism of the target database; Based on the update mechanism, update the data in the cache area to obtain an update result, wherein the update result is used to indicate that the data in the cache area has been successfully updated; Based on the update result, the target object data is read to obtain the read result.
7. The method according to claim 6, characterized in that The method further comprises: Monitoring the target database to obtain monitoring information, wherein the monitoring information is used to indicate that data update of the target database has been completed; Based on the monitoring information, the update mechanism is triggered.
8. The method according to claim 1, characterized in that The method further includes: closing the cache area and the plurality of threads.
9. A data reading device, characterized in that: include: An acquiring unit, configured to acquire a request instruction corresponding to the target object data, wherein the request instruction is used to request to read the target object data; A transmission unit, configured to transmit a target message between multiple threads through a buffer area in response to the request instruction; A determination unit, configured to determine whether the target object data exists in the cache area based on the target message, and obtain a search result; A reading unit is used to read the target object data based on the search result to obtain a reading result, wherein the reading result is used to indicate that the target object data has been successfully read.
10. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 8 when running.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 8.
12. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.
13. A vehicle, characterized in that: The vehicle is used to perform the method according to any one of claims 1 to 8.
