Application switching method and device, computer equipment and storage medium

By obtaining Redis cluster status information and updating the connection status of the application, the problem of lower performance and availability of upper-level applications when the Redis cluster is unavailable is solved, efficient data query switching is achieved, and high performance and high availability of applications are improved.

CN120216129APending Publication Date: 2025-06-27PEOPLE'S INSURANCE COMPANY OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510286111.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The prior art cannot effectively switch the data query path of the upper layer application when the Redis cluster is unavailable, resulting in a degradation of application performance and availability.

Method used

By obtaining the status information of the Redis cluster, the connection status of the Redis cluster and the application is updated. When the application receives a query request, if the Redis cluster is not available, the target data is queried from the preset database; if it is available, the target data is queried from the Redis cluster.

Benefits of technology

It realizes a quick judgment on whether the Redis cluster is available and takes corresponding measures to improve the high performance and high availability of upper-level applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216129A_ABST
    Figure CN120216129A_ABST
Patent Text Reader

Abstract

The invention provides an application switching method and device, computer equipment and a storage medium. The method comprises the steps of obtaining state information of a Redis cluster; updating the connection state of the Redis cluster and the application program according to the state information; when the application program receives a query request, if the connection state indicates that the Redis cluster and the application program are in a disconnected state, querying target data from a preset database based on the query request; and when the application program receives a query request, if the connection state indicates that the Redis cluster and the application program are in a connection state, querying target data from the Redis cluster based on the query request. By implementing the method disclosed by the invention, whether the Redis cluster is available or not can be quickly judged, and corresponding processing measures can be taken, so that the high performance and high availability of an upper-layer application are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of distributed caching technologies, and particularly relates to an application switching method, apparatus, computer device, and storage medium. Background Art

[0002] The Redis cluster mode is considered a highly available solution. When one or more nodes in the cluster are unavailable, the cluster can automatically perform master-slave switching. After the switching is completed, the Redis cluster remains available.

[0003] In related technologies, solutions such as using RedisTemplate to "ping" all nodes of the cluster, connecting to the cluster with Jedis, or Redis health checks are usually adopted.

[0004] In this way, only the health status of a certain node or the cluster in the cluster is monitored, and the switching solution of the upper-layer application when the Redis cluster is completely unavailable is not considered. Summary of the Invention

[0005] The present disclosure aims to at least solve one of the technical problems in the related technologies to some extent.

[0006] To this end, the purpose of the present disclosure is to propose an application switching method, apparatus, computer device, and storage medium, which can quickly determine whether the Redis cluster is available and take corresponding processing measures, thereby effectively improving the high performance and high availability of the upper-layer application.

[0007] To achieve the above object, the application switching method proposed in the first aspect embodiment of the present disclosure includes:

[0008] Obtain the status information of the Redis cluster;

[0009] Update the connection status between the Redis cluster and the application program according to the status information;

[0010] When the application program receives a query request, if the connection status indicates that the Redis cluster is disconnected from the application program, query the target data from a preset database based on the query request;

[0011] When the application program receives the query request, if the connection status indicates that the Redis cluster is connected to the application program, query the target data from the Redis cluster based on the query request.

[0012] To achieve the above object, the application switching apparatus proposed in the second aspect embodiment of the present disclosure includes:

[0013] An obtaining module, configured to obtain the status information of the Redis cluster;

[0014] An update module, configured to update the connection status between the Redis cluster and the application according to the status information;

[0015] A first query module, configured to, when the application receives a query request, if the connection status indicates that the Redis cluster is disconnected from the application, query target data from a preset database based on the query request;

[0016] A second query module, configured to, when the application receives the query request, if the connection status indicates that the Redis cluster is connected to the application, query target data from the Redis cluster based on the query request.

[0017] The computer device provided in the third aspect embodiment of the present disclosure includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the application switching method proposed in the first aspect embodiment of the present disclosure.

[0018] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the application switching method proposed in the first aspect embodiment of the present disclosure.

[0019] The fifth aspect embodiment of the present disclosure proposes a computer program product. When the instructions in the computer program product are executed by a processor, they execute the application switching method proposed in the first aspect embodiment of the present disclosure.

