CN111143326B - Method, apparatus, computer device and storage medium for reducing database operations - Google Patents

Method, apparatus, computer device and storage medium for reducing database operations Download PDF

Info

Publication number
CN111143326B
CN111143326B CN201911365788.5A CN201911365788A CN111143326B CN 111143326 B CN111143326 B CN 111143326B CN 201911365788 A CN201911365788 A CN 201911365788A CN 111143326 B CN111143326 B CN 111143326B
Authority
CN
China
Prior art keywords
state
data
change
cache array
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911365788.5A
Other languages
Chinese (zh)
Other versions
CN111143326A (en
Inventor
谢滨泽
李如先
肖树德
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Original Assignee
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd filed Critical Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Priority to CN201911365788.5A priority Critical patent/CN111143326B/en
Publication of CN111143326A publication Critical patent/CN111143326A/en
Application granted granted Critical
Publication of CN111143326B publication Critical patent/CN111143326B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/217Database tuning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a method, a device, computer equipment and a storage medium for reducing database operation, wherein the method comprises the following steps: dividing the state of data in a database into a plurality of normalcies in advance, wherein at least one normalcy comprises a plurality of appointed states; creating a plurality of cache arrays in a memory, wherein each cache array corresponds to a specified state; when the state of data changes, acquiring the states before and after the data changes, and judging whether the states before and after the data changes belong to the same normal state and are designated states; if the data belong to the same normal state, the state of the data in the database is not updated; otherwise, updating the state of the data in the database; and deleting the ID of the data in the corresponding cache array if the state before the change is the designated state, and inserting the ID of the data in the corresponding cache array if the state after the change is the designated state. The method achieves the advantage of reducing database operations.

Description

Method, apparatus, computer device and storage medium for reducing database operations
Technical Field
The present invention relates to the field of databases, and in particular, to a method, an apparatus, a computer device, and a storage medium for reducing database operations using a cache array.
Background
At present, in the continuous development process of the service, the data state of the database is changed at any time, so that the data state in the database needs to be continuously updated, and the database update speed is too slow under the conditions of high-frequency change of the state and larger data volume or in the concurrent operation of multiple parties. In order to solve the above problems, an extended server is generally required to increase the speed, but the extended server not only requires a huge cost, but also increases the maintenance cost.
Disclosure of Invention
The invention aims to provide a method, a device, computer equipment and a storage medium for reducing database operation by using a cache array, and aims to solve the problems of higher input cost and higher maintenance cost for improving the speed of a database in the prior art.
In a first aspect, an embodiment of the present invention provides a method for reducing database operations using a cache array, including:
dividing the state of data in a database into a plurality of normalcies in advance, wherein at least one normalcy comprises a plurality of appointed states;
creating a plurality of cache arrays in a memory, wherein each cache array corresponds to a specified state;
when the state of the data changes, acquiring the state before the data change and the state after the data change, judging whether the state before the data change and the state after the data change belong to the same normal state, and judging whether the state before the data change and the state after the data change are designated states;
if the data belong to the same normal state, the state of the data in the database is not updated; deleting the ID of the data in the cache array corresponding to the state before the change, and inserting the ID of the data in the cache array corresponding to the state after the change;
if the data do not belong to the same normal state, updating the state of the data in the database; meanwhile, if the state before the change is the designated state, deleting the ID of the data in the corresponding cache array, and if the state after the change is the designated state, inserting the ID of the data in the corresponding cache array.
In a second aspect, an embodiment of the present invention provides an apparatus for reducing database operations using a cache array, including:
the dividing unit is used for dividing the state of the data in the database into a plurality of normal states in advance, wherein at least one normal state comprises a plurality of specified states;
the system comprises a creation unit, a storage unit and a storage unit, wherein the creation unit is used for creating a plurality of cache arrays in a memory, and each cache array corresponds to a specified state;
the judging unit is used for acquiring the state before the data change and the state after the data change when the state of the data change, judging whether the state before the data change and the state after the data change belong to the same normal state or not, and judging whether the state before the data change and the state after the data change are designated states or not;
the first processing unit is used for not updating the state of the data in the database if the first processing unit belongs to the same normal state; deleting the ID of the data in the cache array corresponding to the state before the change, and inserting the ID of the data in the cache array corresponding to the state after the change;
the second processing unit is used for updating the state of the data in the database if the data do not belong to the same normal state; meanwhile, if the state before the change is the designated state, deleting the ID of the data in the corresponding cache array, and if the state after the change is the designated state, inserting the ID of the data in the corresponding cache array.
In a third aspect, an embodiment of the present invention further provides a computer apparatus, which includes a memory, a processor, and a computer program stored on the memory and capable of running on the processor, where the processor implements the method for reducing database operations using a cache array according to the first aspect when the processor executes the computer program.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores a computer program, where the computer program when executed by a processor causes the processor to perform the method for reducing database operations using a cache array according to the first aspect.
The invention discloses a method for reducing database operations by using a cache array, wherein the method comprises the following steps: dividing the state of data in a database into a plurality of normalcies in advance, wherein at least one normalcy comprises a plurality of appointed states; creating a plurality of cache arrays in a memory, wherein each cache array corresponds to a specified state; when the state of the data changes, acquiring the state before the data change and the state after the data change, judging whether the state before the data change and the state after the data change belong to the same normal state, and judging whether the state before the data change and the state after the data change are designated states; if the data belong to the same normal state, the state of the data in the database is not updated; deleting the ID of the data in the cache array corresponding to the state before the change, and inserting the ID of the data in the cache array corresponding to the state after the change; if the data do not belong to the same normal state, updating the state of the data in the database; meanwhile, if the state before the change is the designated state, deleting the ID of the data in the corresponding cache array, and if the state after the change is the designated state, inserting the ID of the data in the corresponding cache array. According to the method, the buffer array is added to serve as the buffer for updating the data state, so that the times of operating the database are reduced, the expenditure of the database is reduced, and the response speed of the database is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart illustrating a method for reducing database operations using a cache array according to an embodiment of the present invention;
FIG. 2 is a schematic block diagram of an apparatus for reducing database operations using a cache array according to an embodiment of the present invention;
fig. 3 is a schematic block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for reducing database operations by using a cache array according to an embodiment of the present invention;
as shown in fig. 1, the method includes steps S101 to S105.
S101, dividing the state of data in a database into a plurality of normalcies in advance, wherein at least one normalcy comprises a plurality of appointed states.
In this embodiment, with the development of time and business, the data volume in the database is continuously increased, and in order to better sort and query the data, the state of the data in the database is divided into a plurality of normal states in advance, and the normal states can be further divided into a plurality of designated states. The data in the database is stored in a corresponding normal form, so that the number of data states in the database can be reduced, and the number of times of updating the data states in the database is reduced.
For example, the state of data in the database may be divided into a first normalcy, a second normalcy, and a third normalcy; obviously, the normal type and number of the partitions can be adjusted according to the specific scene and the specific service.
Further, at least one of the normals may be divided into a plurality of specified states, for example, the second normals may further be divided into a first specified state, a second specified state, a third specified state, a fourth specified state and a fifth specified state, that is, the second normals include: the first specified state, the second specified state, the third specified state, the fourth specified state, and the fifth specified state; obviously, the types and the number of the specified states divided by the normal state can be adjusted according to specific scenes and specific services; of course, a normal state may also have only one state, i.e., a normal state refers to a specific state.
Further, in order to reduce the operation on the database to a greater extent, the state of the data can be divided into the normal states as much as possible, so that the number of the normal states can be reduced, and when the data state changes, the update operation of the data state in the database can be reduced to a greater extent.
Further, in order to reduce the operation on the database to a greater extent, the database can be further optimized according to the characteristics of the data, and for the condition that the change frequency of some data states is greater, the data states can be divided into a certain normal state, or for some data with smaller data quantity, the states of the data can be divided into a certain normal state, so that the operation on the database can be reduced, and the operation efficiency is improved.
For example, assume that the states of the data are 10 in total: "unused", "normal", "in audit", "audit not passed", "audit passed", "in review", "review not passed", "review passed", "abnormal", "completed".
The 8 states of normal, audit failed, audit passed, review in review, review failed, review passed and abnormal have a relatively high frequency of change and a relatively small data volume. Therefore, the state of data in the database is now divided into 3 normalcies: a first normal state, a second normal state, and a third normal state, wherein the first normal state is an "unused" state; the second normalcy includes: the system comprises 8 states of normal state, audit non-passing state, audit non-passing state, rechecking passing state and abnormal state, wherein each state in the 8 states is a designated state; the third normal state is the "complete" state. Thus, when one data is stored in the database, if the state of the data is any one of "normal", "in audit", "audit failed", "audit passed", "in review", "review failed", "review passed" and "abnormal", the storage state of the data in the database is the second normal state, so that the number of the data states in the database is reduced.
S102, creating a plurality of cache arrays in a memory, wherein each cache array corresponds to a specified state;
because the data state in the database needs to be updated according to the change of the data every time the data state changes, a series of operations such as connection creation, reading and writing lock addition, data updating, lock releasing, connection closing and the like are needed to update the data state in the database every time, and the database updating speed is slow when the data state changes at high frequency and the concurrent operation of multiple parties occurs.
By creating several cache arrays in the memory, each specified state (multiple specified states in normal state) corresponds to one cache array. The cache array may contain an ID for the data in the corresponding specified state, which may be maintained in the form of a list. When the state of the data changes, the corresponding cache array in the memory can be modified, wherein the modification mode can be deleting the ID of certain data or inserting the ID of certain data.
By setting the cache array, in the process of updating the data state, especially under the condition of high-frequency change and multiparty concurrency of data, only the updating operation is needed in the memory without accessing the database, so that the updating pressure of the database is reduced.
S103, when the state of the data changes, acquiring the state before the data change and the state after the data change, and judging whether the state before the data change and the state after the data change belong to the same normal state or not and judging whether the state before the data change and the state after the data change are the designated state or not.
In this embodiment, when the state of the data changes, it is required to determine whether the state of the data in the database needs to be updated and whether the cache array needs to be modified according to the changing situation.
In the database, the update of the data state can only be updated from one normal state to another normal state, so this step needs to confirm whether the state of the data changes from one normal state to another normal state or still belongs to the same normal state. For example, a state before a data change is a "normal" state, and a state after the data change is an "audit" state, and both the states are designated states in the second normal state, so that the state before the change and the state after the change belong to the same normal state. Or, the state before the change of one data is the normal state, the state after the change is the finished state, and one of the two states is the appointed state under the second normal state, and the other is the third normal state, so the state before the change and the state after the change do not belong to the same normal state.
In the cache array, the update of the data state is to update from the cache array corresponding to one specified state to the cache array corresponding to another specified state, so that the step needs to confirm whether the state before the change of the data and the state after the change are the specified states. For example, the state before one data change is the "normal" state, the state after the change is the "checking" state, and both the state before the change and the state after the change are the designated states because both the states are the designated states in the second normal state. Or, one state before the data change is a "normal" state, and the state after the data change is a "complete" state, and since one of the two states is a designated state in the second normal state and the other is the third normal state, the state before the data change is the designated state, and the state after the data change is not the designated state.
S104, if the data belong to the same normal state, not updating the state of the data in the database; and deleting the ID of the data in the cache array corresponding to the state before the change, and inserting the ID of the data in the cache array corresponding to the state after the change.
If the state before the data change and the state after the change belong to the same normal state, the state before the change and the state after the change are necessarily the specified state in the same normal state, that is, the state change of the data is changed from one specified state in the same normal state to another specified state.
Specifically, for example, the state before the data change is the "in-audit" specified state in the second normal state, and the state after the data change is the "in-audit failed" specified state in the second normal state, so that the data state change belongs to the change between the specified states in the second normal state, that is, the state before the data change and the state after the data change are confirmed to belong to the same normal state, so that the data state does not need to be updated in the database.
Further, the ID of the data is a unique mark of the data, and the cache array stores the ID of the data.
The precondition of this step is that the state before the change and the state after the change belong to the same normal state, so the state before the change and the state after the change of the data are both specified states, so the cache arrays corresponding to the two specified states need to be modified in the following modification modes: assuming that the state before the change is the first designated state, the corresponding cache array is the first cache array, the state after the change is the second designated state, and the corresponding cache array is the second cache array, then the ID of the data needs to be deleted from the first cache array, the ID of the data is inserted into the second cache array, and the effect that the ID of the data is moved from the first cache array to the second cache array is actually achieved. That is, when a data is changed from one specified state to another, it changes between the two cache arrays in memory.
S105, if the data do not belong to the same normal state, updating the state of the data in the database; meanwhile, if the state before the change is the designated state, deleting the ID of the data in the corresponding cache array, and if the state after the change is the designated state, inserting the ID of the data in the corresponding cache array.
If the state before the change of the data and the state after the change do not belong to the same normal state, the state before the change may be a designated state or not; similarly, the changed state may or may not be the designated state. In this case, the state of the data in the database needs to be updated, but the cache array does not necessarily need to be modified, and it is particularly necessary to confirm whether the state before and after the change of the data is a specified state.
If the state of the data before the change is the designated state, the cache array corresponding to the designated state needs to be modified, namely the ID of the data is deleted from the cache array, and it is required to be noted that whether the state of the data after the change is the designated state does not affect the modification of the cache array. Similarly, if the changed state of the data is the designated state, the cache array corresponding to the designated state needs to be modified, in which the ID of the data is inserted into the cache array, and it should be noted that whether the state of the data before the change is the designated state does not affect the modification of the cache array.
For example, the state before the data change is an "unused" state, and the state after the change is an "audit pass" state; the "unused" state belongs to the first normal state, and the "audit passing" state belongs to the second normal state, so that the state before the data change and the state after the data change do not belong to the same normal state, and the data state in the database needs to be updated, namely, the data state is updated from the first normal state to the second normal state. Because the "audit pass" state is a specified state, the "audit pass" state stores a corresponding cache array in the memory, and the "unused" state does not have a corresponding cache array in the memory, so that the ID of the data needs to be inserted into the cache array corresponding to the "audit pass" state, and deletion processing of the ID in any cache array is not required.
Of course, there may be a fourth normal state, and the fourth normal state also has a plurality of designated states, and if the state of a data is updated from the second normal state to the fourth normal state, then the state of the data in the database needs to be updated at the same time, and two cache arrays in the memory need to be modified.
In one embodiment, when an instruction of newly adding data is received, setting the state of the data to an initial state, acquiring a normal state to which the initial state belongs, and storing the data into the database according to the normal state.
In this embodiment, the normalcy of the initial state is preset, and when the data is newly added, the state of the data is only required to be set as the initial state, and then the data is stored in the database according to the normalcy of the initial state.
In an embodiment, when the instruction of newly adding data is received, setting a state of the data to an initial state, acquiring a normal state to which the initial state belongs, and then storing the data in the database according to the normal state, and further including:
and judging whether the initial state is a designated state, if so, storing the ID of the data into a corresponding cache array.
In this embodiment, if the normal state to which the newly added data belongs is divided into a plurality of specified states, the specified states of the initial state are continuously matched in the normal state to which the newly added data belongs, and after the specified states are determined, the ID of the newly added data is inserted into the cache array corresponding to the specified states.
In the embodiment of the invention, when the data state changes, the data state can be updated into the cache array, so that the operation of updating the data state in the database can be reduced, the database resource is saved, and the maintenance cost is reduced.
The method for reducing database operations by using the cache array further comprises the following steps:
when an instruction for inquiring data is received, inquiring corresponding data in a database, and matching the ID of the inquired data with the IDs in each cache array;
if the matching is successful, the state of the corresponding data is replaced by the designated state, and the queried data is returned.
In this embodiment, according to the received query instruction, the corresponding data is found in the database, the ID of the data is obtained, and the matching is performed in the memory through the ID of the data, so that the matching is aimed at querying the real state of the data, because the normal state cannot represent the real state of the data, if the returned data is only the normal state, the accurate information cannot be provided to the user. Therefore, in the embodiment of the invention, the IDs of the data need to be matched in each cache array of the memory, and if the matching is successful, the state of the corresponding data needs to be replaced by the designated state. For example, the state of one data in the database is the second normal state, and the ID of the data is stored in the cache array corresponding to the "audit passing" state, so that the state of the data can be replaced from the second normal state to the "audit passing" state at this time, and then the data is returned. Of course, if the state of a data in the database is the first normal state, the state in the database can be returned directly because the ID of the data is not stored in any cache array in the memory. This is because the first normal state has only an "unused" state and has a one-to-one correspondence with the two states, so the returned first normal state represents the "unused" state.
In one embodiment, the method for reducing database operations by using the cache array further includes:
when an instruction for inquiring data is received and the state of the data is a designated state, acquiring the ID of the data in a corresponding cache array;
and inquiring corresponding data in a database according to the ID of the data, and returning.
In this embodiment, when an instruction for querying data is received and it is clear that the state of the data is a specified state, the ID of the data may be directly obtained from the cache array corresponding to the specified state, because the IDs of all the data in the specified state are stored in the cache array, and then the data is queried in the database according to the IDs of the data, and then returned, thereby greatly improving the data querying efficiency.
In one embodiment, the state of the queried data is replaced with a specified state and returned.
In this embodiment, since the data is in the specified state, the state of the data stored in the database is a normal state, and at this time, it is necessary to replace the normal state with the specified state and return the data.
In one embodiment, the state of the queried data is replaced with a corresponding specified state, and the data returned to each specified state is classified.
In this embodiment, in the process of simultaneously querying data in multiple specified states, in order to make the returned data more orderly and convenient to query, when multiple data are queried, the state of each data is replaced by the corresponding specified state, and the data in each specified state are re-classified and returned, so that the queried data will be the data in different specified states.
Referring to fig. 2, fig. 2 is a schematic block diagram of an apparatus 200 for reducing database operations using a cache array according to an embodiment of the present invention, where the apparatus 200 may include: a dividing unit 201, a creating unit 202, a judging unit 203, a first processing unit 204, and a second processing unit 205.
A dividing unit 201, configured to divide a state of data in a database into a plurality of normalcies in advance, where at least one normalcy includes a plurality of specified states;
a creating unit 202, configured to create a plurality of cache arrays in a memory, where each cache array corresponds to a specified state;
a judging unit 203, configured to obtain a state before the change and a state after the change of the data when the state of the data changes, and judge whether the state before the change and the state after the change belong to the same normal state, and judge whether the state before the change and the state after the change are specified states;
the first processing unit 204 is configured to not update the state of the data in the database if the data belong to the same normal state; and deleting the ID of the data in the cache array corresponding to the state before the change, and inserting the ID of the data in the cache array corresponding to the state after the change.
The second processing unit 205 is configured to update the state of the data in the database if the data do not belong to the same normal state; meanwhile, if the state before the change is the designated state, deleting the ID of the data in the corresponding cache array, and if the state after the change is the designated state, inserting the ID of the data in the corresponding cache array.
The device completes the update of partial data states in the cache array by creating a plurality of cache arrays, reduces the operation of updating the database, saves database resources and reduces maintenance cost.
In one embodiment, the apparatus 200 for reducing database operations using a cache array further comprises:
and the new adding unit is used for setting the state of the data into an initial state when receiving an instruction of adding the data, acquiring a normal state to which the initial state belongs, and storing the data into the database according to the normal state.
In one embodiment, the apparatus 200 for reducing database operations using a cache array further comprises:
and the caching unit is used for judging whether the initial state is a specified state, and if so, storing the ID of the data into a corresponding caching array.
In one embodiment, the apparatus 200 for reducing database operations using a cache array further comprises:
the matching unit is used for inquiring corresponding data in the database when receiving an instruction for inquiring the data, and matching the ID of the inquired data with the IDs in the cache arrays;
and the replacement return unit is used for replacing the state of the corresponding data with the designated state if the matching is successful and returning the queried data.
In one embodiment, the apparatus 200 for reducing database operations using a cache array further comprises:
the acquisition unit is used for acquiring the ID of the data in the corresponding cache array when an instruction for inquiring the data is received and the state of the data is a designated state;
and the direct return unit is used for inquiring the corresponding data in the database according to the ID of the data and returning.
In an embodiment, the direct return unit comprises:
and the replacing unit is used for replacing the state of the queried data with the designated state and returning.
In one embodiment, the state of the data to be queried includes a plurality of specified states, and the replacement unit includes:
and the classification unit is used for replacing the state of the queried data with the corresponding specified state and classifying the data returned to each specified state.
Since the embodiments of the apparatus portion and the embodiments of the method portion correspond to each other, the embodiments of the apparatus portion are referred to the description of the embodiments of the method portion, and are not repeated herein.
The above-described means for reducing database operations using a cache array may be implemented in the form of a computer program that is executable on a computer device as shown in fig. 3.
Referring to fig. 3, fig. 3 is a schematic block diagram of a computer device according to an embodiment of the present invention. The computer device 300 includes a processor 302, a memory, and a network interface 305, which are connected by a system bus 301, wherein the memory may include a non-volatile storage medium 303 and an internal memory 304.
The non-volatile storage medium 303 may store an operating system 3031 and a computer program 3032. The computer program 3032, when executed, causes the processor 302 to perform a method for reducing database operations using a cache array.
The processor 302 is used to provide computing and control capabilities to support the operation of the overall computer device 300.
The internal memory 304 provides an environment for the execution of a computer program 3032 in the non-volatile storage medium 303, which computer program 3032, when executed by the processor 302, causes the processor 302 to perform a method of reducing database operations using a cache array.
The network interface 305 is used for network communication, such as providing for transmission of data information, etc. It will be appreciated by those skilled in the art that the structure shown in FIG. 3 is merely a block diagram of some of the structures associated with the present inventive arrangements and does not constitute a limitation of the computer device 300 to which the present inventive arrangements may be applied, and that a particular computer device 300 may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
Those skilled in the art will appreciate that the embodiment of the computer device shown in fig. 3 is not limiting of the specific construction of the computer device, and in other embodiments, the computer device may include more or less components than those shown, or certain components may be combined, or a different arrangement of components. For example, in some embodiments, the computer device may include only a memory and a processor, and in such embodiments, the structure and function of the memory and the processor are consistent with the embodiment shown in fig. 3, and will not be described again.
It should be appreciated that in embodiments of the present invention, the processor 302 may be a Central processing unit (Central ProcessingUnit, CPU), the processor 302 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf Programmable gate arrays (FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In another embodiment of the invention, a computer-readable storage medium is provided. The computer readable storage medium may be a non-volatile computer readable storage medium. The computer readable storage medium stores a computer program, wherein the computer program when executed by a processor implements a method of reducing database operations using a cache array according to an embodiment of the present invention.
The storage medium is a physical, non-transitory storage medium, and may be, for example, a U-disk, a removable hard disk, a Read-only memory (ROM), a magnetic disk, or an optical disk.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (6)

1. A method for reducing database operations using a cache array, comprising:
dividing the state of data in a database into a plurality of normalcies in advance, wherein at least one normalcy comprises a plurality of appointed states;
creating a plurality of cache arrays in a memory, wherein each cache array corresponds to a specified state;
when the state of the data changes, acquiring the state before the data change and the state after the data change, judging whether the state before the data change and the state after the data change belong to the same normal state, and judging whether the state before the data change and the state after the data change are designated states;
if the data belong to the same normal state, the state of the data in the database is not updated; deleting the ID of the data in the cache array corresponding to the state before the change, and inserting the ID of the data in the cache array corresponding to the state after the change;
if the data do not belong to the same normal state, updating the state of the data in the database; meanwhile, if the state before the change is the appointed state, deleting the ID of the data in the corresponding cache array, and if the state after the change is the appointed state, inserting the ID of the data in the corresponding cache array;
when an instruction for inquiring data is received, inquiring corresponding data in a database, and matching the ID of the inquired data with the IDs in each cache array; if the matching is successful, the state of the corresponding data is replaced by a designated state, and the queried data is returned;
when an instruction for inquiring data is received and the state of the data is a designated state, acquiring the ID of the data in a corresponding cache array; inquiring corresponding data in a database according to the ID of the data, and returning;
the method comprises the steps of inquiring corresponding data in a database according to the ID of the data, returning the data, and comprises the following steps: replacing the state of the queried data with a designated state, and returning;
the state of the data to be queried comprises a plurality of specified states, the state of the queried data is replaced by the specified state, and the state is returned, and the method comprises the following steps: and replacing the state of the queried data with the corresponding specified state, and classifying the data returned to each specified state.
2. The method for reducing database operations using a cache array of claim 1, further comprising:
when an instruction of newly adding data is received, setting the state of the data into an initial state, acquiring a normal state to which the initial state belongs, and storing the data into the database according to the normal state.
3. The method for reducing database operations using a cache array of claim 2, further comprising:
and judging whether the initial state is a designated state, if so, storing the ID of the data into a corresponding cache array.
4. An apparatus for reducing database operations using a cache array, comprising:
the dividing unit is used for dividing the state of the data in the database into a plurality of normal states in advance, wherein at least one normal state comprises a plurality of specified states;
the system comprises a creation unit, a storage unit and a storage unit, wherein the creation unit is used for creating a plurality of cache arrays in a memory, and each cache array corresponds to a specified state;
the judging unit is used for acquiring the state before the data change and the state after the data change when the state of the data change, judging whether the state before the data change and the state after the data change belong to the same normal state or not, and judging whether the state before the data change and the state after the data change are designated states or not;
the first processing unit is used for not updating the state of the data in the database if the first processing unit belongs to the same normal state; deleting the ID of the data in the cache array corresponding to the state before the change, and inserting the ID of the data in the cache array corresponding to the state after the change;
the second processing unit is used for updating the state of the data in the database if the data do not belong to the same normal state; meanwhile, if the state before the change is the appointed state, deleting the ID of the data in the corresponding cache array, and if the state after the change is the appointed state, inserting the ID of the data in the corresponding cache array;
the matching unit is used for inquiring corresponding data in the database when receiving an instruction for inquiring the data, and matching the ID of the inquired data with the IDs in the cache arrays; the replacement return unit is used for replacing the state of the corresponding data with a designated state if the matching is successful, and returning the queried data;
the acquisition unit is used for acquiring the ID of the data in the corresponding cache array when an instruction for inquiring the data is received and the state of the data is a designated state; the direct return unit is used for inquiring corresponding data in the database according to the ID of the data and returning the data;
the direct return unit includes: the replacing unit is used for replacing the state of the queried data with a designated state and returning the state;
the state of the data to be queried includes a plurality of specified states, and the replacement unit includes: and the classification unit is used for replacing the state of the queried data with the corresponding specified state and classifying the data returned to each specified state.
5. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the computer program implements the method of reducing database operations using a cache array as claimed in any one of claims 1 to 3.
6. A computer readable storage medium storing a computer program which when executed by a processor causes the processor to perform the method of reducing database operations using a cache array as claimed in any one of claims 1 to 3.
CN201911365788.5A 2019-12-26 2019-12-26 Method, apparatus, computer device and storage medium for reducing database operations Active CN111143326B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911365788.5A CN111143326B (en) 2019-12-26 2019-12-26 Method, apparatus, computer device and storage medium for reducing database operations

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911365788.5A CN111143326B (en) 2019-12-26 2019-12-26 Method, apparatus, computer device and storage medium for reducing database operations

Publications (2)

Publication Number Publication Date
CN111143326A CN111143326A (en) 2020-05-12
CN111143326B true CN111143326B (en) 2023-08-18

Family

ID=70520451

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911365788.5A Active CN111143326B (en) 2019-12-26 2019-12-26 Method, apparatus, computer device and storage medium for reducing database operations

Country Status (1)

Country Link
CN (1) CN111143326B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111782667A (en) * 2020-06-22 2020-10-16 成都校精灵科技有限公司 MongoDB updating data driving method, system and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7526481B1 (en) * 1999-04-19 2009-04-28 Oracle International Corporation Web servers with queryable dynamic caches
CN105354317A (en) * 2015-11-12 2016-02-24 携程计算机技术(上海)有限公司 Hotel database updating method and system
CN108549704A (en) * 2018-04-18 2018-09-18 厦门市美亚柏科信息股份有限公司 Distributive type preprocess method, device, equipment and the readable medium of data packet

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9477609B2 (en) * 2013-04-22 2016-10-25 Sap Se Enhanced transactional cache with bulk operation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7526481B1 (en) * 1999-04-19 2009-04-28 Oracle International Corporation Web servers with queryable dynamic caches
CN105354317A (en) * 2015-11-12 2016-02-24 携程计算机技术(上海)有限公司 Hotel database updating method and system
CN108549704A (en) * 2018-04-18 2018-09-18 厦门市美亚柏科信息股份有限公司 Distributive type preprocess method, device, equipment and the readable medium of data packet

Also Published As

Publication number Publication date
CN111143326A (en) 2020-05-12

Similar Documents

Publication Publication Date Title
CN108564470B (en) Transaction distribution method for parallel building blocks in block chain
US20160188227A1 (en) Method and apparatus for writing data into solid state disk
US11232073B2 (en) Method and apparatus for file compaction in key-value store system
CN104850565B (en) A kind of metadata management method based on K-V storage systems
CN110168532B (en) Data updating method and storage device
CN107423387A (en) The method and apparatus of table is divided in a kind of point storehouse based on middleware
US11100047B2 (en) Method, device and computer program product for deleting snapshots
CN111221840B (en) Data processing method and device, data caching method, storage medium and system
CN110851474A (en) Data query method, database middleware, data query device and storage medium
CN109241193B (en) Distributed database processing method and device, and server cluster
CN113127848A (en) Storage method of permission system data and related equipment
CN108427736B (en) Method for querying data
US10642817B2 (en) Index table update method, and device
CN113485635A (en) Data storage method, device, equipment and storage medium
CN111143326B (en) Method, apparatus, computer device and storage medium for reducing database operations
CN105930178A (en) Configurable parameter dynamic loading method and system
US10365850B2 (en) Method of storing data, information processing apparatus and non-transitory computer-readable storage medium
CN104598652B (en) A kind of data base query method and device
CN112000698B (en) Log recording method and device, storage medium and electronic device
CN115687359A (en) Data table partitioning method and device, storage medium and computer equipment
CN114297196A (en) Metadata storage method and device, electronic equipment and storage medium
CN114443598A (en) Data writing method and device, computer equipment and storage medium
CN112000671A (en) Block chain-based database table processing method, device and system
CN115210694A (en) Data transmission method and device
CN116186046B (en) Device data modification method and device, computer device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant