Database access method, terminal and server

An access method and database technology, applied in the field of distributed storage, can solve problems such as long time-consuming, high frequency of client trial and error updates, and reduced fast read and write performance

Active Publication Date: 2017-03-29
CHINA MOBILE COMM GRP CO LTD
12 Cites 3 Cited by

AI-Extracted Technical Summary

Problems solved by technology

Especially when the amount of data increases rapidly, the division of regions will be more frequent, and the frequency o...
View more

Method used

[0166] The technical solutions provided by the embodiments of the present invention have achieved transformations in several aspects: 1) On the basis of the original three-time access positioning mechanism, a solution for optimizing local cache is provided, relying on the cache automatic update mechanism to Improve the synchronization efficiency between the local cache and the remote database, so as to provide reliable local cache data for each access. In most cases, the data can be read and written with one access, which minimizes the amount of access, shortens the time between accesses, and reduces the load on the database. . 2) Add a new att...
View more

Abstract

The present invention discloses a database access method, a terminal and a server. The terminal stores a metatable locally. The method comprises the steps that the terminal starts a timer to time; the terminal determines whether a task of accessing a database is obtained in a process of timing by the timer, and obtains a first determining result; when the first determining result indicates that the task of accessing the database is not obtained when the timer ends up timing, the terminal sends an access request to the server, wherein the access request is used for requesting first identifier information in the metatable, and the first identifier information is used for indicating whether the terminal needs to update a local metatable; the terminal receives an access response sent by the server, wherein the access response carries the first identifier information; and when the first identifier information indicates that the terminal needs to update the local metatable, the terminal updates the local metatable.

Application Domain

Transmission

Technology Topic

Database accessTimer +2

Image

  • Database access method, terminal and server
  • Database access method, terminal and server
  • Database access method, terminal and server

Examples

  • Experimental program(4)

Example Embodiment

[0054] Example one
[0055] In order to solve the problems in the background art, an embodiment of the present invention provides a method for accessing a database. The method is applied to a terminal. The terminal stores a meta table and a root table locally. The functions implemented by the method can be implemented by a processor in the terminal. This is achieved by calling program codes. Of course, the program codes can be stored in a computer storage medium. It can be seen that the terminal includes at least a processor and a storage medium.
[0056] Figure 1-4 It is a schematic diagram of the implementation process of a database access method according to an embodiment of the present invention, such as Figure 1-4 As shown, the method includes:
[0057] Step S101, the terminal starts a timer to start timing;
[0058] Here, the timing time of the timer is set in advance, and the setting of the timing time is related to the averageTime of the server (may be the master node). As a preferred embodiment, the timing time can be set to averageTime; of course, The averageTime can be modified according to a certain rule, and then the modified value is used as the timing time, where the modification can be adding or subtracting a value from the averageTime, or multiplying the averageTime by a coefficient (between 0 and 1).
[0059] Step S102: The terminal judges whether the task of accessing the database is obtained during the start of the timer, and obtains the first judgment result;
[0060] Here, the task is an access task to data stored in the database;
[0061] Step S103: When the first judgment result indicates that the task of accessing the database is not obtained when the timer expires, the terminal sends an access request to the server;
[0062] Here, the access request is used to request the first identification information in the meta table, and the first identification information is used to indicate whether the terminal needs to update the local meta table; the first identification information has at least two types of information (ie, the first identification information). One information and second information), where the first information can be used to indicate that the terminal needs to update the local meta table, and the second information can be used to indicate that the terminal does not need to update the local meta table. The first identification information may be set by a person skilled in the art. For example, the first information may be 0 or 1 or Y (representing Yes) or N (No), etc. As for how to set it specifically, it will not be repeated here.
[0063] In the specific implementation process, as a preferred embodiment, the first identification information can be represented by a flag bit, for example, the updateFlag mentioned in the above embodiment. When the first identification information can use a flag bit, 1 For example, when updateFlag=1, it means the first information, which is a true value, and the terminal needs to update the local meta table; when updateFlag=0, it means the second information, which is a false value. The terminal does not need to update the local meta table.
[0064] Step S104: The terminal receives an access response sent by the server, and the access response carries first identification information;
[0065] Step S105: When the first identification information indicates that the terminal needs to update the local meta table, the terminal updates the local meta table.
[0066] In the embodiment of the present invention, the method further includes:
[0067] Step S106: When the first judgment result indicates that the task of accessing the database is obtained when the timer expires, the terminal reads the root table and the meta table stored locally;
[0068] Step S107: The terminal queries the root table and the meta table according to the task to obtain the access target;
[0069] Step S108: The terminal processes the user data in the server according to the access target.
[0070] Here, the processing includes at least deletion, addition, and modification of user data.
[0071] In the embodiment of the present invention, the terminal locally stores the meta table and the root table, and the method includes: the terminal starts the timer to start timing; the terminal judges whether the task of accessing the database is obtained during the start of the timer, and obtains the first judgment result When the first judgment result indicates that the task of accessing the database is not obtained when the timer expires, the terminal sends an access request to the server, the access request is used to request the first identification information in the meta table, and the first An identification information is used to indicate whether the terminal needs to update the local meta table; the terminal receives the access response sent by the server, and the access response carries the first identification information; when the first identification information indicates that the terminal needs to update the local meta table When meta-table, the terminal updates the local meta-table; in this way, the speed at which the terminal can access the database.