[0020] The application switching method, device, computer device, and storage medium provided by the present disclosure obtain the status information of the Redis cluster; update the connection status between the Redis cluster and the application according to the status information; when the application receives a query request, if the connection status indicates that the Redis cluster is disconnected from the application, query target data from a preset database based on the query request; when the application receives a query request, if the connection status indicates that the Redis cluster is connected to the application, query target data from the Redis cluster based on the query request. Thereby, it can quickly determine whether the Redis cluster is available and take corresponding processing measures, effectively improving the high performance and high availability of the upper-layer application.

[0021] The additional aspects and advantages of the present disclosure will be partially given in the following description, partially become apparent from the following description, or be understood through the practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The above and / or additional aspects and advantages of the present disclosure will become apparent and be readily understood from the following description of embodiments in conjunction with the accompanying drawings, in which:

[0023] Figure 1 is a schematic flowchart of an application switching method proposed in an embodiment of the present disclosure;

[0024] Figure 2 is a schematic flowchart of an application switching method proposed in another embodiment of the present disclosure;

[0025] Figure 3 is a flowchart of a user request according to the present disclosure;

[0026] Figure 4 is a schematic flowchart of a cluster state judgment logic according to the present disclosure;

[0027] Figure 5 is a schematic structural diagram of an application switching device proposed in an embodiment of the present disclosure;

[0028] Figure 6 shows a block diagram of an exemplary computer device suitable for implementing the embodiments of the present disclosure. Detailed Embodiments

[0029] Embodiments of the present disclosure will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary only for explaining the present disclosure and should not be construed as limiting the present disclosure. On the contrary, the embodiments of the present disclosure include all variations, modifications, and equivalents falling within the spirit and scope of the appended claims.

[0030] Figure 1 is a schematic flowchart of an application switching method proposed in an embodiment of the present disclosure.

[0031] It should be noted that the execution subject of the application switching method in this embodiment is an application switching device, which can be implemented in software and / or hardware, and the device can be configured in a computer device. The computer device can include, but is not limited to, a terminal, a server, etc. For example, the terminal can be a mobile phone, a personal digital assistant, etc.

[0032] As Figure 1 shown, the application switching method includes:

[0033] S101: Obtain the status information of the Redis cluster.

[0034] The status information can be used to indicate whether the corresponding Redis cluster is available.

[0035] In the embodiments of the present disclosure, when obtaining the status information of the Redis cluster, it may be based on a third-party cluster status detection device, or it may also be based on any other possible method, which is not limited herein.

[0036] In the embodiments of the present disclosure, when obtaining the status information of the Redis cluster, it can provide a reliable operation basis for subsequent updating the connection status between the Redis cluster and the application program.

[0037] S102: Update the connection status between the Redis cluster and the application program according to the status information.

[0038] Among them, the application program refers to the upper-layer application served by the above Redis cluster.

[0039] In the embodiments of the present disclosure, the type and quantity of the application program are not limited.

[0040] Optionally, in some embodiments, when updating the connection status between the Redis cluster and the application program according to the status information, when the status information indicates that the Redis cluster is in an available state, the connection status between the Redis cluster and the application program is updated to the connected state; when the status information indicates that the Redis cluster is in an unavailable state, the connection status between the Redis cluster and the application program is updated to the disconnected state. Thus, the rapid switching of the connection status between the Redis cluster and the application program can be realized based on the status information of the Redis cluster, thereby effectively improving the working performance of the application program.

[0041] S103: When the application program receives a query request, if the connection status indicates that the Redis cluster and the application program are in a disconnected state, query the target data from the preset database based on the query request.

[0042] Among them, the query request may refer to a request for a user to query specified data.

[0043] Among them, the target data may refer to the data indicated by the query request.

[0044] That is to say, in the embodiments of the present disclosure, when the connection status indicates that the Redis cluster and the application program are in a disconnected state, the target data is queried from the preset database based on the query request, so as to ensure that the application program can query the target data from the preset database when it is in a disconnected state from the Redis cluster, thereby ensuring the robustness of the application program data query process.

