CN109918381A - Method and apparatus for storing data - Google Patents
Method and apparatus for storing data Download PDFInfo
- Publication number
- CN109918381A CN109918381A CN201910189069.6A CN201910189069A CN109918381A CN 109918381 A CN109918381 A CN 109918381A CN 201910189069 A CN201910189069 A CN 201910189069A CN 109918381 A CN109918381 A CN 109918381A
- Authority
- CN
- China
- Prior art keywords
- data
- memory
- stored
- equipment
- trigger condition
- 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
Abstract
Embodiment of the disclosure discloses method and apparatus for storing data.One specific embodiment of this method includes: to obtain new data caused by target application, and new data is stored into the first memory;Meet the first trigger condition in response to determining, the data stored in the first memory is stored to the second memory, and update the data in the second memory;Meet the second trigger condition in response to determining, according to the data that the second memory is stored, updates the data that External memory equipment is stored.The embodiment, which helps to realize, effectively to be stored using generated data.
Description
Technical field
Embodiment of the disclosure is related to field of computer technology, and in particular to method and apparatus for storing data.
Background technique
With the development of computer technology, the number for the application (Application) installed in terminal is more and more
It becomes increasingly complex.Using at runtime, it usually needs constantly access data from storage equipment.
In the related technology, existing will effectively store using generated data to the demand of storage equipment.
Summary of the invention
Embodiment of the disclosure proposes method and apparatus for storing data.
In a first aspect, embodiment of the disclosure provides a kind of method for storing data, this method comprises: obtaining mesh
Mark applies generated new data, and new data is stored into the first memory;Meet the first trigger condition in response to determining, by the
The data stored in one memory are stored to the second memory, and update the data in the second memory;Meet the in response to determining
Two trigger conditions update the data that External memory equipment is stored according to the data that the second memory is stored.
In some embodiments, according to the data stored in the second memory, the number that External memory equipment is stored is updated
According to, comprising: it determines the current data page in External memory equipment, the data that current data page is stored is stored in second
It deposits, and determines the residual memory space size of current data page;In determining residual memory space size less than second
The size for depositing stored data is stored the data that current data page is stored with the second memory in the second memory
Data merge;Data after merging are stored to External memory equipment, and empty the second memory.
In some embodiments, the first trigger condition includes following one: the size of the data stored in the first memory
Greater than preset first threshold;Receive the operation requests information of the data stored for the first memory;Second triggering
Condition includes: that the size of the data stored in the second memory is greater than preset second threshold.
In some embodiments, the structure for the data that the first memory is stored is tree construction, the number that the second memory is stored
According to structure be tree construction.
In some embodiments, the data stored in the first memory are stored to the second memory, further includes: by
The data that one memory is stored are deleted.
In some embodiments, volatile ram is saved as in first, Nonvolatile memory is saved as in second, external storage is set
Standby is disk.
In some embodiments, this method further include: deposit latest data involved in the update in External memory equipment
It stores up to the first memory.
Second aspect, embodiment of the disclosure provide a kind of device for storing data, which includes: first to deposit
Storage unit is configured to obtain new data caused by target application, and new data is stored into the first memory;First updates list
Member is configured in response to determine the first trigger condition of satisfaction, the data stored in the first memory is stored to the second memory,
And the data in the second memory of update;Second updating unit is configured in response to determine the second trigger condition of satisfaction, according to
The data that second memory is stored update the data that External memory equipment is stored.
In some embodiments, in the second updating unit, according to the data stored in the second memory, external storage is updated
The data that equipment is stored, comprising: determine the current data page in External memory equipment, the data that current data page is stored
It stores to the second memory, and determines the residual memory space size of current data page;In response to determining that residual memory space is big
Less than the size for the data that the second memory is stored, in the second memory, data and second that current data page is stored
The data that memory is stored merge;Data after merging are stored to External memory equipment, and empty the second memory.
In some embodiments, in the first updating unit, the first trigger condition includes following one: being deposited in the first memory
The size of the data of storage is greater than preset first threshold;Receive the operation requests of the data stored for the first memory
Information;In second updating unit, the second trigger condition include: the data stored in the second memory size be greater than preset
Second threshold.
In some embodiments, the structure for the data that the first memory is stored is tree construction, the number that the second memory is stored
According to structure be tree construction.
In some embodiments, in the first storage unit, the data stored in the first memory are stored to the second memory
Later, further includes: the data for being stored the first memory are deleted.
In some embodiments, volatile ram is saved as in first, Nonvolatile memory is saved as in second, external storage is set
Standby is disk.
In some embodiments, the device further include: the second storage unit, be configured to by External memory equipment more
Latest data involved in new is stored to the first memory.
The third aspect, embodiment of the disclosure provide a kind of electronic equipment, which includes: one or more places
Manage device;Storage device is stored thereon with one or more programs;When the one or more program is by the one or more processors
It executes, so that the one or more processors realize the method as described in implementation any in first aspect.
Fourth aspect, embodiment of the disclosure provide a kind of computer-readable medium, are stored thereon with computer program,
The method as described in implementation any in first aspect is realized when the program is executed by processor.
The method and apparatus for storing data that embodiment of the disclosure provides, caused by available target application
New data stores new data into the first memory.Then, meet the first trigger condition in response to determining, it will be in the first memory
The data stored are stored to the second memory, and update the data in the second memory.Finally, meeting the second touching in response to determining
Clockwork spring part updates the data that External memory equipment is stored according to the data that the second memory is stored.The method of the present embodiment and
Device is stored to using generated data by the first memory, the second memory and External memory equipment, is helped to realize
It will effectively be stored using generated data.
Detailed description of the invention
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the disclosure is other
Feature, objects and advantages will become more apparent upon:
Fig. 1 is that one embodiment of the disclosure can be applied to exemplary system architecture figure therein;
Fig. 2 is the flow chart according to one embodiment of the method for storing data of the disclosure;
Fig. 3 is the schematic diagram of an application scenarios of method for storing data according to an embodiment of the present disclosure;
Fig. 4 is the flow chart according to another embodiment of the method for storing data of the disclosure;
Fig. 5 is the structural schematic diagram according to one embodiment of the device for storing data of the disclosure;
Fig. 6 is adapted for the structural schematic diagram for realizing the electronic equipment of embodiment of the disclosure.
Specific embodiment
The disclosure is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched
The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to
Convenient for description, part relevant to related invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the feature in embodiment and embodiment in the disclosure can phase
Mutually combination.The disclosure is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 shows the method for storing data or dress for storing data that can apply embodiment of the disclosure
The exemplary system architecture 100 set.
As shown in Figure 1, system architecture 100 may include terminal device 101,102,103, network 104 and database service
Device 105.Network 104 between terminal device 101,102,103 and database server 105 to provide Jie of communication link
Matter.Network 104 may include various connection types, such as wired, wireless communication link or fiber optic cables etc..
Terminal device 101,102,103 can be interacted by network 104 with database server 105, to receive or send
Message etc..Various applications, such as searching class application, the application of debugging class, navigation can be installed on terminal device 101,102,103
Class application, shopping class application etc..
Terminal device 101,102,103 can be hardware, be also possible to software.When terminal device 101,102,103 is hard
When part, it can be and provide the various electronic equipments of support, including but not limited to smart phone, plate electricity for the application installed
Brain, pocket computer on knee and desktop computer etc..When terminal device 101,102,103 is software, may be mounted at
In above-mentioned cited electronic equipment.Multiple softwares or software module may be implemented into (such as providing distributed clothes in it
Business), single software or software module also may be implemented into.It is not specifically limited herein.Terminal device 101,102,103 can incite somebody to action
That is installed is sent to database server 105 using generated data, and institute can also be obtained from database server 105
The data needed.
Database server 105 can be to provide the server of various services, for example, to terminal device 101,102,103
On the server stored using generated new data installed.The available terminal device of server 101,102,
Installed on 103 using generated new data, new data is stored into the first memory.Then, meet in response to determining
The data stored in first memory are stored to the second memory, and update the data in the second memory by the first trigger condition.
Finally, meeting the second trigger condition in response to determining, according to the data that the second memory is stored, updates External memory equipment and deposited
The data of storage.
It should be noted that database server 105 can be hardware, it is also possible to software.When database server 105
When for hardware, the distributed server cluster of multiple servers compositions may be implemented into, individual server also may be implemented into.When
When database server 105 is software, multiple softwares or software module (such as providing Distributed Services) may be implemented into,
Also single software or software module may be implemented into.It is not specifically limited herein.
It should be noted that the method provided by embodiment of the disclosure for storing data is generally by database service
Device 105 executes, and correspondingly, device for storing data is generally positioned in database server 105.Embodiment of the disclosure
Provided method for storing data is independent of terminal device 101,102,103 and network 104, thus, in Fig. 1 can be with
There is no terminal device 101,102,103 and networks 104.
It should be understood that the number of terminal device, network and database server in Fig. 1 is only schematical.According to
It realizes and needs, can have any number of terminal device, network and database server.
With continued reference to Fig. 2, the process of one embodiment of the method for storing data according to the disclosure is shown
200.The method for storing data, comprising the following steps:
Step 201, new data caused by target application is obtained, new data is stored into the first memory.
In the present embodiment, executing subject (such as the database server shown in FIG. 1 of method for storing data
105) target application institute can be got from the terminal device of communication connection by wired connection mode or radio connection
The new data of generation.Wherein, target application typically refers to the application in operating status on the terminal device of communication connection.It needs
It is noted that using data would generally be constantly be generated in the process of running.Above-mentioned new data typically refers to above-mentioned target and answers
Used in sometime most newly generated data.
After getting new data caused by target application, executing subject can be stored new data to the first memory
In.Wherein, the first memory is the memory for being different from the second memory hereafter.
In each embodiment of the disclosure, the first memory is usually volatile ram (Volatile Memory), and second
Memory is usually Nonvolatile memory (Non-Volatile Memory, NVM).External memory equipment is usually disk.
It should be pointed out that volatile ram typically refers to the memory that the data stored after electric current is turned off can disappear.
Nonvolatile memory typically refers to the memory that the data stored after electric current is turned off will not disappear.External memory equipment is logical
Referring to stored data can be with the storage equipment of persistence.The characteristics of memory is: capacity is small, and speed is exceedingly fast, and temporarily deposits
Put data.The characteristics of External memory equipment is: capacity is very big, and speed is slower, can persistence data.
Step 202, meet the first trigger condition in response to determining, the data stored in the first memory are stored to second
Memory, and update the data in the second memory.
In the present embodiment, when meeting the first trigger condition, number that executing subject can will be stored in the first memory
According to storing to the second memory.It should be pointed out that just the data in the first memory are stored after meeting the first trigger condition
To the second memory, and the indirect data by the first memory are stored to the second memory, it is therefore intended that: it can be in the first memory
Data meet and be then written to the second memory in a certain amount of situation, it is possible to reduce the data between the first memory and the second memory are write
Indegree improves data write efficiency.
It should be pointed out that the second memory is usually Nonvolatile memory since the first memory is usually volatile ram,
Data in first memory are stored in time to the second memory, data can be preferably saved, data is prevented to be lost.
In some optional implementations of the present embodiment, the first trigger condition can include but is not limited to it is following it
The size of the data stored in one: the first memory is greater than preset first threshold.It receives and is deposited for the first memory
The operation requests information of the data of storage.
Here, the size for the data that executing subject can be currently stored in the first memory is greater than preset first
When threshold value, data currently stored in the first memory are all stored into the second memory.Wherein, first threshold can be skill
The preset data value of art personnel.In addition, executing subject can also receive the data stored for the first memory
When operation requests information, data currently stored in the first memory are all stored into the second memory.Wherein, aforesaid operations
Solicited message can be for requesting to store the data stored in the first memory to the information of the second memory.As an example,
Aforesaid operations solicited message can be digital " 1 ", be also possible to character group " yes ", will be stored in the first memory for requesting
Data store to the second memory.
In the present embodiment, it stores by the data stored in the first memory to the second memory, executing subject can be with
By data original in the second memory, with it is being newly stored in, merge from the data of the first memory, to realize in second
Data in depositing are updated.
In some optional implementations of the present embodiment, the structure for the data that the first memory is stored is tree construction,
The structure for the data that second memory is stored is tree construction.At this point, it is above-mentioned by data original in the second memory, with new deposit
, merge from the data of the first memory, may include: using tree merge algorithm will correspond to it is original in the second memory
Data tree construction, merge, obtain new with tree constructions be newly stored in, data from the first memory are corresponded to
Tree construction.As an example, above-mentioned tree merges algorithm can calculate to set above heuristic merging (dsu on tree), optimum binary tree
Method (also known as, Huffman (Huffman) tree algorithm) etc..
In some optional implementations of the present embodiment, the data stored in the first memory are stored in second
After depositing, further includes: the data for being stored the first memory are deleted.
Here, it stores by the data in the first memory to the second memory, the second memory is equivalent to the first memory institute
The data of storage are backed up.At this point, executing subject can delete the data being backed up in the first memory.This
Sample can discharge the memory space of the first memory, improve the utilization rate to the memory space of the first memory.
Step 203, meet the second trigger condition in response to determining, according to the data that the second memory is stored, update external
The data that storage equipment is stored.
In the present embodiment, when meeting the second trigger condition, number that executing subject can will be stored in the second memory
According to storing to the second memory.It should be pointed out that just the data in the second memory are stored after meeting the second trigger condition
To External memory equipment, and the indirect data by the second memory are stored to External memory equipment, it is therefore intended that: it can be
Data in two memories, which meet, is then written to External memory equipment in a certain amount of situation, it is possible to reduce the second memory is deposited with outside
Number is written in the data stored up between equipment, improves data write efficiency.
In some optional implementations of the present embodiment, the second trigger condition includes: to be stored in the second memory
The size of data is greater than preset second threshold.
Here, the size for the data that executing subject can be currently stored in the second memory is greater than preset second
When threshold value, data currently stored in the second memory are all stored into External memory equipment.Wherein, second threshold can be with
It is the preset data value of technical staff.
In the present embodiment, data in second memory are stored to External memory equipment determining, executing subject can
To use various ways, the data that External memory equipment is stored are updated.
In some optional implementations of the present embodiment, executing subject can update external deposit in the following way
The data that storage equipment is stored:
The first step determines the current data page in External memory equipment, by the data that current data page is stored store to
Second memory, and determine the residual memory space size of current data page.It should be pointed out that in External memory equipment usually
It is that data are stored using data page.In External memory equipment, what the size of data page was usually fixed, data page and number
It is connected according between page by preset sequence.As an example, above-mentioned preset sequence can be number order.
In further example, if the number of some data page is 2, the number of the next data page adjacent with the data page can be
3。
In this implementation, above-mentioned current data page typically refers to currently can be used for storing the stored number of the second memory
According to data page.Optionally, executing subject can be determined from External memory equipment currently according to the number order of data page
Data page.As an example, currently can be used for storing if data page currently stored in External memory equipment has 1,2,3,4
The data page of second memory institute storing data, can be 1,2,3,4, be that the insertion of second memory institute's storing data is had number at this time
According in page.It is also possible to newly-increased data page 5.
In this implementation, the size of data page can be subtracted the number that current data page is stored at present by executing subject
According to size, obtain the residual memory space size of current data page.
Second step, in response to determining size of the residual memory space size less than the data that the second memory is stored, the
In two memories, the data that the data that current data page is stored are stored with the second memory are merged.
In this implementation, residual memory space size less than the data that the second memory is stored size, at this point, currently
Data page cannot load the data that the second memory is stored, and need 2 data pages.At this point, above-mentioned stored current data page
The data that are stored with the second memory of data merge, typically refer in the data and second that will be stored in current data page
Deposit paging again after stored data merge, available two data pages.In this implementation, in current data page
Storage is stored into the second memory, it is intended to realize and execute the data that will be stored in current data page and the second memory in the second memory
The data stored merge, and effective storage to data may be implemented.
Third step stores the data after merging to External memory equipment, and empties the second memory.Here, master is executed
Body can directly store the data after merging to External memory equipment.Meanwhile it will be in the second memory that backup executed
Data are deleted, and to discharge the memory space of the second memory, improve the utilization rate to the memory space of the second memory.
In some optional implementations of the present embodiment, executing subject can also update external in the following way
The data that storage equipment is stored: it is stored in response to determining that the residual memory space size of current data page is greater than the second memory
The sizes of data data that current data page is stored and the data that the second memory is stored are carried out in the second memory
Merge, the data after merging is stored to External memory equipment, and empty the second memory.
In this implementation, if residual memory space size is greater than the size for the data that the second memory is stored, at this point, working as
Preceding data page can load the data that the second memory is stored.At this point, the above-mentioned data for being stored current data page and second
The data that memory is stored merge, and typically refer to the number for being stored the data stored in current data page and the second memory
According to directly merging.
With continued reference to one that Fig. 3, Fig. 3 are according to the application scenarios 300 of the method for storing data of the present embodiment
Schematic diagram.In the application scenarios of Fig. 3, the application A being currently running in terminal device 301 produces new data (x1, x2).
At this point, the database server 302 connecting with terminal equipment in communication is available to arrive new data (x1, x2), and
New data (x1, x2) is stored into the first memory.
Data that then, database server 302 can be stored in the first memory ((x1, x2), (x3), (x4, x5,
X6 when size)) is greater than first threshold T1, by the data stored in the first memory { (x1, x2), (x3), (x4, x5, x6) }
It stores into the second memory.At this point, if being stored with data (y1, y2, y3, y4) in the second memory.Then by institute in the first memory
After the data ((x1, x2), (x3), (x4, x5, x6)) of storage are stored in the second memory, in available updated second memory
Data be ((x1, x2), (x3), (x4, x5, x6), (y1, y2, y3, y4)).
Finally, data that database server 302 can be stored in the second memory ((x1, x2), (x3), (x4, x5,
X6), (y1, y2, y3, y4), (x7, x8), (y5)) size when being greater than second threshold T2, data that the second memory is stored
((x1, x2), (x3), (x4, x5, x6), (y1, y2, y3, y4), (x7, x8), (y5)) is stored to External memory equipment, is realized more
The data that new External memory equipment is stored.
The method for storing data provided by the above embodiment of the disclosure is new caused by available target application
Data store new data into the first memory.Then, meet the first trigger condition in response to determining, by institute in the first memory
The data of storage are stored to the second memory, and update the data in the second memory.Finally, meeting the second triggering in response to determining
Condition updates the data that External memory equipment is stored according to the data that the second memory is stored.The method of the present embodiment is led to
It crosses the first memory, the second memory and External memory equipment to store to using generated data, helping to realize will apply
Generated data are effectively stored.
With further reference to Fig. 4, it illustrates the processes 400 of another embodiment of method for storing data.The use
In the process 400 of the method for storing data, comprising the following steps:
Step 401, new data caused by target application is obtained, new data is stored into the first memory.
Step 402, meet the first trigger condition in response to determining, the data stored in the first memory are stored to second
Memory, and update the data in the second memory.
Step 403, meet the second trigger condition in response to determining, according to the data that the second memory is stored, update external
The data that storage equipment is stored.
In the present embodiment, the behaviour of the concrete operations of step 401-403 and step 201-203 in embodiment shown in Fig. 2
Make essentially identical, details are not described herein.
Step 404, latest data involved in the update in External memory equipment is stored to the first memory.
In the present embodiment, latest data involved in above-mentioned update can refer to and be stored in External memory equipment
The newest value of variable.Here, executing subject will update related latest data and store in first in External memory equipment
In depositing, it is intended to put newest data in the buffer so that application is read in advance.It can help improve using the reading to data
Take efficiency.
It should be pointed out that the first memory usually has, there are two subregions, and one of subregion is for caching from external storage
The data that equipment is read in advance, to improve data reading performance using redundancy, here, for ease of description, which can be denoted as buffer area.
Another subregion is then used to store using the new data that constantly generates in the process of running, and for ease of description, which can be with
It is denoted as writable area.
In the optional implementation of each embodiment of the disclosure, meet the first trigger condition, root in response to determining
The data in buffer area are updated according to the data that the first memory is stored.In this implementation, determine the writable area of the first memory
When middle stored data are stored to the second memory, executing subject can be using the data that writable area is stored to above-mentioned buffer area
Middle stored data are updated.It helps to realize and stores latest data into buffer area.In this way, helping to realize application
Latest data can be always read from buffer area.It should be pointed out that if using needed for cannot being read from buffer area
Data, then needed for executing subject can also be found from the writable area, the second memory and External memory equipment of the first memory
Data, for using.
In the optional implementation of each embodiment of the disclosure, the structure for the data that the first memory is stored is tree
Structure, the structure for the data that the second memory is stored are tree construction, and the structure for the data that External memory equipment is stored is tree knot
Structure.Optionally, the structure for the data that the first memory is stored can be tied for LSM tree (Log-Structured Merge, Tree)
Structure, the structure for the data that the second memory is stored can be that LSM tree construction and said external store the data that equipment is stored
Structure can be B+ tree (B+Tree) structure.Wherein, the data that above-mentioned first memory is stored, typically refer in the first memory
For storing the data stored in the subregion using generated data.
It should be pointed out that B+ tree is usually that tree construction is established on the basis of key value, the corresponding number of a key value
According to.When needing some data B+ tree is written, need first to obtain the key value of the data, then by obtained key value and
Stored key value is compared in B+ tree.If there is the key value phase with the data to be stored in stored key value
Key value that is same or matching, then can be right to key value institute already existing in B+ tree using the current data to be stored
The data answered are modified.Conversely, if it does not exist, being then added to B+ for the key value for the data to be stored as new node
Tree, stores the data to be stored.In addition, LSM tree is usually directly to be added to the data to be stored.Also
It is to say, under the storage mode of LSM tree, in the data that are stored, the key value of multiple data may be identical.As an example,
The key value of above-mentioned data can be the variable name of variable corresponding to data, be also possible to the cryptographic Hash etc. of data.
In the optional implementation of each embodiment of the disclosure, the structure for the data that the first memory is stored is
LSM tree construction, the structure for the data that the second memory is stored are the data that LSM tree construction and External memory equipment are stored
Structure be B+ tree construction when.At this point, during by data from the first memory storage to the second memory, executing subject can be with
After determining the first trigger condition of satisfaction, directly the LSM tree that the first memory is stored is stored into the second memory.Then, exist
It is executed in second memory and merges the data with identical key value.Later, executing subject can meet second determining
After trigger condition, executing in the second memory will be in the key value for the data that stored, with the B+ tree in External memory equipment
Stored key value is compared, and realization stores the data in the second memory to External memory equipment.
In addition, it is necessary to which, it is noted that the speed inserted data into tree is exceedingly fast due to setting the data structure being ordered into.
Therefore, the structure for the data that the first memory is stored is tree construction, and the structure for the data that the second memory is stored is tree construction, with
And the structure of data that External memory equipment is stored is tree construction, facilitates the storage speed for promoting data.
Figure 4, it is seen that the method for storing data compared with the corresponding embodiment of Fig. 2, in the present embodiment
Process 400 highlight the step of storing latest data involved in the update in External memory equipment to the first memory.By
This, the scheme of the present embodiment description can be put newest data in advance in the buffer so that application is read, can be to application
While generated data are effectively stored, application is improved to the reading efficiency of data.
With further reference to Fig. 5, as the realization to method shown in above-mentioned each figure, present disclose provides one kind for storing number
According to device one embodiment, the Installation practice is corresponding with embodiment of the method shown in Fig. 2, which can specifically answer
For in various electronic equipments.
As shown in figure 5, the device 500 for storing data of the present embodiment includes: the first storage unit 501, it is configured
At new data caused by target application is obtained, new data is stored into the first memory;First updating unit 502, is configured
Meet the first trigger condition in response to determining, the data stored in the first memory are stored to the second memory, and updates
Data in second memory;Second updating unit 503 is configured in response to determine the second trigger condition of satisfaction, according to second
The data that memory is stored update the data that External memory equipment is stored.
In some optional implementations of the present embodiment, in the second updating unit 503, deposited according in the second memory
The data of storage update the data that External memory equipment is stored, and may include: firstly, determining current in External memory equipment
Data page stores the data that current data page is stored to the second memory, and determines that the remaining storage of current data page is empty
Between size.Then, in response to determining size of the residual memory space size less than the data that the second memory is stored, in second
In depositing, the data that the data that current data page is stored are stored with the second memory are merged.Finally, by the number after merging
According to storing to External memory equipment, and empty the second memory.
In some optional implementations of the present embodiment, in the first updating unit 502, the first trigger condition be can wrap
Include following one: the size of the data stored in the first memory is greater than preset first threshold and receives for first
The operation requests information for the data that memory is stored.In second updating unit 503, the second trigger condition may include: in second
The size for depositing middle stored data is greater than preset second threshold.
In some optional implementations of the present embodiment, the structure for the data that the first memory is stored is tree construction,
The structure for the data that second memory is stored is tree construction.
In some optional implementations of the present embodiment, in the first storage unit 501, it will be stored in the first memory
Data store to the second memory, can also include: that the data for being stored the first memory are deleted.
In some optional implementations of the present embodiment, volatile ram is saved as in first, is saved as in second non-easy
The property lost memory, External memory equipment is disk.
In some optional implementations of the present embodiment, which can also be including the second storage unit (in figure not
It shows).Wherein, the second storage unit may be configured to deposit latest data involved in the update in External memory equipment
It stores up to the first memory.
The device provided by the above embodiment of the disclosure, the first storage unit 501 obtains newly to be counted caused by target application
According to storing new data into the first memory.Then, the first updating unit 502 meets the first trigger condition in response to determining, will
The data stored in first memory are stored to the second memory, and update the data in the second memory.Finally, second updates list
Member 503 meets the second trigger condition in response to determining, according to the data that the second memory is stored, updates External memory equipment and is deposited
The data of storage.The device of the present embodiment, by the first memory, the second memory and External memory equipment to using generated data
It is stored, helping to realize will effectively be stored using generated data.
Below with reference to Fig. 6, it illustrates the electronic equipment that is suitable for being used to realize embodiment of the disclosure, (example is as shown in figure 1
Database server) 600 structural schematic diagram.Electronic equipment shown in Fig. 6 is only an example, should not be to the reality of the disclosure
The function and use scope for applying example bring any restrictions.
As shown in fig. 6, electronic equipment 600 may include processing unit (such as central processing unit (CPU), graphics process
Device etc.) 601, can according to the program being stored in read-only memory (ROM) 602 or from storage device 608 be loaded into
Machine accesses the program in memory (RAM) 603 and executes various movements appropriate and processing.In RAM 603, it is also stored with electricity
Sub- equipment 600 operates required various programs and data.Processing unit 601, ROM 602 and RAM 603 by bus 604 that
This is connected.Input/output (I/O) interface 605 is also connected to bus 604.
In general, following device can connect to I/O interface 605: including such as touch screen, touch tablet, keyboard, mouse, taking the photograph
As the input unit 606 of head, microphone, accelerometer, gyroscope etc.;Including such as liquid crystal display (LCD), loudspeaker, vibration
The output device 607 of dynamic device etc.;Storage device 608 including such as tape, hard disk etc.;And communication device 609.Communication device
609, which can permit electronic equipment 600, is wirelessly or non-wirelessly communicated with other equipment to exchange data.Although Fig. 6 shows tool
There is the electronic equipment 600 of various devices, it should be understood that being not required for implementing or having all devices shown.It can be with
Alternatively implement or have more or fewer devices.Each box shown in Fig. 6 can represent a device, can also root
According to needing to represent multiple devices.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description
Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium
On computer program, which includes the program code for method shown in execution flow chart.In such reality
It applies in example, which can be downloaded and installed from network by communication device 609, or from storage device 608
It is mounted, or is mounted from ROM 602.When the computer program is executed by processing unit 601, the implementation of the disclosure is executed
The above-mentioned function of being limited in the method for example.It should be noted that the computer-readable medium of embodiment of the disclosure can be meter
Calculation machine readable signal medium or computer readable storage medium either the two any combination.Computer-readable storage
Medium for example may be-but not limited to-system, device or the device of electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor,
Or any above combination.The more specific example of computer readable storage medium can include but is not limited to: have one
Or the electrical connections of multiple conducting wires, portable computer diskette, hard disk, random access storage device (RAM), read-only memory (ROM),
Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light
Memory device, magnetic memory device or above-mentioned any appropriate combination.In embodiment of the disclosure, computer-readable to deposit
Storage media can be any tangible medium for including or store program, which can be commanded execution system, device or device
Part use or in connection.And in embodiment of the disclosure, computer-readable signal media may include in base band
In or as carrier wave a part propagate data-signal, wherein carrying computer-readable program code.This propagation
Data-signal can take various forms, including but not limited to electromagnetic signal, optical signal or above-mentioned any appropriate combination.Meter
Calculation machine readable signal medium can also be any computer-readable medium other than computer readable storage medium, which can
Read signal medium can be sent, propagated or be transmitted for being used by instruction execution system, device or device or being tied with it
Close the program used.The program code for including on computer-readable medium can transmit with any suitable medium, including but not
It is limited to: electric wire, optical cable, RF (radio frequency) etc. or above-mentioned any appropriate combination.
Above-mentioned computer-readable medium can be included in above-mentioned electronic equipment;It is also possible to individualism, and not
It is fitted into the electronic equipment.Above-mentioned computer-readable medium carries one or more program, when said one or more
When a program is executed by the electronic equipment, so that the electronic equipment: obtaining new data caused by target application, new data is deposited
Storage is into the first memory;Meet the first trigger condition in response to determining, the data stored in the first memory are stored to second
Memory, and update the data in the second memory;Meet the second trigger condition in response to determining, is stored according to the second memory
Data update the data that External memory equipment is stored.
The behaviour for executing embodiment of the disclosure can be write with one or more programming languages or combinations thereof
The computer program code of work, programming language include object oriented program language-such as Java,
Smalltalk, C++ further include conventional procedural programming language-such as " C " language or similar program design language
Speech.Program code can be executed fully on the user computer, partly be executed on the user computer, as an independence
Software package execute, part on the user computer part execute on the remote computer or completely in remote computer or
It is executed on server.In situations involving remote computers, remote computer can pass through the network of any kind --- packet
It includes local area network (LAN) or wide area network (WAN)-is connected to subscriber computer, or, it may be connected to outer computer (such as benefit
It is connected with ISP by internet).
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the disclosure, method and computer journey
The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation
A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use
The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box
The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually
It can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it to infuse
Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding
The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction
Combination realize.
Being described in unit involved in embodiment of the disclosure can be realized by way of software, can also be passed through
The mode of hardware is realized.Described unit also can be set in the processor, for example, can be described as: a kind of processor
Including the first storage unit, the first updating unit and the second updating unit.Wherein, the title of these units is under certain conditions simultaneously
The restriction to the unit itself is not constituted, for example, the first storage unit is also described as " obtaining caused by target application
New data is stored the unit into the first memory by new data ".
Above description is only the preferred embodiment of the disclosure and the explanation to institute's application technology principle.Those skilled in the art
Member is it should be appreciated that invention scope involved in the disclosure, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic
Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature
Any combination and the other technical solutions formed.Such as features described above has similar function with (but being not limited to) disclosed in the disclosure
Can technical characteristic replaced mutually and the technical solution that is formed.
Claims (16)
1. a kind of method for storing data, comprising:
New data caused by target application is obtained, the new data is stored into the first memory;
Meet the first trigger condition in response to determining, the data stored in the first memory are stored to the second memory, Yi Jigeng
Data in new second memory;
Meet the second trigger condition in response to determining, according to the data that second memory is stored, updates External memory equipment
The data stored.
2. according to the method described in claim 1, wherein, described according to the data stored in second memory, update is outer
The data that portion's storage equipment is stored, comprising:
It determines the current data page in External memory equipment, the data that the current data page is stored is stored in second
It deposits, and determines the residual memory space size of the current data page;
Size in response to the determination residual memory space size less than the data that the second memory is stored, in the second memory
In, the data that the data that the current data page is stored are stored with second memory are merged;
Data after merging are stored to External memory equipment, and empty second memory.
3. according to the method described in claim 1, wherein,
First trigger condition includes following one: the size of the data stored in the first memory is greater than preset the
One threshold value;Receive the operation requests information of the data stored for the first memory;
Second trigger condition includes: that the size of the data stored in the second memory is greater than preset second threshold.
4. according to the method described in claim 1, wherein, the structure for the data that first memory is stored is tree construction, institute
The structure for stating the data that the second memory is stored is tree construction.
5. described to store the data stored in the first memory to the second memory according to the method described in claim 1, wherein
Later, further includes: the data for being stored first memory are deleted.
6. according to the method described in claim 1, wherein, volatile ram being saved as in described first, is saved as in described second non-
Volatile ram, the External memory equipment are disk.
7. method described in one of -6 according to claim 1, wherein the method also includes:
Latest data involved in update in External memory equipment is stored to first memory.
8. a kind of device for storing data, comprising:
First storage unit is configured to obtain new data caused by target application, and the new data is stored in first
In depositing;
First updating unit is configured in response to determine the first trigger condition of satisfaction, the data that will be stored in the first memory
It stores to the second memory, and updates the data in second memory;
Second updating unit is configured in response to determine the second trigger condition of satisfaction, be stored according to second memory
Data update the data that External memory equipment is stored.
9. device according to claim 8, wherein described to be deposited according in second memory in the second updating unit
The data of storage update the data that External memory equipment is stored, comprising:
It determines the current data page in External memory equipment, the data that the current data page is stored is stored in second
It deposits, and determines the residual memory space size of the current data page;
Size in response to the determination residual memory space size less than the data that the second memory is stored, in the second memory
In, the data that the data that the current data page is stored are stored with second memory are merged;
Data after merging are stored to External memory equipment, and empty second memory.
10. device according to claim 8, wherein
In first updating unit, first trigger condition includes following one: the data stored in the first memory
Size is greater than preset first threshold;Receive the operation requests information of the data stored for the first memory;
In second updating unit, second trigger condition includes: that the size of the data stored in the second memory is greater than
Preset second threshold.
11. device according to claim 8, wherein the structure for the data that first memory is stored is tree construction, institute
The structure for stating the data that the second memory is stored is tree construction.
12. device according to claim 8, wherein described to be stored in first memory in first storage unit
Data store to the second memory, further includes: the data for being stored first memory are deleted.
13. device according to claim 8, wherein save as volatile ram in described first, saved as in described second non-
Volatile ram, the External memory equipment are disk.
14. the device according to one of claim 8-13, wherein described device further include:
Second storage unit is configured to store latest data involved in the update in External memory equipment to described first
Memory.
15. a kind of electronic equipment, comprising:
One or more processors;
Storage device is stored thereon with one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real
The now method as described in any in claim 1-7.
16. a kind of computer-readable medium, is stored thereon with computer program, wherein the realization when program is executed by processor
Method as described in any in claim 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910189069.6A CN109918381B (en) | 2019-03-13 | 2019-03-13 | Method and apparatus for storing data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910189069.6A CN109918381B (en) | 2019-03-13 | 2019-03-13 | Method and apparatus for storing data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109918381A true CN109918381A (en) | 2019-06-21 |
CN109918381B CN109918381B (en) | 2021-06-11 |
Family
ID=66964601
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910189069.6A Active CN109918381B (en) | 2019-03-13 | 2019-03-13 | Method and apparatus for storing data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109918381B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111221922A (en) * | 2019-12-31 | 2020-06-02 | 苏州浪潮智能科技有限公司 | RocksDB database data writing method and RocksDB database |
CN111580959A (en) * | 2020-04-26 | 2020-08-25 | Oppo(重庆)智能科技有限公司 | Data writing method, data writing device, server and storage medium |
CN114430458A (en) * | 2020-10-29 | 2022-05-03 | 北京小米移动软件有限公司 | Anti-shake data acquisition method, anti-shake data acquisition apparatus, and storage medium |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102122256A (en) * | 2011-03-28 | 2011-07-13 | 中国人民解放军国防科学技术大学 | Pipe-type communication method and system for interprocess communication |
CN103425589A (en) * | 2012-05-17 | 2013-12-04 | 索尼公司 | Control apparatus, storage device, and storage control method |
CN103678149A (en) * | 2013-12-19 | 2014-03-26 | 华为技术有限公司 | Data processing method and device |
CN104731533A (en) * | 2015-03-31 | 2015-06-24 | 百度在线网络技术(北京)有限公司 | Data write-in method and device |
CN105224237A (en) * | 2014-05-26 | 2016-01-06 | 华为技术有限公司 | A kind of date storage method and device |
CN105511802A (en) * | 2015-11-24 | 2016-04-20 | 北京达沃时代科技有限公司 | Buffer memory writing method and apparatus and synchronizing method and apparatus for disk cache region |
CN105631035A (en) * | 2016-01-04 | 2016-06-01 | 北京百度网讯科技有限公司 | Data storage method and device |
CN106055274A (en) * | 2016-05-23 | 2016-10-26 | 联想(北京)有限公司 | Data storage method, data reading method and electronic device |
CN107451152A (en) * | 2016-05-31 | 2017-12-08 | 阿里巴巴集团控股有限公司 | Computing device, data buffer storage and the method and device of lookup |
CN108415855A (en) * | 2018-03-06 | 2018-08-17 | 珠海全志科技股份有限公司 | It makes video recording file memory method and device, computer installation and storage medium |
CN109254733A (en) * | 2018-09-04 | 2019-01-22 | 北京百度网讯科技有限公司 | Methods, devices and systems for storing data |
US20190065325A1 (en) * | 2017-08-31 | 2019-02-28 | International Business Machines Corporation | Restore current version of a track from a non-volatile storage into a new location in cache |
-
2019
- 2019-03-13 CN CN201910189069.6A patent/CN109918381B/en active Active
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102122256A (en) * | 2011-03-28 | 2011-07-13 | 中国人民解放军国防科学技术大学 | Pipe-type communication method and system for interprocess communication |
CN103425589A (en) * | 2012-05-17 | 2013-12-04 | 索尼公司 | Control apparatus, storage device, and storage control method |
CN103678149A (en) * | 2013-12-19 | 2014-03-26 | 华为技术有限公司 | Data processing method and device |
CN105224237A (en) * | 2014-05-26 | 2016-01-06 | 华为技术有限公司 | A kind of date storage method and device |
CN104731533A (en) * | 2015-03-31 | 2015-06-24 | 百度在线网络技术(北京)有限公司 | Data write-in method and device |
CN105511802A (en) * | 2015-11-24 | 2016-04-20 | 北京达沃时代科技有限公司 | Buffer memory writing method and apparatus and synchronizing method and apparatus for disk cache region |
CN105631035A (en) * | 2016-01-04 | 2016-06-01 | 北京百度网讯科技有限公司 | Data storage method and device |
CN106055274A (en) * | 2016-05-23 | 2016-10-26 | 联想(北京)有限公司 | Data storage method, data reading method and electronic device |
CN107451152A (en) * | 2016-05-31 | 2017-12-08 | 阿里巴巴集团控股有限公司 | Computing device, data buffer storage and the method and device of lookup |
US20190065325A1 (en) * | 2017-08-31 | 2019-02-28 | International Business Machines Corporation | Restore current version of a track from a non-volatile storage into a new location in cache |
CN108415855A (en) * | 2018-03-06 | 2018-08-17 | 珠海全志科技股份有限公司 | It makes video recording file memory method and device, computer installation and storage medium |
CN109254733A (en) * | 2018-09-04 | 2019-01-22 | 北京百度网讯科技有限公司 | Methods, devices and systems for storing data |
Non-Patent Citations (1)
Title |
---|
英昌甜: "内存计算环境下基于索引结构的内存优化策略", 《新疆大学学报(自然科学版)》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111221922A (en) * | 2019-12-31 | 2020-06-02 | 苏州浪潮智能科技有限公司 | RocksDB database data writing method and RocksDB database |
CN111580959A (en) * | 2020-04-26 | 2020-08-25 | Oppo(重庆)智能科技有限公司 | Data writing method, data writing device, server and storage medium |
CN111580959B (en) * | 2020-04-26 | 2023-02-28 | Oppo(重庆)智能科技有限公司 | Data writing method, data writing device, server and storage medium |
CN114430458A (en) * | 2020-10-29 | 2022-05-03 | 北京小米移动软件有限公司 | Anti-shake data acquisition method, anti-shake data acquisition apparatus, and storage medium |
CN114430458B (en) * | 2020-10-29 | 2023-12-19 | 北京小米移动软件有限公司 | Anti-shake data acquisition method, anti-shake data acquisition device, and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN109918381B (en) | 2021-06-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11146502B2 (en) | Method and apparatus for allocating resource | |
CN109391509A (en) | A kind of method, system and the application server of more new application | |
CN113641457B (en) | Container creation method, device, apparatus, medium, and program product | |
CN109918381A (en) | Method and apparatus for storing data | |
CN109657174A (en) | Method and apparatus for more new data | |
CN109388626A (en) | Method and apparatus for being numbered to traffic assignments | |
CN110275723A (en) | Obtain method, apparatus, electronic equipment and the readable medium of resource | |
CN109447635A (en) | Information storage means and device for block chain | |
CN109213536A (en) | Resource exhibition method, resource show configuration method, device and the equipment of class control | |
CN103593485B (en) | The method and apparatus for realizing database real-time operation | |
CN110430142A (en) | Method and apparatus for controlling flow | |
CN114911518A (en) | Cloud function application release management method, system, equipment and storage medium | |
CN114625536A (en) | Video memory allocation method, device, medium and electronic equipment | |
CN110119386A (en) | Data processing method, data processing equipment, medium and calculating equipment | |
JP2012159924A (en) | Installation system | |
CN109669637A (en) | For providing system, the method and apparatus of container service | |
CN109885593A (en) | Method and apparatus for handling information | |
CN109271224A (en) | Method and apparatus for determining position | |
CN113391882B (en) | Virtual machine memory management method and device, storage medium and electronic equipment | |
CN108984770A (en) | Method and apparatus for handling data | |
CN113779412B (en) | Message touch method, node and system based on blockchain network | |
CN111275543B (en) | Information processing method, device, server and storage medium | |
CN111857736B (en) | Cloud computing product generation method, device, equipment and storage medium | |
CN111327472B (en) | Method and device for acquiring target network | |
CN110716699A (en) | Method and apparatus for writing data |
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 |