A redis operation control method and system, electronic equipment and medium
By automatically determining the locking status and type of Redis operation objects, the problem of difficult Redis operation control is solved, the risk of failure is reduced, and the operation and maintenance efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CTRIP TRAVEL INFORMATION TECH (SHANGHAI) CO LTD
- Filing Date
- 2022-08-09
- Publication Date
- 2026-04-28
AI Technical Summary
The existing technology makes it difficult to control Redis operations, which increases the risk of failure in the production environment.
By receiving operation instructions, the system determines the locking status of the object being operated on and automatically judges whether the operation instruction can be executed based on the operation type, including the unlocking process and the delay alarm system, thereby reducing the risk of failure.
It reduces the risk of Redis failure, improves operational efficiency, and reduces labor and time costs.
Smart Images

Figure CN115269624B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and more specifically to a control method, system, electronic device, and medium for Redis operations. Background Technology
[0002] The company's Redis (a key-value storage system) can have thousands of clusters, each containing many groups (instances). During daily Redis operations, if simultaneous access to a cluster or group, or to a cluster and any group within that cluster, is required, sporadic conflicts may occur. Such conflicts increase the risk of production environment failures. Therefore, controlling Redis operations to avoid failures caused by these issues has become a problem that needs to be solved. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to overcome the shortcomings of the existing technology in controlling Redis operations, and to provide a method, system, electronic device and medium for controlling Redis operations.
[0004] The present invention solves the above-mentioned technical problems through the following technical solution:
[0005] This invention provides a control method for Redis operations, the control method comprising:
[0006] Receive operation instructions;
[0007] The operation object and operation type are obtained according to the operation instructions, wherein the operation type is a locking operation or an unlocking operation;
[0008] Determine whether the object being operated on is in a locked state. If not, determine that the operation instruction can be executed. If so, continue to determine whether the operation type is an unlock operation. If so, determine that the operation instruction can be executed.
[0009] Preferably, if the operation type is determined to be a locking operation, then the operation instruction cannot be executed.
[0010] Preferably, the control method further includes an unlocking process after the step of further determining whether the operation type is an unlocking operation, and if so, determining that the operation instruction can be executed. The unlocking process includes:
[0011] Unlock the object being operated on;
[0012] Trigger the delayed alarm system.
[0013] Preferably, the lock type can also be obtained according to the operation instruction, wherein the lock type is a cluster lock, a map lock, or a group lock;
[0014] The step of determining whether the object being operated on is in a locked state specifically includes:
[0015] The type of the lock is determined. If the type of the lock is a cluster lock, it is determined whether the operation object has been locked by a cluster lock or a map lock. If not, it is determined that the operation object is not in a locked state. If the type of the lock is a map lock or a group lock, it is determined whether the operation object has been locked by a cluster lock, a map lock, or a group lock. If not, it is determined that the operation object is not in a locked state.
[0016] This invention provides a control system for Redis operations, the control system comprising:
[0017] The receiving module is used to receive operation commands;
[0018] The acquisition module is used to acquire the operation object and operation type according to the operation instruction, wherein the operation type is a locking operation or an unlocking operation;
[0019] The first judgment module is used to determine whether the operation object is in a locked state. If not, it is determined that the operation instruction can be executed. If so, the second judgment module is called. The second judgment module is used to further determine whether the operation type is an unlock operation. If so, it is determined that the operation instruction can be executed.
[0020] Preferably, if the operation type is determined to be a locking operation, then the operation instruction cannot be executed.
[0021] Preferably, the control system further includes an unlocking module, the unlocking module comprising:
[0022] The unlocking unit is used to unlock the object being operated on.
[0023] The delayed alarm unit is used to trigger the delayed alarm system;
[0024] If the second judgment module determines that the operation type is an unlock operation, then the second judgment module is also used to call the unlock module.
[0025] Preferably, the acquisition module is further configured to acquire the lock type according to the operation instruction, wherein the lock type is a cluster lock, a map lock, or a group lock;
[0026] The first judgment module specifically includes:
[0027] The first determination unit is used to determine the type of the lock. If the lock type is a cluster lock, the second determination unit is called. The second determination unit is used to determine whether the operation object has been locked by a cluster lock or a map lock. If not, it is determined that the operation object is not in a locked state. If the lock type is a map lock or a group lock, the third determination unit is called. The third determination unit is used to determine whether the operation object has been locked by a cluster lock, a map lock, or a group lock. If not, it is determined that the operation object is not in a locked state.
[0028] The present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the aforementioned control method for Redis operations.
[0029] The present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the aforementioned control method for Redis operations.
[0030] The positive and progressive effects of this invention are as follows: by automatically judging the state of the operation object and the operation type, this invention determines whether the operation instruction can be executed, reducing the risk of Redis failure, thereby improving the work efficiency of Redis operation and maintenance and reducing the labor and time costs of Redis operation and maintenance. Attached Figure Description
[0031] Figure 1 A flowchart of the control method for Redis operations provided in Embodiment 1 of the present invention.
[0032] Figure 2 A flowchart of the unlocking process provided for Embodiment 1 of the present invention.
[0033] Figure 3 The flowchart shows step S103 provided in Embodiment 1 of the present invention.
[0034] Figure 4 A flowchart illustrating an application example of the control method for Redis operations provided in Embodiment 1 of the present invention.
[0035] Figure 5 This is a schematic diagram of the control system module for Redis operations provided in Embodiment 2 of the present invention.
[0036] Figure 6 This is a schematic diagram of the unlocking module 5 provided in Embodiment 2 of the present invention.
[0037] Figure 7This is a schematic diagram of the first judgment module 3 provided in Embodiment 2 of the present invention.
[0038] Figure 8 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. Detailed Implementation
[0039] The present invention will be further illustrated by way of embodiments below, but the present invention is not limited to the scope of the embodiments described herein.
[0040] Example 1
[0041] This embodiment provides a method for controlling Redis operations, such as... Figure 1 As shown, the control method includes the following steps:
[0042] S101, Receive operation instructions.
[0043] S102. Obtain the operation object and operation type according to the operation instruction, wherein the operation type is a locking operation or an unlocking operation.
[0044] S103. Determine whether the object being operated on is in a locked state. If not, execute S104; if so, execute S105.
[0045] S104. Confirm that the operation instructions can be executed.
[0046] S105. Continue to determine whether the operation type is an unlock operation. If so, execute S104.
[0047] Specifically, in this embodiment, in step S105, if it is determined that the operation type is a locking operation, then it is determined that the operation instruction cannot be executed.
[0048] Specifically, in this embodiment, the control method further includes an unlocking process after step S105, such as... Figure 2 As shown, the unlocking process includes:
[0049] S1. Unlock the object being operated on.
[0050] S2, Trigger delayed alarm system.
[0051] Specifically, in this embodiment, the lock type can also be obtained according to the operation instruction, wherein the lock type is a cluster lock, a map lock, or a group lock.
[0052] Specifically, in this embodiment, such as Figure 3 As shown, step S103 specifically includes:
[0053] S1031. Determine the lock type. If the lock type is a cluster lock, execute S1032; if the lock type is a map lock or a group lock, execute S1033.
[0054] S1032. Determine whether the operation object has been locked by a cluster lock or a map lock. If not, execute S1034.
[0055] S1033. Determine whether the operation object has been locked by a cluster lock, map lock, or group lock. If not, execute S1034.
[0056] S1034. Determine that the object being operated on is not in a locked state.
[0057] The following are specific examples of applying the control method in this embodiment:
[0058] like Figure 4 As shown, after receiving the operation instruction, the operation object, operation type, and lock type are obtained according to the operation instruction.
[0059] Scenario 1: The lock type is a cluster lock, and the operation type is a locking operation.
[0060] Perform cluster lock detection on the target object to determine if the target object has been locked by a cluster lock. If the result is no, continue to perform map lock detection to determine if the target object has been locked by a map lock. If the result is still no, it is determined that the operation command can be executed.
[0061] If the determination result is that the target object has been locked by a cluster lock, then the operation command cannot be executed.
[0062] If the determination result is that the target object has been locked by a map lock, then the operation instruction cannot be executed.
[0063] Scenario 2: The lock type is a cluster lock, and the operation type is unlock operation.
[0064] The cluster lock is cleared on the target object, and a delayed alarm system is triggered to confirm that the operation command can be executed.
[0065] Scenario 3: The lock type is a group lock or a map lock, and the operation type is a locking operation.
[0066] Perform cluster lock detection on the target object to determine if the target object has been locked by a cluster lock. If the result is no, continue to perform map lock detection to determine if the target object has been locked by a map lock. If the result is still no, perform group lock detection to determine if the target object has been locked by a group lock. If the result is no, it is determined that the operation command can be executed.
[0067] If the result indicates that the cluster lock has been acquired, then the operation command cannot be executed.
[0068] If the determination result is that the target object has been locked by a map lock, then the operation instruction cannot be executed.
[0069] If the determination result is that the target object has been locked by a group lock, then the operation instruction cannot be executed.
[0070] Scenario 4: The lock type is a group lock or a map lock, and the operation type is an unlock operation.
[0071] Perform group lock cleanup and map lock cleanup on the target object, and trigger a delayed alarm system to confirm that the operation command can be executed.
[0072] This embodiment provides a control method for Redis operations. By automatically judging the status of the operation object and the operation type, it determines whether the operation command can be executed, reducing the risk of Redis failure. At the same time, it is associated with the delay alarm system to filter alarms caused by normal Redis operations, thereby improving the work efficiency of Redis operation and maintenance and reducing the labor and time costs of Redis operation and maintenance.
[0073] Example 2
[0074] This embodiment provides a control system for Redis operations, such as... Figure 5 As shown, the control system includes a receiving module 1, an acquisition module 2, a first judgment module 3, and a second judgment module 4.
[0075] Receiver module 1 is used to receive operation instructions.
[0076] The acquisition module 2 is used to acquire the operation object and operation type according to the operation instruction, wherein the operation type is a locking operation or an unlocking operation.
[0077] The first judgment module 3 is used to determine whether the object being operated on is in a locked state. If not, it is determined that the operation instruction can be executed. If so, the second judgment module 4 is called. The second judgment module 4 is used to further determine whether the operation type is an unlock operation. If so, it is determined that the operation instruction can be executed.
[0078] Specifically, in this embodiment, if the second judgment module 4 determines that the operation type is a locking operation, then it is determined that the operation instruction cannot be executed.
[0079] Specifically, in this embodiment, the control system further includes an unlocking module 5, such as... Figure 6 As shown, the unlocking module 5 includes an unlocking unit 51 and a delay alarm unit 52.
[0080] The unlocking unit 51 is used to unlock the object being operated on.
[0081] The delayed alarm unit 52 is used to trigger the delayed alarm system.
[0082] If the second judgment module 4 determines that the operation type is an unlock operation, then the second judgment module 4 is also used to call the unlock module 5.
[0083] The delayed alarm unit 52 is used to trigger the delayed alarm system.
[0084] Specifically, in this embodiment, the acquisition module 2 is further configured to acquire the lock type according to the operation instruction, wherein the lock type is a cluster lock, a map lock, or a group lock;
[0085] Specifically, in this embodiment, such as Figure 7 As shown, the first judgment module 3 specifically includes a first judgment unit 31, a second judgment unit 32, and a third judgment unit 33.
[0086] The first judgment unit 31 is used to determine the type of lock. If the lock type is a cluster lock, the second judgment unit 32 is called. The second judgment unit 32 is used to determine whether the operation object has been locked by a cluster lock or a map lock. If not, it is determined that the operation object is not in a locked state. If the lock type is a map lock or a group lock, the third judgment unit 33 is called. The third judgment unit 33 is used to determine whether the operation object has been locked by a cluster lock, a map lock, or a group lock. If not, it is determined that the operation object is not in a locked state.
[0087] This embodiment provides a control system for Redis operations. By automatically judging the status of the operation object and the operation type, it determines whether the operation command can be executed, reducing the risk of Redis failure. At the same time, it is associated with a delay alarm system to filter alarms caused by normal Redis operations, thereby improving the efficiency of Redis operation and maintenance and reducing the labor and time costs of Redis operation and maintenance.
[0088] Example 3
[0089] Figure 8This is a schematic diagram of an electronic device provided in Embodiment 3 of the present invention. It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the control method for the Redis operation described in Embodiment 1 above. Figure 8 The electronic device 30 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0090] The electronic device 30 may be in the form of a general-purpose computing device, such as a server device. The components of the electronic device 30 may include, but are not limited to: at least one processor 31, at least one memory 32, and a bus 33 connecting different system components (including memory 32 and processor 31).
[0091] Bus 33 includes a data bus, an address bus, and a control bus.
[0092] The memory 32 may include volatile memory, such as random access memory (RAM) 321 and / or cache memory 322, and may further include read-only memory (ROM) 323.
[0093] The memory 32 may also include a program / utility 325 having a set (at least one) of program modules 324, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0094] The processor 31 executes various functional applications and data processing by running computer programs stored in the memory 32, such as the control method for Redis operations in Embodiment 1 of the present invention.
[0095] Electronic device 30 can also communicate with one or more external devices 34 (e.g., keyboard, pointing device, etc.). This communication can be performed via input / output (I / O) interface 35. Furthermore, the model-generated device 30 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public network, such as the Internet) via network adapter 36. As shown, network adapter 36 communicates with other modules of the model-generated device 30 via bus 33. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the model-generated device 30, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems.
[0096] It should be noted that although several units / modules or sub-units / modules of the electronic device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.
[0097] Example 4
[0098] The present invention also provides a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the control method for Redis operations of the aforementioned embodiment 1.
[0099] The readable storage medium may be more specifically adopted, including but not limited to: portable disk, hard disk, random access memory, read-only memory, erasable programmable read-only memory, optical storage device, magnetic storage device, or any suitable combination thereof.
[0100] In a possible implementation, the present invention can also be implemented as a program product comprising program code, which, when the program product is run on a terminal device, is used to cause the terminal device to execute a control method for implementing the Redis operation of Embodiment 1.
[0101] The program code for executing the present invention can be written in any combination of one or more programming languages. The program code can be executed entirely on the user device, partially on the user device, as a standalone software package, partially on the user device and partially on a remote device, or entirely on a remote device.
[0102] While specific embodiments of the present invention have been described above, those skilled in the art should understand that these are merely illustrative examples, and the scope of protection of the present invention is defined by the appended claims. Those skilled in the art can make various changes or modifications to these embodiments without departing from the principles and essence of the present invention, but all such changes and modifications fall within the scope of protection of the present invention.
Claims
1. A method for controlling Redis operations, characterized in that, The control method includes: Receive operation instructions; The operation object and operation type are obtained according to the operation instructions, wherein the operation type is a locking operation or an unlocking operation; Determine whether the object being operated on is in a locked state. If not, determine that the operation instruction can be executed. If yes, continue to determine whether the operation type is an unlock operation. If yes, determine that the operation instruction can be executed. The operation instructions can also be used to obtain the lock type, wherein the lock type is a cluster lock, a map lock, or a group lock; The step of determining whether the object being operated on is in a locked state specifically includes: Determine the type of the lock. If the lock type is a cluster lock, determine whether the operation object has been locked by a cluster lock or a map lock. If not, determine that the operation object is not in a locked state. If the lock type is a map lock or a group lock, determine whether the operation object has been locked by a cluster lock, a map lock, or a group lock. If not, determine that the operation object is not in a locked state. If the operation type is determined to be a locking operation, then the operation instruction cannot be executed.
2. The control method for Redis operations as described in claim 1, characterized in that, The control method further includes an unlocking process after the step of further determining whether the operation type is an unlocking operation, and if so, determining that the operation instruction can be executed. The unlocking process includes: Unlock the object being operated on; Trigger the delayed alarm system.
3. A control system for Redis operations, characterized in that, The control system includes: The receiving module is used to receive operation commands; The acquisition module is used to acquire the operation object and operation type according to the operation instruction, wherein the operation type is a locking operation or an unlocking operation; The first judgment module is used to determine whether the operation object is in a locked state. If not, it is determined that the operation instruction can be executed. If yes, the second judgment module is called. The second judgment module is used to further determine whether the operation type is an unlock operation. If yes, it is determined that the operation instruction can be executed. The acquisition module is further configured to acquire the lock type according to the operation instruction, wherein the lock type is a cluster lock, a map lock, or a group lock; The first judgment module specifically includes: The first determination unit is used to determine the type of the lock. If the lock type is a cluster lock, the second determination unit is called. The second determination unit is used to determine whether the operation object has been locked by a cluster lock or a map lock. If not, it is determined that the operation object is not in a locked state. If the lock type is a map lock or a group lock, the third determination unit is called. The third determination unit is used to determine whether the operation object has been locked by a cluster lock, a map lock, or a group lock. If not, it is determined that the operation object is not in a locked state. If the second determination module determines that the operation type is a locking operation, then it determines that the operation instruction cannot be executed.
4. The control system for Redis operations as described in claim 3, characterized in that, The control system further includes an unlocking module, which comprises: The unlocking unit is used to unlock the object being operated on. Delayed alarm unit, used to trigger delayed alarm system; If the second judgment module determines that the operation type is an unlock operation, then the second judgment module is also used to call the unlock module.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the control method for Redis operations as described in claim 1 or 2.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the control method for Redis operations as described in claim 1 or 2.
Citation Information
Patent Citations
Database operation control method and device, computer equipment and storage medium
CN109857745A
Data access processing method, system and device and storage medium
CN109947866A