Example Embodiment

[0072] Example two
[0073] Based on the foregoing embodiment, an embodiment of the present invention provides a database access method, which is applied to a terminal, and the terminal locally stores a meta table and a root table, figure 2 It is a schematic diagram of the implementation process of the database access method in the second embodiment of the present invention, such as figure 2 As shown, the method includes:
[0074] Step S201: When the information in the meta table changes, the server updates the parameter values ​​in the meta table attributes;
[0075] Here, in addition to the parameters in the prior art, the parameters in the meta-table attributes also include the newly added parameters in the foregoing embodiment, for example, changeCount, changePercent, averageTime, updateFlag, and Threshold.
[0076] Here, the server in the embodiment of the present invention may be the master node.
[0077] Step S202: The server judges whether the parameter value meets a preset condition, and obtains a second judgment result;
[0078] Here, taking changeCount and changePercent as examples, two ways of implementing step S202 are provided.
[0079] Manner 1: The parameter in the meta table attribute includes the number of updates (changeCount). Correspondingly, the server determining whether the parameter value meets a preset condition includes:
[0080] The server determines whether the number of updates is greater than a preset first threshold, and when the number of updates is greater than the first threshold, it is determined that the parameter value meets a preset condition, and when the number of updates is less than or equal to the When the first threshold is determined, it is determined that the parameter value does not meet the preset condition.
[0081] Manner 2: The parameter in the meta-table attribute includes the update percentage (changePercent). Correspondingly, the server determining whether the parameter value meets a preset condition includes:
[0082] The server determines whether the update percentage is greater than a preset second threshold, and when the update percentage is greater than the second threshold, it is determined that the parameter value meets the preset condition, and when the update percentage is less than or equal to the When the second threshold is determined, it is determined that the parameter value does not meet the preset condition.
[0083] Here, suppose there is another percentage parameter in the meta table attribute, and the percentage parameter is used to indicate the percentage of the area in the meta table that has not changed. Then the server determines whether the parameter value meets the preset condition, including: The server determines whether the update percentage is less than a preset third threshold, and when the update percentage is less than the second threshold, it is determined that the parameter value meets a preset condition, and when the update percentage is greater than or equal to the first threshold, When the second threshold is used, it is determined that the parameter value does not meet the preset condition.
[0084] Step S203: When the second judgment result indicates that the parameter value meets a preset condition, the server updates the first identification information of the meta table to first information;
[0085] Here, the first information indicates that the terminal needs to update the locally stored meta table.
[0086] Step S204, the terminal starts a timer to start timing;
[0087] Step S205: The terminal judges whether the task of accessing the database is obtained during the start of the timer, and obtains the first judgment result;
[0088] Here, the task is an access task to data stored in the database;
[0089] Step S206: When the first judgment result indicates that the task of accessing the database is not obtained when the timer expires, the terminal sends an access request to the server;
[0090] Here, the above steps S204 to S206 respectively correspond to steps S101 to S103 in the first embodiment. Therefore, those skilled in the art can refer to the first embodiment to understand the above steps S204 to S206. To save space, here No longer.
[0091] Step S207, the server receives the access request sent by the terminal;
[0092] Here, the access request is used to request the first identification information in the meta table, and the first identification information is used to indicate whether the terminal needs to update the local meta table;
[0093] Step S208: The server searches the meta table according to the access request, obtains the first identification information of the meta table, and carries the first identification information in the meta table in the access response;
[0094] Step S209: The server sends the access response to the terminal.
[0095] Step S210, the terminal receives the access response sent by the server;
[0096] Here, the access response carries first identification information;
[0097] Step S211: When the first identification information indicates that the terminal needs to update the local meta table, the terminal updates the local meta table.
[0098] Here, the above steps S209 to S211 respectively correspond to steps S104 to S105 in the first embodiment. Therefore, those skilled in the art can refer to the first embodiment to understand the above steps S209 to S211. To save space, here No longer.
[0099] Step S211, the terminal sends an update request to the server;
[0100] Here, the update request is used to request a meta table, and the first identification information of the requested meta table indicates that the local meta table needs to be updated; the access request and the update request carry identification information of the meta table; correspondingly , The access response carries the first identification information corresponding to the identification information of the meta table, and the update response carries the meta table corresponding to the identification information of the meta table.
[0101] Step S212: The server receives the update request sent by the terminal, and obtains the meta table according to the identification information of the meta table in the update request;
[0102] Step S213: The server carries the acquired meta table in an update response, and sends the update response to the terminal;
[0103] Step S214, the terminal receives an update response sent by the server;
[0104] Here, the update response carries an updated meta table corresponding to the first identification information;
[0105] Step S215: The terminal updates the updated meta table sent by the server to the local.
[0106] In the embodiment of the present invention, the method further includes:
[0107] Step S216: When the first judgment result indicates that the task of accessing the database is obtained when the timer expires, the terminal reads the root table and the meta table stored locally;
[0108] Step S217: The terminal queries the root table and the meta table according to the task to obtain the access target;
[0109] Step S218, the terminal processes the user data in the server according to the access target.
[0110] Here, the processing includes at least deletion, addition, and modification of user data.
[0111] In the embodiment of the present invention, the update response also carries an update time, and the method further includes:
[0112] Step S220: The terminal sets the timing time of the timer according to the update time.
[0113] In the embodiment of the present invention, the method further includes: the server updates the update time and/or the current time in the meta table attribute.