[0045] S104: When the application program receives a query request, if the connection status indicates that the Redis cluster and the application program are in a connected state, query the target data from the Redis cluster based on the query request.

[0046] That is to say, in the embodiments of the present disclosure, when the connection status indicates that the Redis cluster and the application are in a connected state, target data can be queried from the Redis cluster based on a query request.

[0047] Optionally, in some embodiments, if the target data is not queried from the Redis cluster, the target data is queried from a preset database based on the query request, and the target data is written into the Redis cluster. Thus, when the target data is not queried from the Redis cluster, the target data can be promptly queried from the preset database based on the query request to effectively improve the robustness of the application data query process, and then the target data is written into the Redis cluster to facilitate subsequent querying of the target data from the Redis cluster.

[0048] In this embodiment, by obtaining the status information of the Redis cluster; updating the connection status between the Redis cluster and the application according to the status information; when the application receives a query request, if the connection status indicates that the Redis cluster and the application are in a disconnected state, the target data is queried from a preset database based on the query request; when the application receives a query request, if the connection status indicates that the Redis cluster and the application are in a connected state, the target data is queried from the Redis cluster. Thus, it is possible to quickly determine whether the Redis cluster is available and take corresponding processing measures, thereby effectively improving the high performance and high availability of the upper-layer application.

[0049] Figure 2 It is a schematic flowchart of an application switching method proposed in another embodiment of the present disclosure.

[0050] As Figure 2 shown, the application switching method includes:

[0051] S201: Obtain the configuration information of the Redis cluster.

[0052] Among them, the configuration information can be used to indicate the relevant configuration of the Redis cluster.

[0053] In the embodiments of the present disclosure, when obtaining the configuration information of the Redis cluster, reliable reference information can be provided for subsequent determination of the node status information and working mode of the Redis cluster.

[0054] S202: Determine the node status information and working mode of the Redis cluster according to the configuration information, where the working mode is used to indicate whether read and write operations are allowed when there are slots not covered by any node in the Redis cluster.

[0055] Among them, the node status information can be used to indicate the relevant status of each node in the Redis cluster.

[0056] In the embodiments of the present disclosure, when determining the node status information and working mode of the Redis cluster according to the configuration information, reliable reference information can be provided for subsequent determination of the status information of the Redis cluster.

[0057] S203: Determine the status information of the Redis cluster according to the node status information and the working mode.

[0058] In the embodiments of the present disclosure, when determining the status information of the Redis cluster according to the node status information and the working mode, the node status information and the working mode can be input into a pre-trained machine learning model to determine the status information of the Redis cluster. Alternatively, the status information of the Redis cluster can also be determined based on any other possible method according to the node status information and the working mode, and this is not limited.

[0059] Optionally, in some embodiments, when determining the status information of the Redis cluster according to the node status information and the working mode, if the working mode is the first mode, the number of master nodes and the number of normal master nodes in the cluster can be determined based on the node status information; when the number of master nodes is equal to the number of normal master nodes in the cluster, it is determined that the Redis cluster is in an available state; when the number of master nodes is less than the number of normal master nodes in the cluster, it is determined that the Redis cluster is in an unavailable state. Thus, when the working mode of the Redis cluster is the first mode, it is possible to quickly determine whether the Redis cluster is available based on the comparison result of the number of master nodes and the number of normal master nodes in the cluster.

[0060] The first mode refers to a working mode in which the Redis cluster does not allow read and write operations when there are slots not covered by any node.

[0061] The number of master nodes refers to the number of master nodes dynamically obtained according to the actual situation. The number of normal master nodes in the cluster refers to the number of master nodes in the Redis cluster that are in a normal running state.

[0062] Optionally, in some embodiments, when determining the status information of the Redis cluster according to the node status information and the working mode, if the working mode is the second mode, the number of master nodes and the number of normal master nodes in the cluster can be determined based on the node status information; when the number of master nodes is greater than or equal to half of the number of normal master nodes in the cluster, it is determined that the Redis cluster is in an available state; when the number of master nodes is less than half of the number of normal master nodes in the cluster, it is determined that the Redis cluster is in an unavailable state. Thus, when the working mode of the Redis cluster is the second mode, it is possible to quickly determine whether the Redis cluster is available.

[0063] Among them, the second mode refers to the working mode in which the Redis cluster still allows read and write operations when there are slots not covered by any node.

[0064] That is to say, in the embodiments of the present disclosure, the configuration information of the Redis cluster can be obtained; according to the configuration information, the node status information and the working mode of the Redis cluster are determined, wherein the working mode is used to indicate whether read and write operations are allowed when there are slots not covered by any node in the Redis cluster; according to the node status information and the working mode, the status information of the Redis cluster is determined. Thus, the indication accuracy of the obtained status information can be ensured by combining the node status information and the working mode.

[0065] S204: Update the connection status between the Redis cluster and the application according to the status information.

[0066] S205: When the application receives a query request, if the connection status indicates that the Redis cluster is disconnected from the application, query the target data from the preset database based on the query request.

[0067] S206: When the application receives a query request, if the connection status indicates that the Redis cluster is connected to the application, query the target data from the Redis cluster based on the query request.

[0068] For the descriptions of S204 - S206, specific reference can be made to the above embodiments, which will not be elaborated here.

[0069] In this embodiment, the configuration information of the Redis cluster can be obtained; according to the configuration information, the node status information and the working mode of the Redis cluster are determined, wherein the working mode is used to indicate whether read and write operations are allowed when there are slots not covered by any node in the Redis cluster; according to the node status information and the working mode, the status information of the Redis cluster is determined. Thus, the indication accuracy of the obtained status information can be ensured by combining the node status information and the working mode.

[0070] It can be understood that in some monitoring tools, it is possible to effectively monitor whether the master - slave switch occurs in the nodes of the cluster and whether the cluster is available, but it does not involve how to ensure high performance and high availability of the upper - layer applications using the Redis cluster when the cluster is unavailable. Because when the Redis cluster is unavailable, the upper - layer application will attempt to connect to the Redis cluster every time it processes a query request until the connection times out, and then it will query the database to return the request result. Each attempt to connect to Redis takes a certain amount of time, such as the timeout is configured to 15s. In this case, the performance and availability of the application will be greatly reduced, resulting in query timeouts or even crashes.

[0071] Integrating the above embodiments, the present disclosure connects to the cluster through RedisClient, obtains node information in the cluster, and makes a comprehensive analysis based on the connection status of the master nodes in the cluster through a self-developed algorithm to determine whether the Redis cluster is available. When the cluster is available / unavailable, the Redis connection switch is quickly turned on / off. The switch for turning on / off the connection to the Redis cluster needs to be built into the application logic to avoid the application attempting to connect to an unavailable cluster, resulting in an overly long response time, or being unable to utilize the performance advantages of the Redis cache when the cluster is available, thereby ensuring the high availability of the upper-layer application.

[0072] That is to say, the present disclosure can accurately detect whether the Redis cluster is available through a self-developed algorithm. When the cluster is unavailable, the upper-layer application can immediately turn off the switch for connecting to Redis and no longer attempt to connect to the unavailable Redis cluster. When the cluster is available, the upper-layer application immediately turns on the switch for connecting to Redis, thereby ensuring that the TPS of the upper-layer application does not decrease significantly.

[0073] As Figure 3 and Figure 4 shown, Figure 3 is the user request flowchart proposed according to the present disclosure, Figure 4 is the schematic diagram of the cluster status judgment logic flow proposed according to the present disclosure, which includes the following steps:

[0074] 1. Obtain the Redis cluster configuration of the current project, including the connection information of the reids nodes, the password, and the configuration information of the number of master nodes M and the number of slave nodes N.

[0075] 2. Select a normal node through the "telnet" command and connect to RedisClient.

[0076] 3. Obtain the cache cluster node information and the "cluster-require-full-coverage" configuration content (yes / no) of the cluster;

[0077] 3.1. If the result is "yes", determine whether the cluster is available based on the relationship between the dynamically obtained number of master nodes (N1) and the number of normal master nodes (N) in the cluster according to the actual situation.

[0078] 3.1.1. When N1 = N, the cluster is available;

[0079] 3.1.2. When N1 < N, the cluster is unavailable.

[0080] 3.2. If the result is "no", determine whether the cluster is available by judging the number of master nodes (N1) and half of the normal master nodes in the cluster (N / 2).

[0081] 3.2.1. When N1 >= N / 2, the cluster is available;

[0082] 3.2.2. When N1 < N / 2, the cluster is unavailable.

[0083] 4. Return the cluster status and modify the cluster status configuration.

[0084] 5. Execute this program regularly.

[0085] Figure 5 It is a schematic structural diagram of an application switching device proposed in an embodiment of the present disclosure.

[0086] As Figure 5 shown, the application switching device 50 includes:

[0087] An acquisition module 501, configured to acquire the status information of the Redis cluster;

[0088] An update module 502, configured to update the connection status between the Redis cluster and the application program according to the status information;

[0089] A first query module 503, configured to, when the application program receives a query request, if the connection status indicates that the Redis cluster and the application program are in a disconnected state, query target data from a preset database based on the query request;

[0090] A second query module 504, configured to, when the application program receives a query request, if the connection status indicates that the Redis cluster and the application program are in a connected state, query target data from the Redis cluster based on the query request.

[0091] It should be noted that the foregoing explanation of the application switching method also applies to the application switching device in this embodiment, and will not be elaborated here.

[0092] In this embodiment, by acquiring the status information of the Redis cluster; updating the connection status between the Redis cluster and the application program according to the status information; when the application program receives a query request, if the connection status indicates that the Redis cluster and the application program are in a disconnected state, query target data from a preset database based on the query request; when the application program receives a query request, if the connection status indicates that the Redis cluster and the application program are in a connected state, query target data from the Redis cluster based on the query request. Thus, it is possible to quickly determine whether the Redis cluster is available and take corresponding processing measures, thereby effectively improving the high performance and high availability of the upper-layer application.

[0093] Figure 6 Shows a block diagram of an exemplary computer device suitable for implementing the embodiments of the present disclosure. Figure 6The illustrated computer device 12 is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present disclosure.

[0094] As Figure 6 shown, the computer device 12 appears in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects different system components (including the system memory 28 and the processing unit 16).

[0095] The bus 18 represents one or more of several types of bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. By way of example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnection (PCI) bus.

[0096] The computer device 12 typically includes a variety of computer system-readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.

[0097] The memory 28 may include computer system-readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 34 may be used for reading and writing on a non-removable, non-volatile magnetic medium ( Figure 6 not shown, typically referred to as a "hard disk drive").

[0098] Although Figure 6Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk") and an optical disk drive for reading and writing a removable non-volatile optical disk (such as: Compact Disc Read Only Memory (hereinafter referred to as: CD-ROM), Digital Video Disc Read Only Memory (hereinafter referred to as: DVD-ROM) or other optical media) can be provided. In these cases, each drive can be connected to the bus 18 through one or more data medium interfaces. The memory 28 may include at least one program product having a set (such as at least one) of program modules configured to perform the functions of the embodiments of the present disclosure.

[0099] A program / utility 40 having a set (at least one) of program modules 42 can be stored in, for example, the memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. The implementation of a network environment may be included in each or some combination of these examples. The program modules 42 generally execute the functions and / or methods in the embodiments described in the present disclosure.

[0100] The computer device 12 can also communicate with one or more external devices 14 (such as a keyboard, a pointing device, a display 24, etc.), and can also communicate with one or more devices that enable a human body to interact with the computer device 12, and / or communicate with any device that enables the computer device 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through the input / output (I / O) interface 22. Moreover, the computer device 12 can also communicate with one or more networks (such as a Local Area Network (hereinafter referred to as: LAN), a Wide Area Network (hereinafter referred to as: WAN), and / or a public network, such as the Internet) through the network adapter 20. As shown in the figure, the network adapter 20 communicates with other modules of the computer device 12 through the bus 18. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in combination with the computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0101] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, such as implementing the application switching method mentioned in the foregoing embodiments.

