Data access method, device, computer equipment and storage medium
By using status indication data to distinguish the working and idle status of memory blocks in a high-concurrency environment, concurrent operations of data reading and updating are realized, which solves the problem of slow response speed and data inconsistency caused by the lock mechanism, and improves the real-time performance of the system. sex and efficiency.
Patent Information
- Application Number
- CN202010552309.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-17
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-06-17
AI Technical Summary
In a high-concurrency environment, the existing lock mechanism results in long waiting times for data access tasks, reduced response speed, and difficulty in achieving concurrent operations of data reading and updating, leading to data inconsistency issues.
By creating two target memory blocks with the same storage characteristics and using status indication data to distinguish them into working and idle states, it allows data to be read from the working state block during read operations and to the idle state block during update operations. Perform a full update and set the idle status block to the working status after the update is completed.
On the premise of ensuring data security, concurrent operations of data access and updates are realized, improving the real-time nature of data and system response speed, and reducing waiting time.
Smart Images

Figure CN111708626B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data access method, apparatus, computer device and storage medium. Background Art
[0002] With the continuous development of science and technology, the amount of concurrency faced by the system is increasing day by day. In this concurrent environment, data security issues are prone to occur. For example, when the same data needs to be updated and read at the same time, it is easy to cause the updated or read data to be inconsistent or inaccurate.
[0003] At present, the lock mechanism is mainly used to control the system's access to the same data. The lock mechanism means that one of the data access tasks in the concurrent state applies for a lock on the data to be accessed, and then updates the data to be accessed after the lock application is successful, and releases the lock after the update is completed. During this process, other data access tasks can only wait and cannot read the locked data. In this way, although the data security is guaranteed, when the concurrency is large, the system response speed will be reduced due to the long waiting time of the data access task. Summary of the invention
[0004] Based on this, it is necessary to provide a data access method, apparatus, computer device and storage medium that can concurrently perform data reading operations and data updating operations in response to the above technical problems.
[0005] A data access method, the method comprising:
[0006] When a data read operation for a target memory block is triggered, a target memory block in a working state is determined based on the state indication data, and data is read from the target memory block in the working state;
[0007] When a data update operation for a target memory block is triggered, determining a target memory block in an idle state based on the state indication data;
[0008] Based on the data update operation, a full data update is performed on the target memory block in the idle state;
[0009] When the full data update is completed, the target memory block in the idle state is set to the working state by modifying the state indication data.
[0010] A data access device, comprising:
[0011] The data reading module is used to determine the target memory block in a working state based on the state indication data when a data reading operation for the target memory block is triggered, and read data from the target memory block in the working state.
[0012] The data update module is used to determine the target memory block in an idle state based on the state indication data when a data update operation for the target memory block is triggered; and to perform a full data update on the target memory block in the idle state based on the data update operation.
[0013] The status indication data modification module is used to set the target memory block in the idle state to the working state by modifying the status indication data when the full data update is completed.
[0014] In one embodiment, the data access device also includes an initialization module for triggering environment initialization; when the environment is initialized, two target memory blocks with the same storage characteristics are created, and status indication data is created; wherein the status indication data indicates that one of the two target memory blocks is in a working state, and indicates that the other target memory block is in an idle state.
[0015] In one embodiment, the initialization module is further used to create a target memory block; obtain storage characteristics of the target memory block; the storage characteristics include storage space and storage structure; based on the storage characteristics, copy another target memory block.
[0016] In one embodiment, the data reading module is also used to determine the target memory block pointed to by the address stored in the pointer variable as a target memory block in a working state; the determination of the target memory block in an idle state based on the state indication data includes: in the two paired target memory blocks, determining the target memory block not pointed to by the address stored in the pointer variable as a target memory block in an idle state.
[0017] In one embodiment, the state indication data modification module is further used to modify the pointer variable so that the address stored in the pointer variable points to the target memory block in the idle state.
[0018] In one embodiment, the data update module is also used to obtain the data path when the data update operation specifies the data path; read the full amount of data according to the data path; and replace all the data in the target memory block in the idle state with the full amount of data.
[0019] In one embodiment, the data update module is also used to obtain the updated data when the data update operation specifies to update data; based on the updated data and the data in the target memory block in the working state, perform a full data update on the target memory block in the idle state.
[0020] In one embodiment, the data update module is also used to determine the data to be written based on the data insertion operation when the data update operation is a data insertion operation; write the data to be written into the target memory block in the working state; when the data to be written is written successfully, synchronize the entire amount of data in the target memory block in the working state to the target memory block in the idle state.
[0021] In one embodiment, the above-mentioned data access device also includes a synchronization module, which is used to synchronize the data in the target memory block in the working state to the target memory block in the idle state when the data of the target memory block in the working state and the target memory block in the idle state are inconsistent; when the data update operation is triggered, stop the operation of synchronizing the data in the target memory block in the working state to the target memory block in the idle state.
[0022] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0023] When a data read operation for a target memory block is triggered, a target memory block in a working state is determined based on the state indication data, and data is read from the target memory block in the working state;
[0024] When a data update operation for a target memory block is triggered, determining a target memory block in an idle state based on the state indication data;
[0025] Based on the data update operation, a full data update is performed on the target memory block in the idle state;
[0026] When the full data update is completed, the target memory block in the idle state is set to the working state by modifying the state indication data.
[0027] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0028] When a data read operation for a target memory block is triggered, a target memory block in a working state is determined based on the state indication data, and data is read from the target memory block in the working state;
[0029] When a data update operation for a target memory block is triggered, determining a target memory block in an idle state based on the state indication data;
[0030] Based on the data update operation, a full data update is performed on the target memory block in the idle state;
[0031] When the full data update is completed, the target memory block in the idle state is set to the working state by modifying the state indication data.
[0032] The above-mentioned data access method, device, computer equipment and storage medium distinguish the working status of two paired target memory blocks through working status indication data, so that when a data read operation for the target memory block is triggered, data can be read from the target memory block in the working state; when a data update operation for the target memory block is triggered, the target memory block in the idle state can be fully updated. In this way, concurrent operations of data access and data update can be achieved under the premise of ensuring data security; in addition, when the full data update is completed, the target memory block in the idle state is set to the working state by modifying the status indication data, which can improve the real-time performance of the read data while ensuring concurrency. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 An application environment diagram of a data access method in an embodiment;
[0034] Figure 2 A schematic diagram of a flow chart of a data access method in an embodiment;
[0035] Figure 3 A schematic diagram of a target memory block and status indication data in one embodiment;
[0036] Figure 4 A schematic diagram of the principle of a data reading operation in one embodiment;
[0037] Figure 5 A schematic diagram of the principle of a data update operation in one embodiment;
[0038] Figure 6 It is a schematic diagram of the principle of modifying the status indication data in one embodiment;
[0039] Figure 7 is a flowchart of a data access method in a specific embodiment;
[0040] Figure 8 is a flowchart of a data access method in another specific embodiment;
[0041] Fig. 9 is a structural block diagram of a data access device in one embodiment;
[0042] Fig.10 is a structural block diagram of a data access device in another embodiment;
[0043] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0045] Figure 1 1 is an application environment diagram of a data access method in an embodiment, and the data access method is applied to a data access system. The data access system includes a terminal 110 and a server 120. The terminal 110 and the server 120 are connected via a network. The terminal 110 runs a business system. The business system is used to read data from the server 120 and input update data to the server 120, so that the server 120 concurrently responds to the data reading requirements and data update requirements of the business system. The business system can be an APP (Application, client), a WEB application (World Wide Web, an application that can be accessed through the global wide area network) or a mini program (Mini Program), etc. The server 120 can specifically be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop, a desktop computer, a smart speaker, a smart watch, etc., but is not limited to this. The terminal 110 and the server 120 may be directly or indirectly connected via wired or wireless communication, which is not limited in this application. The server 120 may be used alone to execute the data access method provided in the embodiment of the present application. The server 120 may also cooperate with the terminal 110 to execute the data access method provided in the embodiment of the present application.
[0046] It should be understood that although the terms first, second, etc. may be used herein to describe various elements, these elements should not be limited to these terms. These terms are only used to distinguish these elements from each other. For example, without departing from the scope of the present invention, a first thread may be referred to as a second thread, and similarly, a second thread may be referred to as a first thread. Both the first thread and the second thread are threads, but they are not the same thread.
[0047] In one embodiment, Figure 2 As shown, a data access method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:
[0048] S202, when a data read operation for a target memory block is triggered, a target memory block in a working state is determined based on the state indication data, and data is read from the target memory block in the working state.
[0049] The data read operation refers to an operation of reading data from a target memory block. The data read operation may be a thread-triggered operation, such as a computer device calling one or more threads, so that each thread can trigger a data read operation for a target memory block when calling. The data read operation may also be a process-triggered operation, such as a computer device calling one or more processes, so that each process can trigger a data read operation for a target memory block when calling. The following is an explanation using a thread-triggered operation as an example.
[0050] A target memory block is a memory space composed of multiple storage units and has storage characteristics. The storage characteristics of different target memory blocks can be the same or different. Figure 3 , Figure 3 FIG. 2 shows a schematic diagram of a target memory block and status indication data in one embodiment. Figure 3 As shown, the present application creates two target memory blocks with the same storage characteristics when the environment is initialized, and uses the created two target memory blocks as paired target memory blocks.
[0051] The storage characteristics may specifically include storage space and storage structure. The storage space refers to the memory size occupied by the target memory block, and the memory space can be freely set according to demand, for example, the storage space can be set according to the amount of data to be stored, or the storage space can be set according to the memory specifications of the memory stick in the computer device.
[0052] The storage structure refers to the organizational relationship between the data stored in the memory, and the storage structure includes sequential storage structure, linked storage structure, etc. When the storage structure of the memory space is a sequential storage structure, the computer device stores logically adjacent data in storage units with adjacent memory addresses in the target memory block; when the storage structure of the memory space is a linked storage structure, the computer device stores logically adjacent data and establishes an association relationship between two logically adjacent data with the help of pointer variables.
[0053] like Figure 3 As shown, the present application creates status indication data when the environment is initialized, and the status indication data is data used to indicate the working status of the target memory block. The status indication data can specifically be a pointer variable, a key-value pair, a string, etc.
[0054] Among them, the pointer variable refers to a variable used to store the address of a target memory block. When the state indication data is a pointer variable, in the two paired target memory blocks, the target memory block pointed to by the pointer variable can be set as a target memory block in a working state, and the target memory block not pointed to by the pointer variable can be set as a target memory block in an idle state; or in the two paired target memory blocks, the target memory block pointed to by the pointer variable can be set as a target memory block in an idle state, and the target memory block not pointed to by the pointer variable can be set as a target memory block in a working state.
[0055] A key-value pair refers to a key-value pair, in which the key Key serves as a unique identifier to point to the value Value. When the status indication data refers to a key-value pair, the computer device can determine the working status of the target memory block by limiting the key-value. For example, the value Value pointed to by the key key value is limited to the memory identifier of the target memory block in the working status. The memory identifier refers to information that can uniquely identify a memory block, such as the memory address of the memory block, the number obtained by encoding the memory address of the memory block, or the timestamp of creating the memory block.
[0056] Specifically, when it is necessary to read data from a target memory block, the computer device can call one or more first threads according to the data reading requirements, so that each first thread can trigger and execute the data reading operation for the target memory block after being called. For example, when multiple business systems running in the computer device need to read the target data in the target memory block, the computer device counts the number of business systems that need to read the target data, and calls the corresponding number of first threads according to the number to trigger and execute the data reading operation for the target memory block. In actual applications, multiple called first threads can execute the data reading operation synchronously or asynchronously, depending on whether the computer device has a multi-core processor.
[0057] refer to Figure 4 , Figure 4 FIG. 2 shows a schematic diagram of the principle of data reading operation in one embodiment. Figure 4 As shown, when a data read operation for a target memory block is triggered, the first thread determines a target memory block in a working state based on the state indication data, and reads target data from the target memory block in the working state.
[0058] In one embodiment, reading data from the target memory block in the working state specifically includes: when a data reading operation specifies a user identifier, determining a user role of a target user corresponding to the user identifier; determining a role node corresponding to the target user in a preset role structure tree according to the user role; taking the role node corresponding to the target user as the current-level role node, and traversing the role structure tree from the current-level role node toward the lower-level role node; when the current-level role node, or one or more lower-level role nodes directly or indirectly connected to the current-level role node, have access rights to the required access data, reading data from the target memory block in the working state according to the data identifier of the required access data.
[0059] The role structure tree may be constructed based on the organizational structure of the entire group, including multiple levels of role nodes and connection edges for connecting role nodes. It is easy to understand that the higher the level of the current role node, the higher the position of the target user corresponding to the current role node in the group.
[0060] Specifically, one or more business systems are running on the computer device. The computer device monitors data access instructions triggered by users based on the business system. Data access instructions can be instructions triggered by users performing data access operations such as page browsing, data downloading, and data forwarding in the business system. The data access instruction carries a user identifier and a data identifier. The user identifier is information that can uniquely represent the identity of the user, such as an ID number, mobile phone number, etc. The data identifier is information that can uniquely identify the target data that the user wishes to access, and can specifically be a data number, a hash value generated based on the data title or content, etc.
[0061] When a data access instruction is detected, the first thread triggers a data reading operation, and determines the user role of the corresponding target user according to the user identifier carried by the data access instruction. The user role is applicable to role information reflecting the scope of user rights and responsibilities. The first thread obtains a pre-stored role structure tree, and specifies the role node in the role structure tree according to the user role of the target user. The first thread uses the role node corresponding to the target user as the current level role node, and verifies whether the next level role node connected to the current level role node has access rights to the target data corresponding to the data identifier according to the correspondence between the pre-stored user role and the access rights. If the next level organization node has access rights to the target data, the first thread stops traversing, determines whether the target user has access rights to the target data, and reads the target data from the target memory block in the working state according to the data identifier. If the next level organization node does not have access rights to the target data, the next level organization node of the next level organization node is verified to see whether it has access rights to the target data corresponding to the data identifier. Repeat this process until at least one lower level role node directly or indirectly connected to the current level role node is found to have access rights to the target data. If the lowest-level role node is traversed and no lower-level organization node is found that is directly or indirectly connected to the current-level role node and has access rights to the target data, it is determined that the target user does not have access rights to the target data, and the first thread suspends reading the target data from the target memory block. By verifying whether the target user has access rights to the target data, the step of reading the target data from the target memory block is performed only when the target user has access rights to the target data, thereby improving the security of data reading.
[0062] S204, when a data update operation for a target memory block is triggered, determining a target memory block in an idle state based on the state indication data.
[0063] Specifically, refer to Figure 5 , Figure 5 FIG. 2 shows a schematic diagram of the principle of data update operation in one embodiment. Figure 5As shown, when data update is required, the computer device calls one or more second threads based on the data update demand, so that each second thread can trigger and execute the data update operation for the target memory block after being called. In actual applications, in order to improve the security of the data in the target memory block, multiple called second threads perform data update operations asynchronously. When the data update operation for the target memory block is triggered, the second thread obtains the target memory block pointed to by the status indication data, and determines the target memory block in the idle state based on the pointed target memory block. For example, when the status indication data is a key-value pair, and the value Value pointed to by the key key value is limited to the memory identifier of the target memory block in the working state, the second thread determines the value Value pointed to by the key key value as the target memory block in the working state, and in the two paired target memory blocks, the value Value not pointed to by the key key value is determined as the target memory block in the idle state.
[0064] In one embodiment, when more than one second thread concurrently updates the data of the target memory block, one of the second threads in the state can apply to lock the data in the target memory block in the idle state, and then update the data in the target memory block in the idle state after the lock application is successful; when the second thread completes the update process, the lock is released. After locking, other second threads can only wait and cannot update the locked data, which improves the security of the data and avoids errors caused by concurrent updates by multiple second threads.
[0065] S206: Based on the data update operation, a full data update is performed on the target memory block in the idle state.
[0066] Specifically, Figure 5 As shown, the second thread determines the full amount of data that should be stored in the target memory block in the idle state after the update based on the data update operation, and replaces all the data in the target memory block in the idle state with the full amount of data. Among them, the full amount of data refers to all the data in the target memory block after the update. For the second thread, directly updating the full amount of data of the target memory block in the idle state can ensure the real-time performance of each data in the target memory block.
[0067] In one embodiment, when the full amount of data is obtained, the second thread deletes the original data in the target memory block in the idle state, and stores the full amount of data in the target memory block from which the original data has been deleted. In order to improve the security of the data, the second thread caches the original data in the target memory block to a temporary cache space, and destroys the corresponding temporary cache space when confirming that the full amount of data update has been completed; when the full amount of data update fails, the target memory block in the idle state is restored based on the original data in the cache space.
[0068] S208, when the full data update is completed, the target memory block in the idle state is set to the working state by modifying the state indication data.
[0069] Specifically, refer to Figure 6 , Figure 6 FIG. 1 is a schematic diagram showing the principle of modifying the status indication data in an embodiment. Figure 6 As shown, when the full data update is completed, the second thread modifies the state indication data, sets the target memory block in the idle state to the working state, and sets the target memory block in the working state to the idle state. For example, in the above example, the second thread sets the value Value pointed to by the key key value to the memory address of the target memory block in the idle state, sets the target memory block in the idle state to the working state, and sets the target memory block in the working state to the idle state.
[0070] In one embodiment, the second thread performs a difference analysis on the data in the full data and the target memory block in the idle state, selects the difference data from the full data according to the difference analysis result, and updates the difference data to the target memory block in the idle state. Wherein, the data includes a data identifier and a data content. The data identifier is information that can uniquely identify a target data that is expected to be accessed, such as a data number; the data content refers to the specific content contained in each data in the full data, such as a data value. The difference data refers to the data whose data identifier is stored in the full data but has not yet been stored in the target memory block in the idle state; or the data identifier is stored in the full data and the target memory block in the idle state, but the data content of the two is inconsistent. By performing a difference analysis on the data in the full data and the target memory block in the idle state, it is possible to select only the data with differences to be updated according to the difference analysis result, thereby greatly reducing unnecessary data update steps, thereby saving computer resources consumed by data updates.
[0071] In one embodiment, the data reading operation is triggered by the first thread; the data updating operation is triggered by the second thread; the full data updating and the modification status indication data are executed by the second thread or the third thread.
[0072] The computer device has a thread pool, which is composed of multiple threads for triggering and executing data reading operations and data updating operations, such as a first thread for triggering data reading operations, a second thread for triggering data updating operations and performing full data updates and modifying status indication data, and a third thread for performing full data updates and modifying status indication data.
[0073] Specifically, when it is necessary to perform a read operation and a data update operation on the data in the target memory block at the same time, the computer device selects one or more first threads from the thread pool to trigger the data read operation and one or more second threads from the thread pool to trigger the data update operation according to the data read demand and the data update demand, so that the selected first threads and second threads can respond to different data access demands in parallel. When one or more first threads are called, one or more first threads can trigger the data read operation on the target memory block, and determine the target memory block in the working state from the state indication data based on the data read operation, and read the target data from the target memory block in the working state.
[0074] When only one second thread is called, the second thread triggers a data update operation for the target memory block, and performs a full data update on the idle target memory block based on the data update operation. When multiple second threads are called, the computer device sorts the multiple second threads in the order in which they are called, and controls the second threads to complete the full data update operation and the modification status indication data operation based on the arrangement order. In one embodiment, when two or more second threads are called at the same time, the computer device obtains a preset additional sorting rule and sorts the second threads according to the preset additional sorting. For example, the additional sorting rule can be to sort multiple second threads that are called at the same time according to the ID size of the thread ID (Identity document).
[0075] In one embodiment, a computer device may create a third thread in a thread pool for performing full data update and status indication data modification. When a data update operation for a target memory block is triggered, the second thread generates a corresponding data update request according to the triggered operation, and sends the data update request to the third thread, which performs full data update and status indication data modification based on the data update request. For example, when a user clicks on a data update control in a business system, the second thread determines the full data based on the user's click operation, generates a data update request based on the full data, and sends the data update request to the third thread. The third thread parses the data update request, obtains the full data, and updates the target memory block in an idle state based on the full data.
[0076] By creating a third thread dedicated to full data update and status indication data modification, the computer device can separate the trigger operation from the actual execution operation, so that the separated multiple trigger operations can be executed synchronously, and multiple execution operations can be executed asynchronously. By synchronously executing the trigger operation, when data update requirements are received from multiple business systems at the same time, a preliminary response can be made to multiple data update requirements based on multiple second threads, such as sending a prompt that the data update operation is being executed to multiple business systems at the same time, thereby improving the user experience; by asynchronously executing the data update requirements through the third thread, the probability of data asynchrony caused by multiple threads updating the same data at the same time can be reduced, thereby improving data security.
[0077] In the above data access method, the working status of the two paired target memory blocks is distinguished by the working status indication data, so that when the data read operation for the target memory block is triggered, the data can be read from the target memory block in the working status; when the data update operation for the target memory block is triggered, the target memory block in the idle status can be fully updated. In this way, the concurrent operation of data access and data update can be achieved under the premise of ensuring data security; in addition, when the full data update is completed, the target memory block in the idle status is set to the working status by modifying the status indication data, which can improve the real-time performance of the read data while ensuring concurrency.
[0078] In one embodiment, the data access method further includes: triggering environment initialization; when the environment is initialized, creating two target memory blocks with the same storage characteristics, and creating state indication data. The state indication data indicates that one of the two target memory blocks is in a working state, and indicates that the other target memory block is in an idle state.
[0079] The environment initialization refers to the process in which the computer device creates a target memory block and indicates data according to the data access requirement when the data access method is executed for the first time. In this embodiment, the created target memory blocks are specifically two memory blocks with the same storage structure and storage space.
[0080] Specifically, the computer device pre-stores an environment initialization trigger condition. When the environment initialization trigger condition is met, the computer device creates two target memory blocks with the same storage characteristics, and creates status indication data. Among them, the environment initialization trigger condition refers to the condition used to trigger the computer device to perform environment initialization. The environment initialization trigger condition can be freely set according to demand. For example, the environment initialization trigger condition can be for the computer device to switch from shutdown to startup; or for the business system to switch from shutdown to startup; or for the user to trigger the environment initialization control. Among them, the environment initialization control can specifically be a button or a hyperlink, etc.; it can also be a graphic code, such as a QR code or a barcode. The business system allows users to perform data access operations such as browsing, data downloading, and data updating.
[0081] In this embodiment, since the two created target memory blocks have the same storage characteristics, the consistency of the two target memory blocks can be guaranteed; since the created status indication data indicates that one of the two target memory blocks is in a working state and the other target memory block is in an idle state, the working state of the target memory blocks can be distinguished based on the status indication data.
[0082] In one embodiment, creating two target memory blocks with the same storage characteristics includes: creating a target memory block; obtaining the storage characteristics of the target memory block; the storage characteristics include storage space and storage structure; and based on the storage characteristics, copying another target memory block.
[0083] Specifically, when the trigger environment is initialized, the computer device obtains the storage characteristics of the target memory block to be created, and creates a target memory block based on the storage characteristics. The storage characteristics may be pre-stored in the computer device, or may be obtained by the user configuring the target memory block to be created when the trigger environment is initialized. The computer device obtains the storage characteristics of the created target memory block, and copies another matching target memory block based on the storage characteristics.
[0084] In one embodiment, during the process of configuring the target memory block to be created, the user can also specify the data to be stored, so that the computer device stores the specified data to be stored in a target memory block that has been created. For example, the user can specify that the data that is frequently accessed in the database is stored in a target memory block that has been created.
[0085] In this embodiment, the computer device only needs to copy the created target memory block to quickly obtain another target memory block with the same storage characteristics, thereby improving the efficiency of creating paired target memory blocks.
[0086] In one embodiment, the status indication data adopts a pointer variable; determining the target memory block of the working state based on the status indication data includes: determining the target memory block pointed to by the address stored in the pointer variable as the target memory block of the working state; determining the target memory block of the idle state based on the status indication data includes: in two paired target memory blocks, determining the target memory block not pointed to by the address stored in the pointer variable as the target memory block of the idle state.
[0087] Among them, the pointer variable refers to a variable that stores an address. In this embodiment, the address stored by the pointer variable is the memory address of the target memory block. The memory address refers to the address information used to access the target memory block, usually composed of multiple hexadecimal data, such as 0x00000000, or 0x00000000~0x000fffff. When the storage space of the target memory block is known, the computer device uses the address of the first storage unit in the target memory block as the memory address of the target memory block; when the storage space of the target memory block is unknown, the computer device uses the address of the first storage unit and the address of the last storage unit as the value boundary of the memory address value range. Among them, the storage unit refers to the smallest unit that constitutes the target memory block, usually used to store an 8-bit binary data. Different storage units have different addresses.
[0088] Specifically, the computer device obtains the memory address of one of the two paired target memory blocks, and stores the obtained memory address based on the pointer variable, thereby determining the target memory block pointed to by the address stored in the pointer variable as the target memory block in the working state; and determining the target memory block not pointed to by the address stored in the pointer variable as the target memory block in the idle state.
[0089] In this embodiment, the working status of the target memory block is distinguished by a pointer variable, so that the target memory block in the working status can be quickly obtained by subsequent addressing operations based on the pointer variable, thereby greatly improving the addressing efficiency of the target memory block.
[0090] In one embodiment, the target memory block in the idle state is set to the working state by modifying the state indication data, including: modifying the pointer variable so that the address stored in the pointer variable points to the target memory block in the idle state.
[0091] As described above, the pointer variable always points to the target memory block in the working state. Based on the pointer variable, while the first thread reads data from the target memory block in the working state, the second thread can also perform a full data update on the target memory block in the idle state. If the data read by the first thread is expected to have higher real-time performance, the target memory block in the idle state can be set to the working state by modifying the pointer variable when the full data update operation is completed.
[0092] Specifically, when the full data update is completed, the second thread obtains the memory address of the target memory block not pointed to by the pointer variable in the two paired target memory blocks, deletes the original address stored in the pointer variable, and stores the obtained memory address in the pointer variable. It can be understood that the modification operation of the pointer variable can also be performed by the third thread.
[0093] In one embodiment, when the trigger environment is initialized, the computer device creates two target memory blocks with the same storage characteristics, and records the memory addresses of the target memory blocks accordingly, so that the second thread can modify the pointer variable according to the recorded memory addresses. For example, when creating the target memory block, the computer device stores the memory addresses of the two paired target memory blocks in the cache, and when performing the pointer variable modification operation later, the memory address to be pointed to can be queried in the cache.
[0094] In this embodiment, when the full update is completed, the target memory block in the idle state is set to the working state, so that the data read by the first thread is the updated data, which greatly improves the real-time performance of the data.
[0095] In one embodiment, based on a data update operation, a full data update is performed on a target memory block in an idle state, including: when the data update operation specifies a data path, obtaining the data path; reading the full data according to the data path; and replacing all data in the target memory block in the idle state with the full data.
[0096] The data path is an access path for reading the full data to be updated to the target memory block. The data path can specifically be an access path to a database storing full data, an access path to a file storing full data, etc. When the full data is stored in a single data table, the access path to the database includes the table address of the data table where the full data is located; when the full data is stored in multiple data tables, the access path to the database includes not only the table addresses of the multiple data tables, but also the data identifier of the full data. For example, by adding a column "data identifier of full data" to the table, the full data can be queried in the data table storing the full data.
[0097] Specifically, when data needs to be updated for the target memory block, the computer device calls the second thread to trigger the data update operation, and obtains the pre-stored data path based on the called second thread. The second thread analyzes the acquired data path to obtain the path type pointed to by the data path. When the data path points to a database, the second thread reads the full data from the database according to the table address in the data path and the data identifier of the full data. When the data path points to a file, the second thread obtains the file according to the data path, and parses the file to obtain the full data recorded in the file. For example, the second thread parses the JSON (JavaScript Object Notation, JS object notation) string in the file to obtain the full data recorded in the JSON string. When the full data is obtained, the second thread determines the target memory block in the idle state through the status indication data, and replaces all the data in the target memory block in the idle state with the full data.
[0098] In this embodiment, the full amount of data is read based on the specified data path, which can improve the integrity of the full amount of data read. In addition, for the full amount of data stored in different storage methods, by deploying different data paths respectively, the reading requirements for full amount of data with multiple storage methods can be met.
[0099] In one embodiment, based on a data update operation, a full data update is performed on a target memory block in an idle state, including: when the data update operation specifies update data, obtaining the update data; based on the update data and the data in the target memory block in a working state, a full data update is performed on the target memory block in the idle state.
[0100] Specifically, when the updated data is obtained, the computer device calls the second thread to trigger the data update operation, and based on the triggered data update operation, obtains the updated data and all the data in the target memory block in the working state. For example, when the user inputs the updated data based on the business system, the computer device calls the second thread to obtain the input updated data, and at the same time, reads all the data in the target memory block in the working state based on the status indication data. Among them, the updated data refers to data with the same data identifier and different data content compared with the data in the target memory block in the working state. The second thread deletes the original data in the target memory block in the idle state, and based on the updated data and the data in the target memory block in the working state, performs a full data update on the target memory block in the idle state in which the original data is deleted.
[0101] In one embodiment, the second thread creates a temporary cache space for storing data of the target memory block in the working state, and updates the data in the temporary cache space based on the update data. When the update operation on the temporary cache space is completed, the second thread replaces all the data of the target memory block in the idle state with the data in the temporary cache space. When the update operation on the full amount of data of the target memory block in the idle state is completed, the second thread destroys the created temporary cache space.
[0102] In one embodiment, the second thread preferentially stores the updated data in the target memory block in the idle state from which the original data has been deleted, and then stores the data in the target memory block in the working state that has a different data identifier from the updated data in the target memory block in the idle state. It is easy to understand that the data in the target memory block in the working state can also be first stored in the target memory block in the idle state from which the original data has been deleted, and then the target memory block in the idle state is updated based on the updated data. This is not limited here.
[0103] In this embodiment, since the data of the target memory block in the working state has higher real-time performance than the data of the target memory block in the idle state, the full data can be obtained by combining the update data and the data in the target memory block in the working state, so that the data of the target memory block in the idle state can be updated based on the full data.
[0104] In one embodiment, based on the data update operation, a full data update is performed on the target memory block in the idle state, including: when the data update operation is a data insertion operation, determining the data to be written based on the data insertion operation; writing the data to be written into the target memory block in the working state; when the data to be written is written successfully, synchronizing the full amount of data in the target memory block in the working state to the target memory block in the idle state.
[0105] Specifically, when the data identifier of the updated data obtained by the second thread does not exist in the target memory block in the working state, it can be considered that the data update operation at this time is a data insertion operation, and the updated data obtained is the data to be written. The second thread determines the target memory block in the working state based on the state indication data, and writes the data to be written into the target memory block in the working state. The second thread determines whether the written data is written successfully. When the writing is successful, all the data in the target memory block in the working state is synchronized to the target memory block in the idle state. In one embodiment, the second thread reads the data to be written from the target memory block in the working state based on the data identifier of the data to be written, and when the reading is successful, it is determined that the data to be written is written successfully.
[0106] In this embodiment, since the data insertion operation will not change the data content of all the data stored in the target memory block, the data reading operation can still be performed on the target memory block in the working state while the data insertion operation is performed. This concurrent operation of data insertion and data reading enables the computer device to process different data access tasks at the same time, thereby improving the processing efficiency of data access tasks. In addition, since the data in the target internal block is obtained synchronously, the consistency of the data in the two target memory blocks can be guaranteed.
[0107] In one embodiment, the above-mentioned data access method also includes: when the data of the target memory block in the working state and the target memory block in the idle state are inconsistent, synchronizing the data in the target memory block in the working state to the target memory block in the idle state; when the data update operation is triggered, stopping the operation of synchronizing the data in the target memory block in the working state to the target memory block in the idle state.
[0108] Specifically, the computer device performs a difference analysis on the data in the target memory block in the working state and the data in the target memory block in the idle state. When the target memory block in the working state has data whose data identifier has not been stored in the target memory block in the idle state, the computer device writes the data that has not been stored into the target memory block in the idle state; when the target memory block in the working state has data whose data identifier has been stored in the target memory block in the idle state but the data content is inconsistent, the computer device updates the target memory block in the idle state based on the data with inconsistent data content. Furthermore, the computer device continuously monitors the triggering operation of the data update. When it is determined that the data update operation is triggered, the computer device stops updating the data in the target memory block in the working state or writing it into the target memory block in the idle state, and switches to executing the data update operation.
[0109] In this embodiment, the data in the target memory block in the working state is synchronized to the target memory block in the idle state between executing two adjacent data update operations, so that the data in the two target memory blocks can be kept consistent. Therefore, when the target memory block in the working state is unavailable due to a failure, the updated data can still be read from the target memory block in the idle state.
[0110] In a specific embodiment, Figure 7 As shown, the data access method provided by this application includes the following steps:
[0111] S702, when a data reading operation for a target memory block is triggered, the target memory block pointed to by the address stored in the pointer variable is determined as a target memory block in a working state, and data is read from the target memory block in the working state; the data reading operation is triggered by the first thread.
[0112] S704, when a data update operation for a target memory block is triggered, in the two paired target memory blocks, the target memory block not pointed to by the address stored in the pointer variable is determined as an idle target memory block; the data update operation is triggered by the second thread.
[0113] S706, when the data update operation specifies a data path, the data path is obtained, the full amount of data is read according to the data path, and all the data in the target memory block in the idle state is replaced with the full amount of data.
[0114] S708, when the data update operation specifies to update data, obtain the updated data; based on the updated data and the data in the target memory block in the working state, perform a full data update on the target memory block in the idle state.
[0115] S710, when the data update operation is a data insertion operation, determine the data to be written based on the data insertion operation, write the data to be written into the target memory block in the working state, and when the data to be written is written successfully, synchronize all the data in the target memory block in the working state to the target memory block in the idle state.
[0116] S712, when the full data update is completed, modify the pointer variable so that the address stored in the pointer variable points to the target memory block in the idle state; the full data update and modification of the pointer variable are executed by the second thread or the third thread.
[0117] S714, when the data of the target memory block in the working state and the target memory block in the idle state are inconsistent, synchronize the data in the target memory block in the working state to the target memory block in the idle state; when the data update operation is triggered, stop the operation of synchronizing the data in the target memory block in the working state to the target memory block in the idle state.
[0118] The above-mentioned data access method distinguishes the working status of the two paired target memory blocks through the working status indication data, so that when the data read operation for the target memory block is triggered, the data can be read from the target memory block in the working status; when the data update operation for the target memory block is triggered, the target memory block in the idle status can be fully updated. In this way, the concurrent operation of data access and data update can be realized under the premise of ensuring data security; in addition, when the full data update is completed, the target memory block in the idle status is set to the working status by modifying the status indication data, which can improve the real-time performance of the read data while ensuring concurrency.
[0119] In another specific embodiment, Figure 8 As shown, the data access method provided by this application includes the following steps:
[0120] S802, triggering environment initialization.
[0121] S804, when the environment is initialized, create a target memory block, obtain the storage characteristics of the target memory block, and based on the storage characteristics, copy another target memory block; and create status indication data; the storage characteristics include storage space and storage structure; the status indication data indicates that one of the two target memory blocks is in a working state, and indicates that the other target memory block is in an idle state.
[0122] S806, when a data read operation for a target memory block is triggered, a target memory block in a working state is determined based on the state indication data, and data is read from the target memory block in the working state.
[0123] S808, when a data update operation for a target memory block is triggered, determining a target memory block in an idle state based on the state indication data.
[0124] S810: Based on the data update operation, a full amount of data is updated to the target memory block in the idle state.
[0125] S812, when the full data update is completed, the target memory block in the idle state is set to the working state by modifying the state indication data.
[0126] The present application also provides an application scenario, and the application scenario applies the above data access method. Specifically, the application of the data access method in the application scenario is as follows:
[0127] This application scenario involves a terminal and a server, wherein the terminal runs a contact book application for querying and modifying the contact information of group members; the server is the background server of the contact book application, which is used to call threads to respond to contact information query requests and contact information modification requests sent by the terminal. When the trigger environment is initialized, the server creates two target memory blocks with the same storage characteristics for storing contact information, and creates a state indication data, and sets one of the two target memory blocks to a working state and the other to an idle state based on the state indication data.
[0128] When the server receives contact information query requests or contact information modification requests initiated by multiple users based on their respective terminals at the same time, the server counts the number of requests received and calls multiple threads to respond to the contact information query requests or contact information modification requests based on the number of requests. After the contact information modification request is responded to successfully, the target memory block in the idle state is set to the working state by modifying the status indication data.
[0129] For example, when user A initiates a query request for querying the contact information of member a based on the address book application, user B initiates a query request for querying the contact information of member b, and user C initiates a modification request for updating the contact information of member c, the server calls two first threads and one second thread according to the number of requests received: first thread a, first thread b, and second thread c, so that first thread a can determine the target memory block in the working state based on the status indication data, read the contact information of member a from the target memory block in the working state, and return the read contact information to user A; first thread b can determine the target memory block in the working state based on the status indication data, read the contact information of member b from the target memory block in the working state, and return the read contact information to user B; second thread c can determine the target memory block in the idle state based on the status indication data, and fully update the target memory block in the idle state according to the contact information of member c carried in the contact information modification request, and when the full update is completed, the status indication data is modified accordingly.
[0130] The present application also provides an application scenario, which applies the above-mentioned data access method.
[0131] Specifically, the application of the data access method in this application scenario is as follows:
[0132] This application scenario involves a terminal and a server, wherein an inventory query system is running in the terminal for querying the inventory of multiple materials. The server has two target memory blocks and a status indication data, wherein the target memory block stores the inventory information of popular materials, and the status indication data is used to set one of the two target memory blocks to a working state and the other to an idle state. During environment initialization, in order to reduce the frequency of terminal access to the database, the server pulls the inventory information of popular materials from the database and stores the inventory information of popular materials in the target memory block, so that when reading the inventory information, the terminal can preferentially search for the inventory information from the target memory block without frequently accessing the database, thereby reducing the access frequency of the database and improving the overall performance of the system. Among them, the inventory information of popular materials refers to information that is read by the terminal more than the preset threshold number of times during the statistical period.
[0133] When it is necessary to read inventory information of multiple materials, the terminal generates multiple inventory information reading requests based on the inventory information reading requirements, and sends the multiple inventory information reading requests to the server, so that the server calls multiple first threads to respond to the inventory information reading requests. The first thread determines the target memory block of the working state through the state indication data, reads the inventory information from the target memory block of the working state, and returns the read inventory information to the terminal.
[0134] In order to improve the real-time performance of inventory information, the second thread in the server pulls the latest inventory information from the database at regular intervals, and fully updates the target memory block in the idle state based on the pulled inventory information. When the full data update is completed, the second thread sets the target memory block in the idle state to the working state by modifying the state indication data.
[0135] It should be understood that although Figure 2 , 7 The steps in the flowcharts of and 8 are shown in sequence as indicated by arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 , 7 At least part of the steps in 8 may include multiple steps or multiple stages. These steps or stages do not necessarily have to be executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily one by one, but can be executed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0136] In one embodiment, Fig. 9 As shown, a data access device 900 is provided. The device can be a software module or a hardware module, or a combination of the two to become a part of a computer device. The device specifically includes: a data reading module 902, a data updating module 904 and a status indication data modification module 906, wherein:
[0137] The data reading module 902 is used to determine the target memory block in a working state based on the state indication data when a data reading operation for the target memory block is triggered, and read data from the target memory block in the working state; the data reading operation is triggered by the first thread.
[0138] The data update module 904 is used to determine the target memory block in an idle state based on the status indication data when a data update operation for the target memory block is triggered; based on the data update operation, perform a full data update on the target memory block in the idle state; the data update operation is triggered by the second thread.
[0139] The status indication data modification module 906 is used to set the target memory block in the idle state to the working state by modifying the status indication data when the full data update is completed; the full data update and the modification of the status indication data are executed by the second thread or the third thread.
[0140] In one embodiment, Fig.10As shown, the data access device 900 also includes an initialization module 908, which is used to trigger environment initialization; when the environment is initialized, two target memory blocks with the same storage characteristics are created, and status indication data is created; wherein, the status indication data indicates that one of the two target memory blocks is in a working state, and indicates that the other target memory block is in an idle state.
[0141] In one embodiment, the initialization module 908 is further used to create a target memory block; obtain storage characteristics of the target memory block; the storage characteristics include storage space and storage structure; and based on the storage characteristics, copy another target memory block.
[0142] In one embodiment, the data reading module 902 is also used to determine the target memory block pointed to by the address stored in the pointer variable as a target memory block in a working state; the determination of the target memory block in an idle state based on the state indication data includes: in the two paired target memory blocks, determining the target memory block not pointed to by the address stored in the pointer variable as a target memory block in an idle state.
[0143] In one embodiment, the state indication data modification module 906 is further used to modify the pointer variable so that the address stored in the pointer variable points to the target memory block in the idle state.
[0144] In one embodiment, the data update module 904 is also used to obtain the data path when the data update operation specifies a data path; read the full amount of data according to the data path; and replace all the data in the target memory block in the idle state with the full amount of data.
[0145] In one embodiment, the data update module 904 is also used to obtain the updated data when the data update operation specifies to update data; based on the updated data and the data in the target memory block in the working state, perform a full data update on the target memory block in the idle state.
[0146] In one embodiment, the data update module 904 is also used to determine the data to be written based on the data insertion operation when the data update operation is a data insertion operation; write the data to be written into the target memory block in the working state; when the data to be written is written successfully, synchronize the entire amount of data in the target memory block in the working state to the target memory block in the idle state.
[0147] In one embodiment, the above-mentioned data access device 900 also includes a synchronization module 910, which is used to synchronize the data in the target memory block in the working state to the target memory block in the idle state when the data of the target memory block in the working state and the target memory block in the idle state are inconsistent; when the data update operation is triggered, stop the operation of synchronizing the data in the target memory block in the working state to the target memory block in the idle state.
[0148] The specific definition of the data access device can be found in the definition of the data access method above, which will not be repeated here. Each module in the above data access device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0149] In one embodiment, a computer device is provided, which may be Figure 1 The internal structure diagram of the server 120 in FIG. 1 may be as follows: Fig.11 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data access data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data access method is implemented.
[0150] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0151] In one embodiment, the data access device provided by the present application can be implemented in the form of a computer program. The computer program can be Fig.11 The computer device is run on the computer device shown. The memory of the computer device can store various program modules that constitute the database migration evaluation device, such as: Fig. 9The data reading module, data updating module and status indication data modifying module shown in the figure. The computer program composed of various program modules enables the processor to execute the steps in the data access of various embodiments of the present application described in this specification.
[0152] For example, Fig.11 The computer device shown can be Fig. 9 The data reading module in the data access device shown executes step S202. The computer device can execute steps S204 and S206 through the data updating module. The computer device can execute step S208 through the status indication data modification module.
[0153] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above data access method. The steps of the data access method here may be the steps of the data access method in the above embodiments.
[0154] In one embodiment, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above data access method. The steps of the data access method here can be the steps in the data access method of each of the above embodiments.
[0155] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0156] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0157] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A data access method, characterized in that: The method comprises: Trigger environment initialization; When the environment is initialized, two target memory blocks with the same storage characteristics are created, and state indication data is created; The state indication data indicates that one of the two target memory blocks is in a working state, and indicates that the other target memory block is in an idle state; When a data read operation for a target memory block is triggered, a target memory block in a working state is determined based on the state indication data, and data is read from the target memory block in the working state; When a data update operation for a target memory block is triggered, determining a target memory block in an idle state based on the state indication data; Based on the data update operation, a full amount of data is updated to the target memory block in the idle state; when the data update operation is a data insertion operation, the data to be written is determined based on the data insertion operation; the data to be written is written into the target memory block in the working state; when the data to be written is successfully written, the data in the target memory block in the working state is fully synchronized to the target memory block in the idle state; When the full data update is completed, the target memory block in the idle state is set to the working state by modifying the state indication data.
2. The method according to claim 1, characterized in that: The environment initialization trigger conditions can be freely set according to needs.
3. The method according to claim 2, characterized in that The step of creating two target memory blocks having the same storage characteristics includes: Create a target memory block; Acquire storage characteristics of the target memory block; the storage characteristics include storage space and storage structure; Based on the storage characteristics, another target memory block is copied.
4. The method according to claim 1, characterized in that: The state indication data adopts a pointer variable; the target memory block of the working state is determined based on the state indication data, including: The target memory block pointed to by the address stored in the pointer variable is determined as the target memory block in the working state; The step of determining a target memory block in an idle state based on the state indication data comprises: In the two paired target memory blocks, the target memory block not pointed to by the address stored in the pointer variable is determined as a target memory block in an idle state.
5. The method according to claim 4, characterized in that The step of setting the target memory block in an idle state to a working state by modifying the state indication data comprises: The pointer variable is modified so that the address stored in the pointer variable points to the target memory block in the idle state.
6. The method according to claim 1, characterized in that The data reading operation is triggered by the first thread; the data updating operation is triggered by the second thread; the full data updating and the modifying of the status indication data are executed by the second thread or the third thread.
7. The method according to claim 1, characterized in that The updating of the entire amount of data to the target memory block in the idle state based on the data updating operation includes: When the data update operation specifies a data path, obtaining the data path; Read all the data according to the data path; All data in the target memory block in the idle state is replaced with the full amount of data.
8. The method according to claim 1, characterized in that The updating of the entire amount of data to the target memory block in the idle state based on the data updating operation includes: When the data update operation specifies update data, obtaining the update data; Based on the update data and the data in the target memory block in the working state, the target memory block in the idle state is fully updated with data.
9. The method according to claim 1, characterized in that: The method further comprises: Based on the data identifier of the data to be written, the data to be written is read from the target memory block in the working state, and when the reading is successful, it is determined that the data to be written is written successfully.
10. The method according to any one of claims 1 to 9, characterized in that The method further comprises: When the data of the target memory block in the working state is inconsistent with the data of the target memory block in the idle state, synchronizing the data in the target memory block in the working state to the target memory block in the idle state; When the data update operation is triggered, the operation of synchronizing the data in the target memory block in the working state to the target memory block in the idle state is stopped.
11. A data access device, characterized in that: The device comprises: An initialization module, used to trigger environment initialization; when the environment is initialized, two target memory blocks with the same storage characteristics are created, and state indication data is created; wherein the state indication data indicates that one of the two target memory blocks is in a working state, and indicates that the other target memory block is in an idle state; A data reading module, configured to determine the target memory block in a working state based on the state indication data when a data reading operation for the target memory block is triggered, and read data from the target memory block in the working state; A data update module is used for, when a data update operation for a target memory block is triggered, determining a target memory block in an idle state based on the state indication data; performing a full data update to the target memory block in the idle state based on the data update operation, and when the data update operation is a data insertion operation, determining data to be written based on the data insertion operation; writing the data to be written into the target memory block in a working state; when the data to be written is successfully written, synchronizing the data in the target memory block in the working state to the target memory block in the idle state in full; The status indication data modification module is used to set the target memory block in the idle state to the working state by modifying the status indication data when the full data update is completed.
12. The device according to claim 11, characterized in that The environment initialization trigger conditions can be freely set according to needs.
13. The device according to claim 11, characterized in that The data reading module is also used to determine the target memory block pointed to by the address stored in the pointer variable as the target memory block in the working state; the determination of the target memory block in the idle state based on the state indication data includes: in the two paired target memory blocks, determining the target memory block not pointed to by the address stored in the pointer variable as the target memory block in the idle state.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 10 are implemented.
15. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