Example Embodiment

[0114] Example three
[0115] Based on the foregoing embodiment, the embodiment of the present invention provides a database access method, image 3 It is a schematic diagram of the implementation process of the database access method in the third embodiment of the present invention, such as image 3 As shown, the method includes:
[0116] Step S301, the client terminal starts to run;
[0117] Here, the client is installed on the terminal, and the terminal runs the client.
[0118] Step S302, start timing;
[0119] Specifically, the timer is started, and the timer starts timing.
[0120] Step S303, in the process of timer timing, determine whether to obtain an access task? If yes, go to step S304, otherwise, go to step S310;
[0121] Step S304, read the local cache;
[0122] Here, the local cache is a root table and a meta table;
[0123] Step S305, access the target;
[0124] Specifically, the root table and meta table are searched according to the access task to obtain the target address, and then the client directly accesses the target address;
[0125] Step S306, judge whether the return is correct? If yes, go to step S308, otherwise, go to step S307;
[0126] Step S307, are the n attempts successful? If yes, go to step S308, otherwise go to step S309;
[0127] Step S308, the task ends;
[0128] Step S309, update the target cache, and then return to step S305;
[0129] Here, the target cache is a locally cached meta table.
[0130] Step S310, waiting for the timing to be completed;
[0131] Specifically, waiting for the timer to complete regularly;
[0132] Step S311, access the database;
[0133] Step S312, judge whether updateFlag is True? If no, go to step S302, if yes, go to step S313;
[0134] Step S313, update all caches;
[0135] Step S314: Set the timing time of the timer according to averageTime.

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products