[0102] To implement the above embodiments, the present disclosure also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the application switching method proposed in the foregoing embodiments of the present disclosure.

[0103] To implement the above embodiments, the present disclosure also provides a computer program product. When the instruction processor in the computer program product executes, it performs the application switching method proposed in the foregoing embodiments of the present disclosure.

[0104] After considering the specification and practicing the invention disclosed herein, those skilled in the art will readily conceive of other embodiments of the present disclosure. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and embodiments are only to be considered as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.

[0105] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.

[0106] It should be noted that in the description of the present disclosure, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present disclosure, unless otherwise specified, the meaning of "a plurality of" is two or more.

[0107] Any process or method description in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of code including one or more executable instructions for implementing a specific logical function or process. The scope of the preferred embodiments of the present disclosure includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in a reverse order according to the involved functions, rather than in the order shown or discussed. This should be understood by those skilled in the art of the embodiments of the present disclosure.

[0108] It should be understood that each part of the present disclosure can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following technologies well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0109] Those of ordinary skill in the art can understand that all or part of the steps carried out in the method of the above embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0110] In addition, in each of the various embodiments of the present disclosure, the functional units can be integrated in a processing module, or each unit can exist physically alone, or two or more units can be integrated in one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0111] The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disk, etc.

[0112] In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.

[0113] Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.

Claims

1. An application switching method, characterized in that: include: Get the status information of the Redis cluster; Update the connection status between the Redis cluster and the application according to the status information; When the application receives a query request, if the connection status indicates that the Redis cluster is disconnected from the application, querying target data from a preset database based on the query request; When the application receives the query request, if the connection status indicates that the Redis cluster is in a connected state with the application, the target data is queried from the Redis cluster based on the query request.

2. The method according to claim 1, characterized in that The obtaining of the status information of the Redis cluster includes: Obtain configuration information of the Redis cluster; Determine the node status information and the working mode of the Redis cluster according to the configuration information, wherein the working mode is used to indicate whether the Redis cluster allows read and write operations when there is a slot that is not covered by any node; The status information of the Redis cluster is determined according to the node status information and the working mode.

3. The method according to claim 2, characterized in that Determining the status information of the Redis cluster according to the node status information and the working mode includes: If the working mode is the first mode, determining the number of master nodes and the number of normal master nodes of the cluster based on the node status information; When the number of master nodes is equal to the normal number of master nodes of the cluster, determine that the Redis cluster is in an available state; When the number of the master nodes is less than the normal number of master nodes of the cluster, it is determined that the Redis cluster is in an unavailable state.

4. The method according to claim 2, characterized in that The determining the state information of the Redis cluster according to the node state information and the working mode further includes: If the working mode is the second mode, determining the number of master nodes and the number of normal master nodes of the cluster based on the node status information; When the number of the master nodes is greater than or equal to half of the normal number of master nodes of the cluster, determine that the Redis cluster is in an available state; When the number of the master nodes is less than half of the normal number of master nodes of the cluster, it is determined that the Redis cluster is in an unavailable state.

5. The method according to claim 1, characterized in that The updating of the connection status between the Redis cluster and the application according to the status information includes: When the status information indicates that the Redis cluster is in an available state, updating the connection state between the Redis cluster and the application to the connection state; When the status information indicates that the Redis cluster is in an unavailable state, the connection state between the Redis cluster and the application is updated to the disconnected state.

6. The method according to claim 1, characterized in that The method further comprises: If the target data is not found in the Redis cluster, the target data is found in the preset database based on the query request, and the target data is written into the Redis cluster.

7. An application switching device, characterized in that: include: The acquisition module is used to obtain the status information of the Redis cluster; An update module, used to update the connection status between the Redis cluster and the application according to the status information; A first query module, configured to query target data from a preset database based on the query request when the application receives a query request if the connection status indicates that the Redis cluster is disconnected from the application; The second query module is used to query target data from the Redis cluster based on the query request when the application receives the query request if the connection status indicates that the Redis cluster and the application are in a connected state.

8. A computer device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.