CN112948430A - Date data query method and device - Google Patents

Date data query method and device Download PDF

Info

Publication number
CN112948430A
CN112948430A CN202110338762.2A CN202110338762A CN112948430A CN 112948430 A CN112948430 A CN 112948430A CN 202110338762 A CN202110338762 A CN 202110338762A CN 112948430 A CN112948430 A CN 112948430A
Authority
CN
China
Prior art keywords
cache cluster
date data
calling
data query
query request
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
Application number
CN202110338762.2A
Other languages
Chinese (zh)
Other versions
CN112948430B (en
Inventor
安兴朝
李文翰
贾佳
王亚平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
Original Assignee
CCB Finetech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202110338762.2A priority Critical patent/CN112948430B/en
Publication of CN112948430A publication Critical patent/CN112948430A/en
Application granted granted Critical
Publication of CN112948430B publication Critical patent/CN112948430B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Development Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Technology Law (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a date data query method and device, and relates to the technical field of automatic program design. One embodiment of the method comprises: receiving a date data query request; calling the first cache cluster, and determining whether the first cache cluster is in a normal state; when the first cache cluster is determined to be in a normal state, responding to a date data query request according to a calling result obtained by calling the first cache cluster; and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request. The implementation mode not only improves the efficiency of inquiring date data and reduces the processing pressure of the database, but also can transfer the second cache cluster when the first cache cluster has faults such as network unsmooth and the like, thereby ensuring the normal operation of transaction services.

Description

Date data query method and device
Technical Field
The invention relates to the technical field of automatic program design, in particular to a date data query method and device.
Background
In many transaction businesses of banks, date data has a very important status, and errors in the date data may cause errors in bank accounts and cause losses to the banks.
However, in the prior art, the date data is generally stored in one database in a unified manner, and then the query request about the date data is processed by calling the database, so that not only is the efficiency low, but also the database is queried once every access request is required, which causes huge pressure on the database, and when the database has faults such as network failure, large-scale response timeout is caused, which further affects the transaction service.
Disclosure of Invention
In view of this, embodiments of the present invention provide a date data query method and apparatus, which can set up two cache clusters for a database, and after receiving a date data query request, first invoke a first cache cluster to determine whether the first cache cluster is in a normal state, and if it is determined that the first cache cluster is in the normal state, respond to the date data query request according to an invocation result obtained by invoking the first cache cluster; if the first cache cluster is determined to be in an abnormal state, the second cache cluster is called to respond to the date data query request, so that the date data query efficiency is improved, the processing pressure of the database is relieved, and when the first cache cluster has faults such as network unsmooth and the like, the second cache cluster can be called instead, and the normal operation of transaction service is guaranteed.
To achieve the above object, according to an aspect of an embodiment of the present invention, a date data query method is provided.
The date data query method of the embodiment of the invention comprises the following steps:
receiving a date data query request;
calling the first cache cluster, and determining whether the first cache cluster is in a normal state;
when the first cache cluster is determined to be in a normal state, responding to a date data query request according to a calling result obtained by calling the first cache cluster;
and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request.
Alternatively,
calling the first cache cluster, and determining whether the first cache cluster is in a normal state, wherein the steps of:
calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length;
when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state;
when the first cache cluster does not return a response within a first preset time, increasing the calling failure times, and determining whether the calling failure times are greater than a preset calling threshold value: if not, returning to execute the calling of the first cache cluster; if so, determining that the first cache cluster is in an abnormal state.
Alternatively,
when the number of the date data query requests is multiple, calling the first cache cluster, and determining whether the first cache cluster is in a normal state, wherein the steps comprise:
for each date data query request, performing:
calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length;
when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state;
when the first cache cluster does not return a response within a first preset time length, increasing the calling failure times corresponding to the date data query request in an incremental manner, and determining whether the calling failure times are greater than a preset calling threshold value; if not, returning to execute the calling of the first cache cluster; if yes, marking the date data query request as query failure, and increasing the query failure times;
and determining whether the query failure times are greater than a preset query threshold value, and if so, determining that the first cache cluster is in an abnormal state.
Alternatively,
when the first cache cluster is determined to be in an abnormal state, calling a second cache cluster to respond to a date data query request, wherein the steps of:
and calling the second cache cluster for one or more date data query requests marked as query failures to respond to the one or more date data query requests with query failures.
Alternatively,
when the first cache cluster is determined to be in an abnormal state, after the second cache cluster is called to respond to the date data query request, the method further comprises the following steps:
starting a detection thread, and setting a second preset time length for the detection thread so that the detection thread determines whether the first cache cluster is in a normal state or not every second preset time length;
if so, stopping calling the second cache cluster, and calling the first cache cluster again.
Alternatively,
invoking a second cache cluster to respond to a date data query request, comprising:
calling a second cache cluster, and determining whether the second cache cluster is in a normal state;
if not, the date data query request is responded by the query abnormal information, and the abnormal reminding information is sent to the front-end page.
Alternatively,
the date data query request comprises: an identifier of the requesting end;
responding to a date data query request according to a calling result obtained by calling the first cache cluster, and comprising the following steps:
determining whether the calling result is null;
if yes, responding the date data query request by using the null value, and setting a third preset time length corresponding to the request end according to the identifier so as to respond to the received other date data query requests including the identifier by using the null value within the third preset time length.
Alternatively,
the date data query request also comprises: first date data existing at a request end;
when the calling result is not empty, determining whether the calling result is the same as the first date data;
if yes, responding to the date data query request with the first date data;
if not, the date data query request is responded with the calling result.
Alternatively,
the date data query request comprises an identifier of a request end, the calling result comprises a date change field, and the date change field is used for indicating the working stage of the first cache cluster;
responding to a date data query request according to a calling result obtained by calling the first cache cluster, and comprising the following steps:
determining the working stage of the first cache cluster according to the date change field;
and responding to the date data query request according to the working phase of the first cache cluster.
Alternatively,
and when the first cache cluster is determined to be in the date change completion stage according to the date change field, responding the date data query request by using a null value, and setting a third preset time length corresponding to the request end according to the identifier so as to respond the received other date data query requests including the identifier by using the null value within the third preset time length.
Alternatively,
the date data query request also comprises: first date data existing at a request end;
and responding the date data query request with the first date data when the first cache cluster is determined to be in the date change preparation stage according to the date change field.
Alternatively,
and when the first cache cluster is determined to be in the date change execution stage according to the date change field, responding to the date data query request by using the second date data in the calling result.
Alternatively,
when the first cache cluster is determined to be in the date change execution stage according to the date change field, the method further comprises the following steps:
obtaining third date data from the persistent database;
determining whether the second date data is consistent with the third date data;
if not, circularly executing the following steps until the modification is successful or the modification times are larger than a preset modification threshold value:
modifying the second date data according to the third date data;
determining whether the modification is successful, if not, increasing the modification times, and judging whether the modification times are greater than a preset modification threshold value;
if not, the execution returns to modify the second date data according to the third date data.
Alternatively,
and when the modification times are larger than a preset modification threshold value, sending date change failure information to the front-end page.
Alternatively,
invoking a second cache cluster to respond to a date data query request, comprising:
and calling the second cache cluster according to the preset address of the second cache cluster so as to respond to the date data query request.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a date data query apparatus.
The date data query device comprises a request receiving module, a state determining module and a response module; wherein:
the request receiving module is used for receiving a date data query request;
the state determining module is used for calling the first cache cluster and determining whether the first cache cluster is in a normal state;
the response module is used for responding to the date data query request according to a calling result obtained by calling the first cache cluster when the first cache cluster is determined to be in a normal state; and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a date data query electronic device.
An electronic device for date data query according to an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by one or more processors, the one or more processors implement the date data query method of the embodiment of the invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention stores thereon a computer program that, when executed by a processor, implements a date data query method of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: two cache clusters can be set for the database, after a date data query request is received, a first cache cluster is called first to determine whether the first cache cluster is in a normal state, and if the first cache cluster is determined to be in the normal state, the date data query request is responded according to a calling result obtained by calling the first cache cluster; if the first cache cluster is determined to be in an abnormal state, the second cache cluster is called to respond to the date data query request, so that the date data query efficiency is improved, the processing pressure of the database is relieved, and when the first cache cluster has faults such as network unsmooth and the like, the second cache cluster can be called instead, and the normal operation of transaction service is guaranteed.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a diagram illustrating the main steps of a date data query method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main steps of a method for specifically performing step S102;
fig. 3 is a schematic diagram of another main step of specifically executing the method of step S102 when the number of the date data inquiry requests is plural;
FIG. 4 is a schematic diagram of the main steps of a method for specifically performing step S103;
FIG. 5 is a schematic diagram of the main steps of a method of collating second date data in a first cache cluster;
FIG. 6 is a schematic diagram of the main steps of a method of detecting the status of a first cache cluster;
fig. 7 is a schematic diagram of main blocks of a date data inquiry apparatus according to an embodiment of the present invention;
FIG. 8 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic diagram of main steps of a date data query method according to an embodiment of the present invention.
As shown in fig. 1, a date data query method according to an embodiment of the present invention mainly includes the following steps:
step S101: a date data query request is received.
In the embodiment of the invention, a two-level storage mode of cache cluster-persistent database is adopted to deal with the date data query request. Specifically, the date data can be stored in the cache cluster, so that after the date data query request is received, the date data can be directly queried from the cache cluster without processing the date data query request by the persistent database, and the pressure of the persistent database is relieved. In addition, an identifier of whether date data is changed or not can be stored in the cache cluster, if the date data in the persistent database is not changed, the date data is directly inquired from the cache cluster, and if the date data in the persistent database is changed, the changed date data is synchronized to the cache cluster firstly, and then the date data is inquired from the cache cluster.
In the embodiment of the present invention, the cache cluster adopts a "master library-backup library" manner, where the master library is a first cache cluster, and the backup library is a second cache cluster, where one or more second cache clusters may be provided, and data in the second cache cluster is consistent with data in the first cache cluster. After receiving the date data query request, firstly calling a main library, namely a first cache cluster to perform query, and if the first cache cluster has a fault in an abnormal state, such as network unsmooth and the like, then calling a backup library, namely a second cache cluster to perform query, so that the date data query request can be processed in time, and large-area delay is avoided.
Step S102: and calling the first cache cluster, and determining whether the first cache cluster is in a normal state.
In the embodiment of the present invention, a method for specifically executing step S102 may be as shown in fig. 2, where the method mainly includes the following steps:
step S201: calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length;
step S202: when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state;
step S203: when the first cache cluster does not return a response within a first preset time length, increasing the number of times of call failure;
step S204: determining whether the calling failure times are larger than a preset calling threshold value or not; if not, returning to execute the step S201, and if so, executing the step S205;
step S205: determining that the first cache cluster is in an abnormal state.
In the embodiment of the present invention, when there are a plurality of daily data query requests, another method for specifically executing step S102 may be as shown in fig. 3, where the method mainly includes the following steps:
for each date data query request, performing:
step S301: calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length;
step S302: when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state;
step S303: when the first cache cluster does not return a response within a first preset time length, increasing the number of calling failure times corresponding to the date data query request;
step S304: determining whether the calling failure times are larger than a preset calling threshold value or not; if not, returning to execute the step S301, and if so, executing the step S305;
step S305: marking the date data query request as query failure, and increasing the query failure times;
step S306: determining whether the number of times of query failure is greater than a preset query threshold, if so, executing step S307, and if not, executing step S308;
step S307: determining that the first cache cluster is in an abnormal state;
step S308: another target data query request that is not executed is selected, and the process returns to execute step S301.
In the embodiment of the present invention, when it is determined that the first cache cluster is in the abnormal state, for one or more date data query requests marked as query failures, the second cache cluster may be invoked to respond to the one or more date data query requests with query failures.
Step S103: when the first cache cluster is determined to be in a normal state, responding to a date data query request according to a calling result obtained by calling the first cache cluster;
in the embodiment of the present invention, the first cache cluster has three different working phases, which are a date change preparation phase, a date change execution phase, and a date change completion phase.
When the first cache cluster is in the preparation stage of date change, it is described that the first cache cluster and the persistent database are both prepared to change the date (for example, the date is changed to 11 pm at 59 pm and is prepared to be changed at 0 pm at 0), and at this time, the first date data in the persistent database may be synchronized into the first cache cluster from the first cache cluster, so that the request end knows that the first cache cluster is in the preparation stage of date change at this time through the response of the date data query request (i.e., the first date data of the current day is also available); when the first cache cluster is in the date change execution stage, it is described that the first date data in the first cache cluster is changed into the second date data and the first date data in the persistent database is changed into the third date data (normally, the second date data is the same as the third date data, for example, 0 point of the second day is reached, and both the first cache cluster and the persistent database change the date into the second day); when the first cache cluster is in the date change completion stage, which indicates that the change of the dates in the first cache cluster and the persistent database is completed at this time (for example, the time from 0 point 1 to 23 points 58 on the second day), the first cache cluster and the persistent database may use the changed date data as the first date data at this time.
Similarly, the second cache cluster also has the three working phases, and is always consistent with the working phase of the first cache cluster.
In a preferred embodiment of the present invention, since each request terminal continuously sends a date data query request to determine whether date data is changed from 11 pm to 59 pm to 0 pm on the next day, the time is not only a node of date change but also a node of rapid increase of received date data query requests, and therefore, the first cache cluster and the second cache cluster in the time can hold the first date data of the current day or the second date data of the next day. In the period from 0 point 1 to 23 points 58 of each day, the first cache cluster and the second cache cluster may be set empty, and the response received by the requesting end is a null value, which may know that the first cache cluster or the second cache cluster is in the date change completion stage at this time and the date is not changed, so the first date data obtained from 0 point 0 of the day may be used.
In the embodiment of the present invention, the date data query request may include: the method comprises the steps that identification of a request end and first date data existing in the request end are obtained; now, a method for specifically executing step S103 is shown in fig. 4, and the method mainly includes the following steps:
step S401: determining whether the calling result is null;
step S402: when the calling result is empty, responding to the date data query request by using a null value;
step S403: setting a third preset time corresponding to the request end according to the identifier of the request end, and responding to the received other date data query requests including the identifier by using a null value within the third preset time;
step S404: when the calling result is not empty, determining whether the calling result is the same as the first date data; if yes, go to step S405, if no, go to step S406;
step S405: responding to the date data query request with the first date data;
step S406: the date data query request is responded with the call result.
In the embodiment of the present invention, when the calling result is null, the date data query request is responded with a null value, and the response received by the requesting end is a null value at this time, so that it can be known that the date of the first cache cluster or the second cache cluster is in the date change completion stage at this time, and the date is not changed. And a third preset time length can be set for the request end, when another date data query request including the identifier of the request end is received within the third preset time length, it indicates that the request end has sent a date data query request again in the date change completion stage, and at this time, the first cache cluster does not need to be called to obtain a call result, and the call result can be directly responded by a null value, so that the pressure of the first cache cluster is reduced.
In another embodiment of the present invention, the date data query request may include: the method comprises the steps that identification of a request end and first date data existing in the request end are obtained; the calling result can include: a date change field to indicate a working phase of the first cache cluster. At this time, when it is determined that the first cache cluster is in a normal state, the working stage of the first cache cluster can be determined according to the date change field; and responding to the date data query request according to the working phase of the first cache cluster.
Specifically, when the first cache cluster is determined to be in the date change completion stage according to the date change field, responding to the date data query request by using a null value, and setting a third preset time length corresponding to the request end according to the identifier, so as to respond to the received other date data query requests including the identifier by using the null value within the third preset time length; when the first cache cluster is determined to be in a date change preparation stage according to the date change field, responding to a date data query request by first date data; and when the first cache cluster is determined to be in the date change execution stage according to the date change field, responding to the date data query request by using the second date data in the calling result.
In the embodiment of the present invention, when it is determined that the first cache cluster is in the date change execution stage according to the date change field, the second date data in the first cache cluster may be checked according to the third date data in the persistent database (similarly, the second date data in the second cache cluster also needs to be checked), so as to ensure the consistency of the date data among the persistent database, the first cache cluster, and the second cache cluster.
Specifically, a method for checking the second date data in the first cache cluster is shown in fig. 5, and the method mainly includes the following steps:
step S501: obtaining third date data from the persistent database;
step S502: determining whether the second date data and the third date data in the first cache cluster are consistent, if not, executing a step S503, and if so, ending the checking process;
step S503: modifying the second date data according to the third date data;
step S504: determining whether the modification is successful, if not, executing step S505, and if so, ending the checking process;
step S505: increasing the number of modification times, judging whether the number of modification times is greater than a preset modification threshold value, if not, returning to execute the step S503, and if so, executing the step S506;
step S506: and sending date change failure information to a front-end page.
In the embodiment of the present invention, when it is determined that the first cache cluster is in the date change preparation stage according to the date change field, after the first date data in the persistent database is synchronized to the first cache cluster, it may also check whether the first date data in the first cache cluster is correct according to the first date data in the persistent database (similarly, after the first date data is synchronized to the second cache cluster, it is also checked whether the first date data in the second cache cluster is correct), so as to verify whether the synchronization is successful, and ensure the consistency of the date data among the persistent database, the first cache cluster, and the second cache cluster.
Step S104: and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request.
In the embodiment of the present invention, when it is determined that the first cache cluster is in the abnormal state, the process of calling the second cache cluster to respond to the date data query request is similar to the process from step S102 to step S103, that is: it is also necessary to determine whether the second cache cluster is in a normal state in a similar manner, and to respond to the date data query request according to a second call result obtained by calling the second cache cluster in a similar manner. This part of the content will not be described in detail in this specification.
In the embodiment of the present invention, the second cache cluster may be called according to a preset address of the second cache cluster, so as to respond to the date data query request.
In the embodiment of the present invention, when it is determined that the first cache cluster is in the abnormal state, after the second cache cluster is called to respond to the date data query request, a detection process of the first cache cluster is further included, and specifically, a method for detecting a state of the first cache cluster is shown in fig. 6, and the method mainly includes the following steps:
step S601: starting a detection thread, and setting a second preset time length for the detection thread so that the detection thread determines whether the first cache cluster is in a normal state or not every second preset time length;
step S602: and when the detection thread determines that the first cache cluster is recovered to the normal state, stopping calling the second cache cluster, and calling the first cache cluster again.
In this embodiment of the present invention, invoking the second cache cluster to respond to the date data query request includes:
calling a second cache cluster, and determining whether the second cache cluster is in a normal state;
if not, the date data query request is responded by the query abnormal information, and the abnormal reminding information is sent to the front-end page.
In the embodiment of the present invention, a flag bit may also be set for the first cache cluster and the second cache cluster, where the flag bit is true when the first cache cluster is in a normal state; when the first cache cluster is in an abnormal state and the second cache cluster is in a normal state, the flag bit is false; and when the first cache cluster and the second cache cluster are both in abnormal states, the flag bit is empty, and abnormal reminding information is sent to the front-end page.
According to the date data query method provided by the embodiment of the invention, after two cache clusters are set for the database, after a date data query request is received, the first cache cluster is called firstly to determine whether the first cache cluster is in a normal state, and if the first cache cluster is determined to be in the normal state, the date data query request is responded according to a calling result obtained by calling the first cache cluster; if the first cache cluster is determined to be in an abnormal state, the second cache cluster is called to respond to the date data query request, so that the date data query efficiency is improved, the processing pressure of the database is relieved, and when the first cache cluster has faults such as network unsmooth and the like, the second cache cluster can be called instead, and the normal operation of transaction service is guaranteed.
Fig. 7 is a schematic diagram of main blocks of a date data inquiry apparatus according to an embodiment of the present invention.
As shown in fig. 7, a date data query apparatus 700 according to an embodiment of the present invention includes a request receiving module 701, a status determining module 702, and a response module 703; wherein:
a request receiving module 701, configured to receive a date data query request;
a state determining module 702, configured to invoke the first cache cluster and determine whether the first cache cluster is in a normal state;
a response module 703, configured to, when it is determined that the first cache cluster is in a normal state, respond to the date data query request according to a call result obtained by calling the first cache cluster; and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request.
In this embodiment of the present invention, the status determining module 702 is further configured to: calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length; when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state; when the first cache cluster does not return a response within a first preset time, increasing the calling failure times, and determining whether the calling failure times are greater than a preset calling threshold value: if not, returning to execute the calling of the first cache cluster; if so, determining that the first cache cluster is in an abnormal state.
In an embodiment of the present invention, when the number of the date data query requests is multiple, the state determination module 702 is further configured to: for each date data query request, performing: calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length; when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state; when the first cache cluster does not return a response within a first preset time length, increasing the calling failure times corresponding to the date data query request in an incremental manner, and determining whether the calling failure times are greater than a preset calling threshold value; if not, returning to execute the calling of the first cache cluster; if yes, marking the date data query request as query failure, and increasing the query failure times; and determining whether the query failure times are greater than a preset query threshold value, and if so, determining that the first cache cluster is in an abnormal state.
In this embodiment of the present invention, when it is determined that the first cache cluster is in the abnormal state, the response module 703 is further configured to: and calling the second cache cluster for one or more date data query requests marked as query failures to respond to the one or more date data query requests with query failures.
In this embodiment of the present invention, when it is determined that the first cache cluster is in the abnormal state, after the second cache cluster is called to respond to the date data query request, the responding module 703 is further configured to: starting a detection thread, and setting a second preset time length for the detection thread so that the detection thread determines whether the first cache cluster is in a normal state or not every second preset time length; if so, stopping calling the second cache cluster, and calling the first cache cluster again.
In this embodiment of the present invention, the response module 703 is further configured to: calling a second cache cluster, and determining whether the second cache cluster is in a normal state; if not, the date data query request is responded by the query abnormal information, and the abnormal reminding information is sent to the front-end page.
In the embodiment of the present invention, the date data query request includes: an identifier of the requesting end; the response module 703 is further configured to: determining whether the calling result is null; if yes, responding the date data query request by using the null value, and setting a third preset time length corresponding to the request end according to the identifier so as to respond to the received other date data query requests including the identifier by using the null value within the third preset time length.
In the embodiment of the present invention, the date data query request further includes: first date data existing at a request end; the response module 703 is further configured to: when the calling result is not empty, determining whether the calling result is the same as the first date data; if yes, responding to the date data query request with the first date data; if not, the date data query request is responded with the calling result.
In the embodiment of the invention, the date data query request comprises an identifier of a request end, and the calling result comprises a date change field which is used for indicating the working stage of the first cache cluster; the response module 703 is further configured to: determining the working stage of the first cache cluster according to the date change field; and responding to the date data query request according to the working phase of the first cache cluster.
In this embodiment of the present invention, the response module 703 is further configured to: and when the first cache cluster is determined to be in the date change completion stage according to the date change field, responding the date data query request by using a null value, and setting a third preset time length corresponding to the request end according to the identifier so as to respond the received other date data query requests including the identifier by using the null value within the third preset time length.
In the embodiment of the present invention, the date data query request further includes: first date data existing at a request end; the response module 703 is further configured to: and responding the date data query request with the first date data when the first cache cluster is determined to be in the date change preparation stage according to the date change field.
In this embodiment of the present invention, the response module 703 is further configured to: and when the first cache cluster is determined to be in the date change execution stage according to the date change field, responding to the date data query request by using the second date data in the calling result.
In this embodiment of the present invention, when it is determined that the first cache cluster is in the date change execution stage according to the date change field, the response module 703 is further configured to: obtaining third date data from the persistent database; determining whether the second date data is consistent with the third date data; if not, circularly executing the following steps until the modification is successful or the modification times are larger than a preset modification threshold value: modifying the second date data according to the third date data; determining whether the modification is successful, if not, increasing the modification times, and judging whether the modification times are greater than a preset modification threshold value; if not, the execution returns to modify the second date data according to the third date data.
In this embodiment of the present invention, the response module 703 is further configured to: and when the modification times are larger than a preset modification threshold value, sending date change failure information to the front-end page.
In this embodiment of the present invention, the response module 703 is further configured to: and calling the second cache cluster according to the preset address of the second cache cluster so as to respond to the date data query request.
According to the date data query device provided by the embodiment of the invention, after two cache clusters are set for the database, after a date data query request is received, the first cache cluster is called firstly to determine whether the first cache cluster is in a normal state, and if the first cache cluster is determined to be in the normal state, the date data query request is responded according to a calling result obtained by calling the first cache cluster; if the first cache cluster is determined to be in an abnormal state, the second cache cluster is called to respond to the date data query request, so that the date data query efficiency is improved, the processing pressure of the database is relieved, and when the first cache cluster has faults such as network unsmooth and the like, the second cache cluster can be called instead, and the normal operation of transaction service is guaranteed.
Fig. 8 shows an exemplary system architecture 800 of a date data query method or a date data query apparatus to which an embodiment of the present invention can be applied.
As shown in fig. 8, the system architecture 800 may include terminal devices 801, 802, 803, a network 804 and an electronic device 805. The network 804 serves as a medium for providing communication links between the terminal devices 801, 802, 803 and the electronic device 805. Network 804 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 801, 802, 803 to interact with an electronic device 805 over a network 804 to receive or send messages or the like. Various communication client applications, such as shopping applications, instant messaging tools, mailbox clients, social platform software, etc., may be installed on the terminal devices 801, 802, 803.
The terminal devices 801, 802, 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The electronic device 805 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 801, 802, 803. The background management server may analyze and otherwise process data such as the received date data query request, and feed back a processing result (for example, date data information) to the terminal device.
It should be noted that, a date data query method provided by the embodiment of the present invention is generally executed by the electronic device 805, and accordingly, a date data query apparatus is generally disposed in the electronic device 805.
It should be understood that the number of terminal devices, networks, and electronic devices in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and electronic devices, as desired for implementation.
Referring now to FIG. 9, shown is a block diagram of a computer system 900 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU)901 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 901.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a receiving module, a state determination module, and a response module. The names of these modules do not constitute a limitation to the module itself in some cases, and for example, the request receiving module may also be described as a "module for receiving a date data query request".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: receiving a date data query request; calling the first cache cluster, and determining whether the first cache cluster is in a normal state; when the first cache cluster is determined to be in a normal state, responding to a date data query request according to a calling result obtained by calling the first cache cluster; and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request.
According to the technical scheme of the embodiment of the invention, two cache clusters can be set for the database, after the date data query request is received, the first cache cluster is called firstly to determine whether the first cache cluster is in a normal state, and if the first cache cluster is determined to be in the normal state, the date data query request is responded according to a calling result obtained by calling the first cache cluster; if the first cache cluster is determined to be in an abnormal state, the second cache cluster is called to respond to the date data query request, so that the date data query efficiency is improved, the processing pressure of the database is relieved, and when the first cache cluster has faults such as network unsmooth and the like, the second cache cluster can be called instead, and the normal operation of transaction service is guaranteed.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (18)

1. A date data query method, comprising:
receiving a date data query request;
calling a first cache cluster, and determining whether the first cache cluster is in a normal state;
when the first cache cluster is determined to be in a normal state, responding to the date data query request according to a calling result obtained by calling the first cache cluster;
and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request.
2. The method of claim 1, wherein invoking the first cache cluster to determine whether the first cache cluster is in a normal state comprises:
calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length;
when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state;
when the first cache cluster does not return a response within a first preset time, increasing the calling failure times, and determining whether the calling failure times are greater than a preset calling threshold value: if not, returning to execute the calling of the first cache cluster; if so, determining that the first cache cluster is in an abnormal state.
3. The method of claim 1, wherein when the date data query request is multiple, the invoking the first cache cluster and determining whether the first cache cluster is in a normal state comprises:
for each date data query request, performing:
calling the first cache cluster, and determining whether the first cache cluster returns a response within a first preset time length;
when the first cache cluster returns a response within a first preset time, determining that the first cache cluster is in a normal state;
when the first cache cluster does not return a response within a first preset time length, increasing the calling failure times corresponding to the date data query request in an incremental manner, and determining whether the calling failure times are greater than a preset calling threshold value; if not, returning to execute the calling of the first cache cluster; if yes, marking the date data query request as query failure, and increasing the number of query failure times;
and determining whether the query failure times are greater than a preset query threshold value, and if so, determining that the first cache cluster is in an abnormal state.
4. The method of claim 3, wherein when it is determined that the first cache cluster is in an abnormal state, the invoking a second cache cluster in response to the date data query request comprises:
and calling the second cache cluster for one or more date data query requests marked as query failures to respond to the date data query requests marked as query failures.
5. The method of claim 1, wherein when it is determined that the first cache cluster is in an abnormal state, after the invoking a second cache cluster in response to the date data query request, further comprising:
starting a detection thread, and setting a second preset time length for the detection thread, so that the detection thread determines whether the first cache cluster is in a normal state or not every second preset time length;
if so, stopping calling the second cache cluster, and calling the first cache cluster again.
6. The method of claim 1, wherein invoking the second cache cluster in response to the date data query request comprises:
calling the second cache cluster, and determining whether the second cache cluster is in a normal state;
if not, responding the date data query request by querying abnormal information, and sending abnormal reminding information to the front-end page.
7. The method of claim 1, wherein the date data query request comprises: an identifier of the requesting end;
the responding the date data query request according to the calling result obtained by calling the first cache cluster comprises the following steps:
determining whether the calling result is null;
if yes, responding the date data query request by using a null value, and setting a third preset time length corresponding to the request end according to the identifier so as to respond to the received other date data query requests including the identifier by using the null value within the third preset time length.
8. The method of claim 7, wherein the date data query request further comprises: the first date data existing in the request terminal;
when the calling result is not empty, determining whether the calling result is the same as the first date data;
if yes, responding to the date data query request by the first date data;
and if not, responding the date data query request with the calling result.
9. The method according to claim 1, wherein the date data query request includes an identifier of a request end, and the call result includes a date change field, and the date change field is used to indicate a working phase of the first cache cluster;
the responding the date data query request according to the calling result obtained by calling the first cache cluster comprises the following steps:
determining the working stage of the first cache cluster according to the date change field;
and responding to the date data query request according to the working phase of the first cache cluster.
10. The method of claim 9,
and when the first cache cluster is determined to be in a date change completion stage according to the date change field, responding the date data query request by using a null value, and setting a third preset time length corresponding to the request end according to the identifier so as to respond the received other date data query requests including the identifier by using the null value within the third preset time length.
11. The method of claim 9, wherein the date data query request further comprises: the first date data existing in the request terminal;
and when the first cache cluster is determined to be in a date change preparation stage according to the date change field, responding the date data query request by the first date data.
12. The method of claim 9,
and when the first cache cluster is determined to be in a date change execution stage according to the date change field, responding the date data query request by using the second date data in the calling result.
13. The method of claim 12, wherein when determining that the first cache cluster is in a date change execution phase according to the date change field, further comprising:
obtaining third date data from the persistent database;
determining whether the second date data is consistent with the third date data;
if not, circularly executing the following steps until the modification is successful or the modification times are larger than a preset modification threshold value:
modifying the second date data according to the third date data;
determining whether the modification is successful, if not, increasing the modification times, and judging whether the modification times are greater than the preset modification threshold value;
if not, returning to execute the third date data and modifying the second date data.
14. The method of claim 13,
and when the modification times are larger than the preset modification threshold value, sending date change failure information to a front-end page.
15. The method of claim 1, wherein invoking the second cache cluster in response to the date data query request comprises:
and calling the second cache cluster according to a preset address of the second cache cluster so as to respond to the date data query request.
16. The date data inquiry device is characterized by comprising a request receiving module, a state determining module and a response module; wherein:
the request receiving module is used for receiving a date data query request;
the state determining module is used for calling a first cache cluster and determining whether the first cache cluster is in a normal state;
the response module is used for responding to the date data query request according to a calling result obtained by calling the first cache cluster when the first cache cluster is determined to be in a normal state; and when the first cache cluster is determined to be in the abnormal state, calling a second cache cluster to respond to the date data query request.
17. An electronic device for date data inquiry, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-15.
18. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-15.
CN202110338762.2A 2021-03-30 2021-03-30 Date data query method and device Active CN112948430B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110338762.2A CN112948430B (en) 2021-03-30 2021-03-30 Date data query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110338762.2A CN112948430B (en) 2021-03-30 2021-03-30 Date data query method and device

Publications (2)

Publication Number Publication Date
CN112948430A true CN112948430A (en) 2021-06-11
CN112948430B CN112948430B (en) 2022-12-13

Family

ID=76227453

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110338762.2A Active CN112948430B (en) 2021-03-30 2021-03-30 Date data query method and device

Country Status (1)

Country Link
CN (1) CN112948430B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528373A (en) * 2014-10-21 2016-04-27 阿里巴巴集团控股有限公司 Database fault processing method, device, system and server
CN108959940A (en) * 2018-06-19 2018-12-07 杭州朗和科技有限公司 Data access control method, medium, device and calculating equipment
CN109189813A (en) * 2018-08-22 2019-01-11 中国建设银行股份有限公司 A kind of data sharing method and device
CN110928904A (en) * 2019-10-31 2020-03-27 北京浪潮数据技术有限公司 Data query method and device and related components
CN111737230A (en) * 2020-06-23 2020-10-02 北京奇艺世纪科技有限公司 Data verification method and device, electronic equipment and readable storage medium
CN111767297A (en) * 2020-06-30 2020-10-13 平安国际智慧城市科技股份有限公司 Big data processing method, device, equipment and medium
CN111949725A (en) * 2020-06-07 2020-11-17 中信银行股份有限公司 Data query method and device, electronic equipment and computer readable storage medium
CN111949402A (en) * 2020-08-05 2020-11-17 中国建设银行股份有限公司 Database request processing method and device, computer equipment and storage medium
CN112231148A (en) * 2020-10-23 2021-01-15 北京思特奇信息技术股份有限公司 Distributed cache data offline transmission method and device and readable storage medium
KR102202792B1 (en) * 2020-08-06 2021-01-15 (주)시큐레이어 Method and device for performing multi-caching on data sources of same or different types by using cluster-based processing system
CN112363865A (en) * 2020-10-19 2021-02-12 深圳云天励飞技术股份有限公司 Database fault recovery method and device and face image search system

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528373A (en) * 2014-10-21 2016-04-27 阿里巴巴集团控股有限公司 Database fault processing method, device, system and server
CN108959940A (en) * 2018-06-19 2018-12-07 杭州朗和科技有限公司 Data access control method, medium, device and calculating equipment
CN109189813A (en) * 2018-08-22 2019-01-11 中国建设银行股份有限公司 A kind of data sharing method and device
CN110928904A (en) * 2019-10-31 2020-03-27 北京浪潮数据技术有限公司 Data query method and device and related components
CN111949725A (en) * 2020-06-07 2020-11-17 中信银行股份有限公司 Data query method and device, electronic equipment and computer readable storage medium
CN111737230A (en) * 2020-06-23 2020-10-02 北京奇艺世纪科技有限公司 Data verification method and device, electronic equipment and readable storage medium
CN111767297A (en) * 2020-06-30 2020-10-13 平安国际智慧城市科技股份有限公司 Big data processing method, device, equipment and medium
CN111949402A (en) * 2020-08-05 2020-11-17 中国建设银行股份有限公司 Database request processing method and device, computer equipment and storage medium
KR102202792B1 (en) * 2020-08-06 2021-01-15 (주)시큐레이어 Method and device for performing multi-caching on data sources of same or different types by using cluster-based processing system
CN112363865A (en) * 2020-10-19 2021-02-12 深圳云天励飞技术股份有限公司 Database fault recovery method and device and face image search system
CN112231148A (en) * 2020-10-23 2021-01-15 北京思特奇信息技术股份有限公司 Distributed cache data offline transmission method and device and readable storage medium

Also Published As

Publication number Publication date
CN112948430B (en) 2022-12-13

Similar Documents

Publication Publication Date Title
CN111277639B (en) Method and device for maintaining data consistency
CN108897854B (en) Monitoring method and device for overtime task
CN111460129B (en) Method, device, electronic equipment and storage medium for generating identification
CN110928912A (en) Method and device for generating unique identifier
CN111881329A (en) Account balance management method and system
CN111782502A (en) Automatic testing method and device
CN113282589A (en) Data acquisition method and device
CN113760522A (en) Task processing method and device
CN112948138A (en) Method and device for processing message
CN112948430B (en) Date data query method and device
CN114756173A (en) Method, system, device and computer readable medium for file merging
CN114706774A (en) Interface test method, device, equipment and storage medium
CN113760487B (en) Service processing method and device
CN113726885A (en) Method and device for adjusting flow quota
CN113779122A (en) Method and apparatus for exporting data
CN113760693A (en) Method and apparatus for local debugging of microservice systems
CN112671877A (en) Data processing method and device
CN113556370A (en) Service calling method and device
CN111210349A (en) Virtual asset transfer hosting method and device, electronic equipment and storage medium
CN112688982A (en) User request processing method and device
CN113766437B (en) Short message sending method and device
CN110825610A (en) Method and device for providing test data
CN114979187B (en) Data processing method and device
CN113760179A (en) Data processing method and device
CN115033600A (en) Data processing method and data processing device

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
TA01 Transfer of patent application right

Effective date of registration: 20220930

Address after: 25 Financial Street, Xicheng District, Beijing 100033

Applicant after: CHINA CONSTRUCTION BANK Corp.

Address before: 12 / F, 15 / F, No. 99, Yincheng Road, Shanghai pilot Free Trade Zone, 200120

Applicant before: Jianxin Financial Science and Technology Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant