CN107577775A - One kind reads data method, device, electronic equipment and readable storage medium storing program for executing - Google Patents
One kind reads data method, device, electronic equipment and readable storage medium storing program for executing Download PDFInfo
- Publication number
- CN107577775A CN107577775A CN201710805732.1A CN201710805732A CN107577775A CN 107577775 A CN107577775 A CN 107577775A CN 201710805732 A CN201710805732 A CN 201710805732A CN 107577775 A CN107577775 A CN 107577775A
- Authority
- CN
- China
- Prior art keywords
- data
- version information
- database
- cached version
- buffer zone
- 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.)
- Granted
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiments of the invention provide one kind to read data method, device, electronic equipment and computer-readable recording medium.The above method includes:Receive the reading instruction of corresponding first object data;Obtain the first current database data version information of database, database purchase last revision data current the first data cached version information of the second database data version information and buffer zone;According to the first database data version information and the second database data version information, the second data cached version information is generated;Judge whether the first data cached version information and the second data cached version information are identical;If the first data cached version information differs with the second data cached version information, first object data are read from database.Using reading data method provided in an embodiment of the present invention, the data read are identical with data currently stored in database, can improve the degree of accuracy of the data read.
Description
Technical field
The present invention relates to data reading techniques field, more particularly to one kind read data method, device, electronic equipment and
Computer-readable recording medium.
Background technology
With the fast development of network technology, in order to accelerate to access the speed of data, it will usually will be frequent in database
The data of access are stored in buffer zone.Read instruction startup thread and read buffer zone first, if not deposited in buffer zone
In the data to be read, then reading database obtains the data, then writes the data into buffer zone.Relative to directly from number
According to data are read in storehouse, read buffer zone and obtain the speed of data faster.When the data in database are changed, in order to protect
Card is identical with the data in database from the data that buffer zone is read, existing to read comprising the following steps that for data method:
When changing data, write instruction starts thread and deletes corresponding data in buffer zone, and the data after renewal are then write number
According to storehouse;When reading data, due to the data being not present in buffer zone, read instruction startup thread reading database and updated
Data afterwards, and the data after renewal are write buffer zone, read next time in the data and database that buffer zone obtains
The data of storage are identical.
However, inventor has found that at least there are the following problems for prior art during the present invention is realized:
In the concurrent scene of thread, if two threads of A, B will modify to the data item of certain in database simultaneously,
And thread A and thread B have deleted corresponding data in caching.Next, thread A is first the data item in database
Content modification is data A, and now, another thread C needs to read the data item, due to the data item being not present in buffer zone,
Then can reading database obtain data A, and data A write buffer zone, then, thread B is the data item in database
Content modification is data B.Now, the content of the data item is data A in buffer zone, and the content of the data item is in database
Data B, so, when again reading off the data item, data A can be read from buffer zone, the data read and data occurs
The situation that data in storehouse differ, the degree of accuracy for reading data can be caused relatively low.
The content of the invention
The purpose of the embodiment of the present invention, which is to provide, a kind of reads data method, device, electronic equipment and computer-readable
Storage medium, it is identical with the data in database with the data that guarantee is read, improve the degree of accuracy of the data read.Specifically
Technical scheme is as follows:
In a first aspect, in order to achieve the above object, the embodiment of the invention discloses one kind to read data method, methods described
Including:
Receive the reading instruction of corresponding first object data;
Obtain the last revision data of the first current database data version information of database, the database purchase
The the first data cached version information of second database data version information and buffer zone currently;
It is slow according to the first database data version information and the second database data version information, generation second
Deposit data version information;
Judge whether the described first data cached version information and the described second data cached version information are identical;
If the first data cached version information differs with the described second data cached version information, from the number
The first object data are read according to storehouse.
Optionally, methods described also includes:
If the first data cached version information is identical with the described second data cached version information, from the caching
Read the first object data in region.
Optionally, described after the database reads the first object data, methods described also includes:
Data currently stored in the database are write into the buffer zone.
Optionally, methods described also includes:
Receive the write instruction of corresponding second target data;
The buffer zone current the 3rd data cached version information and the 4th data cached version information are obtained, its
In, the 4th data cached version information is according to the 3rd current database data version information of the database and described
The 4th database data version information generation of the last revision data of database purchase;
Second target data is write into the database, and generates the 5th database data version information;
The 5th database data version information is arranged to the current version information of the database;
Second target data is write into the buffer zone.
Optionally, before the buffer zone by second target data write-in, methods described also includes:
Judge whether the 3rd data cached version information and the 4th data cached version information are identical;
If the 3rd data cached version information is identical with the 4th data cached version information, execution is described will
Second target data writes the buffer zone step;
Or if the 3rd data cached version information differs with the 4th data cached version information, protect
The data for holding the buffer zone are constant.
Optionally, after the buffer zone by second target data write-in, methods described also includes:
It is slow according to the 3rd database data version information and the 5th database data version information, generation the 5th
Deposit data version information;
The 5th data cached version information is arranged to the current version information in the buffer zone.
Second aspect, in order to achieve the above object, the embodiment of the invention also discloses a kind of data reading device, the dress
Put including:
First receiving module, for receiving the reading instruction of corresponding first object data;
First acquisition module, for obtaining the first current database data version information of database, the data stock
The the first data cached version information of second database data version information of the last revision data of storage and buffer zone currently;
First generation module, for according to the first database data version information and the second database data version
This information, generate the second data cached version information;
First judge module, for judging that the described first data cached version information is believed with the described second data cached version
Whether breath is identical;If the first data cached version information differs with the described second data cached version information, triggering
First read module;
First read module, for reading the first object data from the database.
Optionally, described device also includes:
Second read module, if believed for the described first data cached version information and the described second data cached version
Manner of breathing is same, and the first object data are read from the buffer zone.
Optionally, described device also includes:
First writing module, for data currently stored in the database to be write into the buffer zone.
Optionally, described device also includes:
Second receiving module, for receiving the write instruction of corresponding second target data;
Second acquisition module, for obtaining the 3rd current data cached version information of the buffer zone and the 4th caching
Data version information, wherein, the 4th data cached version information is according to the 3rd current database number of the database
Generated according to version information and the 4th database data version information of the last revision data of the database purchase;
Second generation module, for second target data to be write into the database, and generate the 5th database number
According to version information;
First setup module, for the 5th database data version information to be arranged into the current version of the database
This information;
Second writing module, for second target data to be write into the buffer zone.
Optionally, described device also includes:
Second judge module, for judging that the 3rd data cached version information is believed with the described 4th data cached version
Whether breath is identical;
If the 3rd data cached version information is identical with the 4th data cached version information, execution is described will
Second target data writes the buffer zone step;
Or if the 3rd data cached version information differs with the 4th data cached version information, protect
The data for holding the buffer zone are constant.
Optionally, described device also includes:
3rd generation module, for according to the 3rd database data version information and the 5th database data version
This information, generate the 5th data cached version information;
Second setup module, for the 5th data cached version information to be arranged into the current version in the buffer zone
This information.
The third aspect, in order to achieve the above object, the embodiment of the invention also discloses a kind of electronic equipment, the electronics is set
It is standby to include processor, communication interface, memory and communication bus, wherein, the processor, the communication interface, the storage
Device completes mutual communication by the communication bus;
The memory, for depositing computer program;
The processor, during for performing the program deposited on memory, realize the reading as described in above-mentioned first aspect
Access is according to method and step.
Fourth aspect, in order to achieve the above object, the embodiment of the invention also discloses a kind of computer-readable recording medium,
The computer-readable recording medium internal memory contains computer program, when the computer program is executed by processor, realizes such as
Reading data method step described in above-mentioned first aspect.
A kind of reading data method, device, electronic equipment and computer-readable recording medium provided in an embodiment of the present invention,
Can be after the reading instruction of corresponding first object data be received, in the first current caching number of buffer zone using the above method
When being differed according to version information and the second data cached version information, first object data are read from database, wherein, second is slow
Deposit data version information is the last revision data according to the first current database data version information of database and database
The second database data version information calculate.So, it can be determined that the number in data and buffer zone in database
According to whether identical, if it is not the same, then reading data from database so that currently stored in the data and database that read
Data it is identical, the degree of accuracy of the data read can be improved.Certainly, any product or method for implementing the present invention must differ
It is fixed to need to reach all the above advantage simultaneously.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
There is the required accompanying drawing used in technology description to be briefly described.
Fig. 1 is a kind of schematic flow sheet for reading data method provided in an embodiment of the present invention;
Fig. 2 is that a kind of flow of method of being modified to the data that are stored in database provided in an embodiment of the present invention is illustrated
Figure;
Fig. 3 is a kind of structural representation of data reading device provided in an embodiment of the present invention;
Fig. 4 is the structural representation of a kind of electronic equipment provided in an embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is described.
, can be by database in order to accelerate to access the speed of data as the data volume stored in database is continuously increased
The data storage being accessed frequently is in buffer zone.When the data to be accessed are not present in buffer zone, then read data
Storehouse obtains data.When need change database in data when, write instruction can start thread delete first it is right in buffer zone
The data answered, then by the data write into Databasce after renewal;Now, due to having deleted corresponding number in buffer zone
According to reading instruction can start thread and directly read database, the data after being updated, and the data after renewal are write caching
Region.Need to read the data next time, buffer zone can be directly read by reading instruction and starting thread, the data read with
Data in database are identical.However, in the case where thread is concurrent, thread A deletes data in buffer zone first, in thread
For A by before the data write into Databasce after renewal, another thread B reading databases obtain legacy data, and legacy data is write and cached
Region, then thread A the data write into Databasce after renewal is caused to read the data obtained during buffer zone and number next time
Differed according to the currently stored data in storehouse.
Based on this, the data that inventor thinks that the data of database purchase and buffer zone can be stored are marked.
According to the mark of the data stored in the mark and database of the currently stored data in buffer zone, different reading sides is selected
Formula so that the data read are identical with the data that database is currently stored.
Based on above-mentioned consideration, the present patent application provides a kind of reading data method, device, electronic equipment and computer can
Read storage medium.This method can apply to terminal, can also be applied to server.The present invention enters exemplified by applied to server
Row explanation, other situations are similar therewith.Server (hereinafter referred to as destination server) applied to the above method is corresponding in reception
, can be in the first current data cached version information of buffer zone and the second caching number after the reading instruction of first object data
When being differed according to version information, first object data are read from database, wherein, the second data cached version information is according to number
The second database data version according to the first current database data version information of storehouse and the last revision data of database is believed
What breath calculated.Based on this programme, the data that can to read are identical with data currently stored in database, Neng Gouti
The degree of accuracy for the data that height is read.
The present invention is described in detail by specific embodiment again below.Carried referring to Fig. 1, Fig. 1 for the embodiment of the present invention
A kind of schematic flow sheet of the reading data method supplied, including:
S101:Receive the reading instruction of corresponding first object data.
Wherein, database is according to the set of the data of certain rule storage, and being total to for data can be realized using database
Enjoy.In order to improve the speed for accessing data, it will usually which the data being accessed frequently stored in database are write into buffer zone
In stored.
It is one of major instruction operated to data to read instruction, and it can be sent to target by terminal to read instruction
Server.
When terminal needs to read certain data (i.e. first object data), corresponding first object can be sent to destination server
The reading instruction of data, data item corresponding to first object data is included in reading instruction.Destination server receives the reading
After instruction fetch, reading instruction can be parsed and obtain the data item, to cause succeeding target server to be obtained according to the data item
First object data.
S102:Obtain the first current database data version information of database, the last revision data of database purchase
Current the first data cached version information of the second database data version information and buffer zone.
In a kind of implementation, destination server can enter according to the instruction received to the data stored in database
Row modification, including data are updated or added with new data., can be to slow after the data modification stored in database
Deposit the data stored in region and synchronize modification, with the data for keeping the data that are stored in buffer zone and being stored in database
It is identical.
After the data modification for completing to store in database, in database amended data be properly termed as in database when
The data of preceding storage, the data before changing are properly termed as the last revision data stored in database;Similarly, when completion caches
After the data syn-chronization modification stored in region, amended data are properly termed as currently stored in buffer zone in buffer zone
Data, the data before changing are properly termed as the last revision data stored in buffer zone.Destination server can be according to number
According to storehouse data version information, to distinguish the data stored in database before and after modification;According to data cached version information, to distinguish
The data stored before and after modification in buffer zone.
Above-mentioned first database data version information is the version information of data currently stored in database, and first caches
Data version information is the version information of data currently stored in buffer zone.
Under normal circumstances, destination server can keep the data in database identical with the data in buffer zone, i.e., and
Data in database corresponding to one database data version information, buffer zone corresponding with the first data cached version information
In data it is identical.But under the data modification failure of buffer zone or other abnormal conditions, the first database data version
Data corresponding to information, data corresponding with the first data cached version information will differ.
In a kind of implementation, destination server (Universally Unique Identifier, can lead to UUID
By the use of unique identifier) it is used as the version information of the data stored in database.UUID can be the character of destination server generation
String, the UUID generated every time is all without repetition, that is, UUID has unique identity characteristic.Destination server will can generate
Version informations (i.e. database data version information) of the UUID as each edition data of database.Because each UUID has
There is unique identity characteristic, each two UUID can be combined, obtain a new mark with uniqueness, i.e.,
cacheUUID.CacheUUID can be as version information (the i.e. data cached version of the data of buffer zone corresponding to database
This information).The present embodiment enters so that database data version information is UUID, data cached version information is cacheUUID as an example
Row explanation, other situations are similar therewith, repeat no more.For the ease of description, the first database data version information can be designated as
UUID1, the second database data version information can be designated as UUID2, the first data cached version information can be designated as cacheUUID1。
Destination server can store to the UUID and cacheUUID generated every time, when destination server receives
After instruction, the UUID and cacheUUID being locally stored can be directly obtained.
S103:According to the first database data version information and the second database data version information, the caching of generation second
Data version information.
In a kind of implementation, the generating algorithm of data cached version information can be prestored in destination server, should
Generating algorithm can be text string generation algorithm.Destination server can be according to UUID1、UUID2It is raw with text string generation algorithm
Into the second data cached version information, cacheUUID can be designated as2。
Exemplary, UUID1For 8FE345, UUID2For 665BC9, generated by the way of string-concatenation data cached
Version information, then the second data cached version information cacheUUID2Can be 8FE345.665BC9.The embodiment of the present invention only with
Illustrated exemplified by UUID splicing generations cacheUUID, other generate cacheUUID mode according to UUID, belong to this hair
In the protection domain of bright embodiment.
S104:Judge whether the first data cached version information and the second data cached version information are identical.
If the first data cached version information is identical with the second data cached version information, S105 is performed;
If the first data cached version information differs with the second data cached version information, S106 is performed.
S105:First object data are read from database.
In a kind of implementation, if cacheUUID1And cacheUUID2Differ, namely stored in current cache region
Data and database in the data that store differ, destination server can read first object data from database, to protect
It is identical with the data in database to demonstrate,prove the data read, improves the degree of accuracy of the data read.
Optionally, destination server can update the data in buffer zone after database obtains first object data.
Accordingly, the above method also includes:Data currently stored in database are write into buffer zone.
In a kind of implementation, destination server judges cacheUUID1And cacheUUID2, can also be by number after differing
Buffer zone is write according to data currently stored in storehouse so that the data stored in the data and database that are stored in buffer zone
It is identical.Wherein, the data stored in buffer zone can be not provided with expired time, to improve the hit rate for reading buffer zone.
S106:First object data are read from buffer zone.
In force, if cacheUUID1And cacheUUID2It is identical, namely the data stored in current cache region with
The data stored in database are identical, then destination server can read first object data from buffer zone, now, from caching
The data read in region, it is identical with the data in database, the degree of accuracy of the data read can be improved.
In one particular embodiment of the present invention, destination server can also receive the write instruction of data, to data
The data stored in storehouse are modified.Referring to Fig. 2, specific processing procedure can be:
S201:Receive the write instruction of corresponding second target data.
Wherein, write instruction is also one of major instruction operated to data, and write instruction can be destination service
The instruction that terminal corresponding to device is sent.
When terminal needs to write certain data (i.e. second target data), corresponding second target can be sent to destination server
The write instruction of data, the second target data is included in the write instruction., can be with after destination server receives the write instruction
Parse the write instruction and obtain the second target data, to allow succeeding target server according to the second target data to data
Data in storehouse and buffer zone are modified.
After the data modification for completing to store in database, in database amended data be properly termed as in database when
The data of preceding storage, the data before changing are properly termed as the last revision data stored in database;Similarly, when completion caches
After the data syn-chronization modification stored in region, amended data are properly termed as currently stored in buffer zone in buffer zone
Data, the data before changing are properly termed as the last revision data stored in buffer zone.Destination server can be according to number
According to storehouse data version information, to distinguish the data stored in database before and after modification;According to data cached version information, to distinguish
The data stored before and after modification in buffer zone.
S202:Obtain buffer zone current the 3rd data cached version information and the 4th data cached version information.
Wherein, the 4th data cached version information is according to the 3rd current database data version information sum of database
Generated according to the 4th database data version information of the last revision data of library storage.
Above-mentioned 3rd database data version information is the version information of data currently stored in database, the 4th data
Storehouse data version information is the version information of the last revision data stored in database, and the 3rd data cached version information is i.e. slow
Deposit the version information of data currently stored in region.
For the ease of description, the 3rd data cached version information can be designated as cacheUUID3, the 4th data cached version letter
Breath can be designated as cacheUUID4, the 3rd database data version information can be designated as UUID3, the 4th database data version information can
It is designated as UUID4。
In a kind of implementation, destination server can directly obtain the cacheUUID being locally stored3、UUID3With
UUID4.According to UUID3And UUID4Generate cacheUUID4, and stored.
Wherein, according to UUID3And UUID4Generate cacheUUID4Specific steps may be referred to above-mentioned generation cacheUUID
The step of, it will not be repeated here.
S203:By the second target data write into Databasce, and generate the 5th database data version information.
A kind of implementation, destination server can be used the second target data write into Databasce with deleting buffer zone
In the asynchronous mode of data carry out, avoid caching is abnormal from causing the second target data write into Databasce to fail.Destination server
Generate and store new UUID5。
S204:5th database data version information is arranged to the current version information of database.
In a kind of implementation, destination server can be by UUID5As by after the second target data write into Databasce, count
According to the 5th database data version information of the data stored in storehouse.
S205:Second target data is write into buffer zone.
, can be to database after destination server receives corresponding second target data write instruction from above-mentioned
The data of middle storage are modified, and the data stored in synchronous vacations buffer zone, to ensure the number stored in buffer zone
It is identical according to the data with being stored in database, it is possible to increase to read the degree of accuracy for the data that buffer zone obtains.
Optionally, before the second target data is write into buffer zone (i.e. S205), the above method also includes:
Judge whether the 3rd data cached version information and the 4th data cached version information are identical.
If the 3rd data cached version information is identical with the 4th data cached version information, perform the second target data
Write buffer zone step.
Or if the 3rd data cached version information differs with the 4th data cached version information, keep buffer area
The data in domain are constant.
In a kind of implementation, cacheUUID3And cacheUUID4Data and number identical, namely stored in buffer zone
It is identical according to the data stored in storehouse.Destination server, can be by the second target data after the second target data write into Databasce
Buffer zone is write, it is identical with the data stored in database with the data for store in buffer zone.
cacheUUID3And cacheUUID4Differ, namely stored in the data and database stored in buffer zone
Data differ.Now, destination server is not modified to the data in buffer zone, keeps the data of buffer zone not
Become, it is possible to reduce the number of buffer zone renewal, reduce the renewal burden of destination server.
Optionally, after the second target data is write into buffer zone, the above method also includes:
According to the 3rd database data version information and the 5th database data version information, the 5th data cached version is generated
This information.
5th data cached version information is arranged to the current version information in buffer zone.
, can be by cacheUUID in a kind of implementation5As the 5th data cached version information, and stored.
Wherein, according to UUID3And UUID5Generate cacheUUID5The step of, may be referred to above-mentioned generation cacheUUID's
Step, it will not be repeated here.
After second target data is write buffer zone by destination server, data currently stored in buffer zone are set
Version information is cacheUUID5, to cause the current version information in buffer zone identical with the version information that database is current.
Because destination server receives the reading instruction of corresponding first object data and receives corresponding second number of targets
According to write instruction can be synchronous, therefore the UUID in this implementation embodiment3Can be with the UUID in above-described embodiment1Phase
Together;Similar, UUID4Can be with UUID2It is identical, cacheUUID3Can be with cacheUUID1It is identical, cacheUUID4Can be with
cacheUUID2It is identical.
From above-mentioned, reading data method provided in an embodiment of the present invention, corresponding first object data can received
Reading instruction after, in buffer zone, the first current data cached version information differs with the second data cached version information
When, first object data are read from database, wherein, the second data cached version information is according to the first current number of database
Calculated according to the second database data version information of storehouse data version information and the last revision data of database.So,
It may determine that whether the data in the data and buffer zone in database are identical, if it is not the same, then being read from database
Data so that the data read are identical with data currently stored in database, can improve the accurate of the data that read
Degree.
Corresponding with above method embodiment, referring to Fig. 3, Fig. 3 fills for a kind of data that read provided in an embodiment of the present invention
The structural representation put, including:
First receiving module 301, for receiving the reading instruction of corresponding first object data;
First acquisition module 302, for obtaining the first current database data version information of database, the database
The the first data cached version letter of second database data version information of the last revision data of storage and buffer zone currently
Breath;
First generation module 303, for according to the first database data version information and the second database number
According to version information, the second data cached version information is generated;
First judge module 304, for judging the described first data cached version information and the described second data cached version
Whether this information is identical;If the first data cached version information differs with the described second data cached version information,
Trigger the first read module 305;
First read module 305, for reading the first object data from the database.
In one particular embodiment of the present invention, described device also includes:
Second read module, if believed for the described first data cached version information and the described second data cached version
Manner of breathing is same, and the first object data are read from the buffer zone.
In one particular embodiment of the present invention, described device also includes:
First writing module, for data currently stored in the database to be write into the buffer zone.
In one particular embodiment of the present invention, described device also includes:
Second receiving module, for receiving the write instruction of corresponding second target data;
Second acquisition module, for obtaining the 3rd current data cached version information of the buffer zone and the 4th caching
Data version information, wherein, the 4th data cached version information is according to the 3rd current database number of the database
Generated according to version information and the 4th database data version information of the last revision data of the database purchase;
Second generation module, for second target data to be write into the database, and generate the 5th database number
According to version information;
First setup module, for the 5th database data version information to be arranged into the current version of the database
This information;
Second writing module, for second target data to be write into the buffer zone.
In one particular embodiment of the present invention, described device also includes:
Second judge module, for judging that the 3rd data cached version information is believed with the described 4th data cached version
Whether breath is identical;
If the 3rd data cached version information is identical with the 4th data cached version information, execution is described will
Second target data writes the buffer zone step;
Or if the 3rd data cached version information differs with the 4th data cached version information, protect
The data for holding the buffer zone are constant.
In one particular embodiment of the present invention, described device also includes:
3rd generation module, for according to the 3rd database data version information and the 5th database data version
This information, generate the 5th data cached version information;
Second setup module, for the 5th data cached version information to be arranged into the current version in the buffer zone
This information.
From above-mentioned, the present invention implements the data reading device provided, can receive the reading of corresponding first object data
After instruction fetch, when in buffer zone, the first current data cached version information and the second data cached version information differ,
First object data are read from database, wherein, the second data cached version information is according to the first current data of database
What the second database data version information of the last revision data of storehouse data version information and database calculated.So, may be used
To judge whether the data in data and buffer zone in database are identical, if it is not the same, then reading number from database
According to so that the data read are identical with data currently stored in database, can improve the degree of accuracy of the data read.
The embodiment of the present invention additionally provides a kind of electronic equipment, as shown in figure 4, including processor 401, communication interface 402,
Memory 403 and communication bus 404, wherein, processor 401, communication interface 402, memory 403 is complete by communication bus 404
Into mutual communication,
Memory 403, for depositing computer program;
Processor 401, during for performing the program deposited on memory 403, realize reading provided in an embodiment of the present invention
Take data method.
Specifically, above-mentioned reading data method, including:
Receive the reading instruction of corresponding first object data;
Obtain the last revision data of the first current database data version information of database, the database purchase
The the first data cached version information of second database data version information and buffer zone currently;
It is slow according to the first database data version information and the second database data version information, generation second
Deposit data version information;
Judge whether the described first data cached version information and the described second data cached version information are identical;
If the first data cached version information differs with the described second data cached version information, from the number
The first object data are read according to storehouse.
It should be noted that other implementations of above-mentioned reading data method are identical with preceding method embodiment part,
Here repeat no more.
Electronic equipment provided in an embodiment of the present invention, when reading data, corresponding first object data can received
After reading instruction, in buffer zone, the first current data cached version information differs with the second data cached version information
When, first object data are read from database, wherein, the second data cached version information is according to the first current number of database
Calculated according to the second database data version information of storehouse data version information and the last revision data of database.So that read
The data got are identical with data currently stored in database, can improve the degree of accuracy of the data read.
The communication bus that above-mentioned electronic equipment is mentioned can be Peripheral Component Interconnect standard (Peripheral Component
Interconnect, abbreviation PCI) bus or EISA (Extended Industry Standard
Architecture, abbreviation EISA) bus etc..The communication bus can be divided into address bus, data/address bus, controlling bus etc..
For ease of representing, only represented in figure with a thick line, it is not intended that an only bus or a type of bus.
The communication that communication interface is used between above-mentioned electronic equipment and other equipment.
Memory can include random access memory (Random Access Memory, abbreviation RAM), can also include
Nonvolatile memory (non-volatile memory), for example, at least a magnetic disk storage.Optionally, memory may be used also
To be at least one storage device for being located remotely from aforementioned processor.
Above-mentioned processor can be general processor, including central processing unit (Central Processing Unit,
Abbreviation CPU), network processing unit (Network Processor, abbreviation NP) etc.;It can also be digital signal processor
(Digital Signal Processing, abbreviation DSP), application specific integrated circuit (Application Specific
Integrated Circuit, abbreviation ASIC), field programmable gate array (Field-Programmable Gate Array,
Abbreviation FPGA) either other PLDs, discrete gate or transistor logic, discrete hardware components.
The embodiment of the present invention additionally provides a kind of computer-readable recording medium, is stored in the computer-readable recording medium
There is instruction, when run on a computer so that computer performs reading data method provided in an embodiment of the present invention.
Specifically, above-mentioned reading data method, including:
Receive the reading instruction of corresponding first object data;
Obtain the last revision data of the first current database data version information of database, the database purchase
The the first data cached version information of second database data version information and buffer zone currently;
It is slow according to the first database data version information and the second database data version information, generation second
Deposit data version information;
Judge whether the described first data cached version information and the described second data cached version information are identical;
If the first data cached version information differs with the described second data cached version information, from the number
The first object data are read according to storehouse.
It should be noted that other implementations of above-mentioned reading data method are identical with preceding method embodiment part,
Here repeat no more.
By running the instruction stored in computer-readable recording medium provided in an embodiment of the present invention, data are being read
When, can be after the reading instruction of corresponding first object data be received, in the first current data cached version letter of buffer zone
When breath differs with the second data cached version information, first object data are read from database, wherein, the second data cached version
This information is the second number of the last revision data according to the first current database data version information of database and database
Calculated according to storehouse data version information.So that the data read are identical with data currently stored in database, Ke Yiti
The degree of accuracy for the data that height is read.
The embodiment of the present invention additionally provides a kind of computer program product for including instruction, when it runs on computers
When so that computer performs reading data method provided in an embodiment of the present invention.
Specifically, above-mentioned reading data method, including:
Receive the reading instruction of corresponding first object data;
Obtain the last revision data of the first current database data version information of database, the database purchase
The the first data cached version information of second database data version information and buffer zone currently;
It is slow according to the first database data version information and the second database data version information, generation second
Deposit data version information;
Judge whether the described first data cached version information and the described second data cached version information are identical;
If the first data cached version information differs with the described second data cached version information, from the number
The first object data are read according to storehouse.
It should be noted that other implementations of above-mentioned reading data method are identical with preceding method embodiment part,
Here repeat no more.
By running computer program product provided in an embodiment of the present invention, when reading data, can be corresponded to receiving
After the reading instruction of first object data, the first current data cached version information and the second data cached version in buffer zone
When this information differs, first object data are read from database, wherein, the second data cached version information is according to database
The first current database data version information and the second database data version information meter of the last revision data of database
Calculate.So that the data read are identical with data currently stored in database, the standard of the data read can be improved
Exactness.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or its any combination real
It is existing.When implemented in software, can realize in the form of a computer program product whole or in part.The computer program
Product includes one or more computer instructions.When loading on computers and performing the computer program instructions, all or
Partly produce according to the flow or function described in the embodiment of the present invention.The computer can be all-purpose computer, special meter
Calculation machine, computer network or other programmable devices.The computer instruction can be stored in computer-readable recording medium
In, or the transmission from a computer-readable recording medium to another computer-readable recording medium, for example, the computer
Instruction can pass through wired (such as coaxial cable, optical fiber, numeral from a web-site, computer, server or data center
User's line (DSL)) or wireless (such as infrared, wireless, microwave etc.) mode to another web-site, computer, server or
Data center is transmitted.The computer-readable recording medium can be any usable medium that computer can access or
It is the data storage devices such as server, the data center integrated comprising one or more usable mediums.The usable medium can be with
It is magnetic medium, (for example, floppy disk, hard disk, tape), optical medium (for example, DVD) or semiconductor medium (such as solid state hard disc
Solid State Disk (SSD)) etc..
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality
Body or operation make a distinction with another entity or operation, and not necessarily require or imply and deposited between these entities or operation
In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to
Nonexcludability includes, so that process, method, article or equipment including a series of elements not only will including those
Element, but also the other element including being not expressly set out, or it is this process, method, article or equipment also to include
Intrinsic key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that
Other identical element also be present in process, method, article or equipment including the key element.
Each embodiment in this specification is described by the way of related, identical similar portion between each embodiment
Divide mutually referring to what each embodiment stressed is the difference with other embodiment.Especially for device,
For electronic equipment, computer-readable recording medium, computer program product embodiments, implement because it is substantially similar to method
Example, so description is fairly simple, the relevent part can refer to the partial explaination of embodiments of method.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all
Any modification, equivalent substitution and improvements made within the spirit and principles in the present invention etc., are all contained in protection scope of the present invention
It is interior.
Claims (14)
1. one kind reads data method, it is characterised in that methods described includes:
Receive the reading instruction of corresponding first object data;
Obtain the first current database data version information of database, the database purchase last revision data second
The the first data cached version information of database data version information and buffer zone currently;
According to the first database data version information and the second database data version information, the caching number of generation second
According to version information;
Judge whether the described first data cached version information and the described second data cached version information are identical;
If the first data cached version information differs with the described second data cached version information, from the database
Read the first object data.
2. according to the method for claim 1, it is characterised in that methods described also includes:
If the first data cached version information is identical with the described second data cached version information, from the buffer zone
Read the first object data.
3. according to the method for claim 1, it is characterised in that read the first object number from the database described
According to afterwards, methods described also includes:
Data currently stored in the database are write into the buffer zone.
4. according to the method for claim 1, it is characterised in that methods described also includes:
Receive the write instruction of corresponding second target data;
The buffer zone current the 3rd data cached version information and the 4th data cached version information are obtained, wherein, institute
It is according to the 3rd current database data version information of the database and the data to state the 4th data cached version information
The 4th database data version information generation of the last revision data of library storage;
Second target data is write into the database, and generates the 5th database data version information;
The 5th database data version information is arranged to the current version information of the database;
Second target data is write into the buffer zone.
5. according to the method for claim 4, it is characterised in that second target data is write into the caching described
Before region, methods described also includes:
Judge whether the 3rd data cached version information and the 4th data cached version information are identical;
If the 3rd data cached version information is identical with the 4th data cached version information, perform described by described in
Second target data writes the buffer zone step;
Or if the 3rd data cached version information differs with the 4th data cached version information, keep institute
The data for stating buffer zone are constant.
6. according to the method for claim 4, it is characterised in that second target data is write into the caching described
After region, methods described also includes:
According to the 3rd database data version information and the 5th database data version information, the caching number of generation the 5th
According to version information;
The 5th data cached version information is arranged to the current version information in the buffer zone.
7. a kind of data reading device, it is characterised in that described device includes:
First receiving module, for receiving the reading instruction of corresponding first object data;
First acquisition module, for obtaining the first current database data version information of database, the database purchase
The the first data cached version information of second database data version information of last revision data and buffer zone currently;
First generation module, for according to the first database data version information and the second database data version letter
Breath, generate the second data cached version information;
First judge module, for judging that the described first data cached version information is with the described second data cached version information
It is no identical;If the first data cached version information differs with the described second data cached version information, triggering first
Read module;
First read module, for reading the first object data from the database.
8. device according to claim 7, it is characterised in that described device also includes:
Second read module, if for the described first data cached version information and the described second data cached version information phase
Together, the first object data are read from the buffer zone.
9. device according to claim 7, it is characterised in that described device also includes:
First writing module, for data currently stored in the database to be write into the buffer zone.
10. device according to claim 7, it is characterised in that described device also includes:
Second receiving module, for receiving the write instruction of corresponding second target data;
Second acquisition module, for obtaining the 3rd current data cached version information of the buffer zone and the 4th data cached
Version information, wherein, the 4th data cached version information is according to the 3rd current database data version of the database
The generation of 4th database data version information of this information and the last revision data of the database purchase;
Second generation module, for second target data to be write into the database, and generate the 5th database data version
This information;
First setup module, believe for the 5th database data version information to be arranged into the current version of the database
Breath;
Second writing module, for second target data to be write into the buffer zone.
11. device according to claim 10, it is characterised in that described device also includes the second judge module, is used for:
Judge whether the 3rd data cached version information and the 4th data cached version information are identical;
If the 3rd data cached version information is identical with the 4th data cached version information, perform described by described in
Second target data writes the buffer zone step;
Or if the 3rd data cached version information differs with the 4th data cached version information, keep institute
The data for stating buffer zone are constant.
12. device according to claim 10, it is characterised in that described device also includes:
3rd generation module, for according to the 3rd database data version information and the 5th database data version letter
Breath, generate the 5th data cached version information;
Second setup module, believe for the 5th data cached version information to be arranged into the current version in the buffer zone
Breath.
13. a kind of electronic equipment, it is characterised in that including processor, communication interface, memory and communication bus, wherein, it is described
Processor, the communication interface, the memory complete mutual communication by the communication bus;
The memory, for depositing computer program;
The processor, during for performing the program deposited on the memory, realize any described sides of claim 1-6
Method step.
14. a kind of computer-readable recording medium, it is characterised in that the computer-readable recording medium internal memory contains computer
Program, the computer program realize claim 1-6 any described method and steps when being executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710805732.1A CN107577775B (en) | 2017-09-08 | 2017-09-08 | Data reading method and device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710805732.1A CN107577775B (en) | 2017-09-08 | 2017-09-08 | Data reading method and device, electronic equipment and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107577775A true CN107577775A (en) | 2018-01-12 |
CN107577775B CN107577775B (en) | 2021-12-10 |
Family
ID=61032927
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710805732.1A Active CN107577775B (en) | 2017-09-08 | 2017-09-08 | Data reading method and device, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107577775B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109542872A (en) * | 2018-10-26 | 2019-03-29 | 金蝶软件(中国)有限公司 | Method for reading data, device, computer equipment and storage medium |
CN109766361A (en) * | 2018-12-19 | 2019-05-17 | 中国平安人寿保险股份有限公司 | Data cached read method, device, computer equipment and storage medium |
CN111752977A (en) * | 2020-06-16 | 2020-10-09 | 北京字节跳动网络技术有限公司 | Data reading request and data writing request processing method and device |
CN111752919A (en) * | 2020-06-16 | 2020-10-09 | 北京字节跳动网络技术有限公司 | Data writing method, data reading method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1522409A (en) * | 2001-06-09 | 2004-08-18 | 存储交易株式会社 | Cache-conscious concurrency control scheme for database systems |
CN101464895A (en) * | 2009-01-21 | 2009-06-24 | 阿里巴巴集团控股有限公司 | Method, system and apparatus for updating internal memory data |
US20100082553A1 (en) * | 2008-09-30 | 2010-04-01 | Louis Beatty | Backing up and restoring selected versioned objects from a monolithic database backup |
US20140324785A1 (en) * | 2013-04-30 | 2014-10-30 | Amazon Technologies, Inc. | Efficient read replicas |
CN104573035A (en) * | 2015-01-16 | 2015-04-29 | 杭州犀照科技有限公司 | Caching service method and device and news information obtaining method and system |
-
2017
- 2017-09-08 CN CN201710805732.1A patent/CN107577775B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1522409A (en) * | 2001-06-09 | 2004-08-18 | 存储交易株式会社 | Cache-conscious concurrency control scheme for database systems |
US20100082553A1 (en) * | 2008-09-30 | 2010-04-01 | Louis Beatty | Backing up and restoring selected versioned objects from a monolithic database backup |
CN101464895A (en) * | 2009-01-21 | 2009-06-24 | 阿里巴巴集团控股有限公司 | Method, system and apparatus for updating internal memory data |
US20140324785A1 (en) * | 2013-04-30 | 2014-10-30 | Amazon Technologies, Inc. | Efficient read replicas |
CN104573035A (en) * | 2015-01-16 | 2015-04-29 | 杭州犀照科技有限公司 | Caching service method and device and news information obtaining method and system |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109542872A (en) * | 2018-10-26 | 2019-03-29 | 金蝶软件(中国)有限公司 | Method for reading data, device, computer equipment and storage medium |
CN109766361A (en) * | 2018-12-19 | 2019-05-17 | 中国平安人寿保险股份有限公司 | Data cached read method, device, computer equipment and storage medium |
CN109766361B (en) * | 2018-12-19 | 2023-08-04 | 中国平安人寿保险股份有限公司 | Cache data reading method, device, computer equipment and storage medium |
CN111752977A (en) * | 2020-06-16 | 2020-10-09 | 北京字节跳动网络技术有限公司 | Data reading request and data writing request processing method and device |
CN111752919A (en) * | 2020-06-16 | 2020-10-09 | 北京字节跳动网络技术有限公司 | Data writing method, data reading method and device |
CN111752977B (en) * | 2020-06-16 | 2024-01-19 | 抖音视界有限公司 | Data reading request and data writing request processing method and device |
Also Published As
Publication number | Publication date |
---|---|
CN107577775B (en) | 2021-12-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11853549B2 (en) | Index storage in shingled magnetic recording (SMR) storage system with non-shingled region | |
US10698831B2 (en) | Method and apparatus for data access | |
CN107577775A (en) | One kind reads data method, device, electronic equipment and readable storage medium storing program for executing | |
CN105677580A (en) | Method and device for accessing cache | |
WO2020211236A1 (en) | Read-write conflict resolution method and apparatus employing b+ tree and storage medium | |
EP2842041B1 (en) | Data processing system and method for operating a data processing system | |
GB2516477A (en) | Method and system for handling virtual memory address synonyms in a multi-level cache hierarchy structure | |
CN111427859B (en) | Message processing method and device, electronic equipment and storage medium | |
US20170147507A1 (en) | Direct memory access of dynamically allocated memory | |
US20070156778A1 (en) | File indexer | |
CN107301215A (en) | A kind of search result caching method and device, searching method and device | |
CN113448490A (en) | Method, apparatus and computer program product for storage | |
CN110008758A (en) | ID obtaining method and device, electronic equipment and storage medium | |
CN117573574B (en) | Prefetching method and device, electronic equipment and readable storage medium | |
WO2019047901A1 (en) | Data depositing method | |
US20170147508A1 (en) | Device, system and method of accessing data stored in a memory | |
WO2019047142A1 (en) | Method for program patching, device, micro control unit, and terminal device | |
CN113742131A (en) | Method, electronic device and computer program product for storage management | |
CN109492020A (en) | A kind of data cache method, device, electronic equipment and storage medium | |
US20140181502A1 (en) | Dynamically manipulating rules for adding new devices | |
CN109542872A (en) | Method for reading data, device, computer equipment and storage medium | |
KR102416336B1 (en) | Device, method, system and computer readable storage medium for managing blockchain | |
CN107436918B (en) | Database implementation method, device and equipment | |
US10311039B2 (en) | Optimized iterators for RCU-protected skiplists | |
US20100042864A1 (en) | System and method for managing application |
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 |