Business processing method and device, computer device and storage medium
By generating and determining Redis request identifiers through AOP interceptors, Redis cache breakdown is avoided, the problem of database load surges in high-frequency call scenarios is solved, and more stable Redis access is achieved.
Patent Information
- Application Number
- CN202511374354.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2045-09-25
AI Technical Summary
In high-frequency call scenarios, Redis cache breakdown issues can cause a surge in database load, potentially triggering a cascading failure effect.
The operation method of setting anti-duplicate annotation flags is intercepted by AOP interceptor, the target request identifier is generated, and it is checked whether the identifier exists in the Redis server. If it exists, the request is rejected; if it does not exist, the identifier is written and an expiration time is set, the business request is allowed and the operation is executed.
This avoids multiple identical business requests accessing the Redis server within a short period of time, solves the cache breakdown problem in high-frequency call scenarios, and reduces database load.
Smart Images

Figure CN120915846B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to business processing methods, apparatus, computer equipment and storage media. Background Technology
[0002] With the widespread adoption of microservice architectures, Redis, as a high-performance distributed cache and data storage middleware (Redis server), has become a key component for improving system performance and handling high-concurrency traffic. In various business scenarios, service instances use client operations on Redis for data caching, session management, distributed locks, and other operations, greatly improving system response speed and throughput.
[0003] However, in high-frequency call scenarios, accessing the Redis server using the existing Redis usage pattern can lead to cache breakdown issues. For example, when a hot data key in the Redis server expires, a large number of concurrent requests will simultaneously penetrate the cache and directly access the underlying database, causing a sudden surge in database load and potentially triggering an avalanche effect. Summary of the Invention
[0004] This application provides a business processing method, apparatus, computer equipment, and storage medium, which can solve the cache breakdown problem in high-frequency call scenarios.
[0005] In a first aspect, embodiments of this application provide a business processing method, which includes:
[0006] Receive a target service request, which requests the invocation of a target operation method;
[0007] When the target operation method is marked with a preset anti-duplicate annotation, the target service request is intercepted by a preset AOP interceptor;
[0008] Generate a target request identifier corresponding to the target service request according to the preset target request identifier generation rules;
[0009] Determine whether the target request identifier exists in the requested Redis server;
[0010] If the target request identifier exists in the Redis server, then the target business request is rejected;
[0011] If the target request identifier does not exist in the Redis server, then the target request identifier is written to the Redis server, the expiration time of the target request identifier in the Redis server is set, the target business request is allowed through the AOP interceptor, and the target operation method is executed to process the target business request.
[0012] In some embodiments, generating a target request identifier corresponding to the target service request according to a preset target request identifier generation rule includes:
[0013] The target request identifier generation rule corresponding to the target operation method is determined from a plurality of preset request identifier generation rules. The target request identifier generation rule is either the same user anti-duplicate identifier generation rule or the global user anti-duplicate identifier generation rule.
[0014] When the target request identifier is the same as the same user anti-duplicate identifier generation rule, the target request identifier is generated according to the method parameters, class name, method name and username corresponding to the target operation method.
[0015] When the target request identifier is the global user anti-duplicate identifier generation rule, the target request identifier is generated according to the method parameters, class name, and method name corresponding to the target operation method.
[0016] In some embodiments, after executing the target operation method to process the target service request, the method further includes:
[0017] The AOP interceptor intercepts the execution result of the target service request;
[0018] If the execution result is an execution failure, the target data is retrieved from the corresponding persistent database and then populated back into the Redis server.
[0019] In some embodiments, after intercepting the execution result of the target service request through the AOP interceptor, the method further includes:
[0020] If the execution result is successful, then the execution result is cached, and a time-to-live window for the execution result is set.
[0021] In some embodiments, determining whether the target request identifier exists in the requested Redis server includes:
[0022] The existence of the target request identifier in the Redis server is determined by a preset Redis atomic operation.
[0023] In some embodiments, the method is applied to a business processing device that integrates a starter component, the starter component including an automation configuration module and an encapsulation module, the target operation method including at least one target Redis operation, the target Redis operation being configured by the starter component; before receiving the target business request, the method further includes;
[0024] When the target service starts, the configuration parameter file corresponding to the target service is read through the preset automatic configuration module, and multiple Redis operation tool beans are created and registered to the application context of the business service through the configuration parameter file. The Redis operation tool beans are used for business requests of the target service to execute corresponding Redis operations.
[0025] The encapsulation module performs encapsulation operations on multiple target Redis tool beans among the multiple Redis operation tool beans to obtain at least one Redis operation method. The target Redis operation tool bean is a Redis operation tool bean of a preset type among the multiple Redis operation tool beans.
[0026] In some embodiments, the starter component further includes a key name constant pool, which includes multiple key templates. Each key template includes a key constant naming parameter and a placeholder. The data in the Redis server is stored based on the key name constant pool.
[0027] Secondly, embodiments of this application also provide a business processing apparatus, which includes:
[0028] The transceiver unit is used to receive a target service request, which requests the invocation of a target operation method.
[0029] The processing unit is configured to: intercept the target business request through a preset AOP interceptor when the target operation method is marked by a preset anti-duplicate annotation; generate a target request identifier corresponding to the target business request according to a preset target request identifier generation rule; determine whether the target request identifier exists in the requested Redis server; if the target request identifier exists in the Redis server, reject the target business request; if the target request identifier does not exist in the Redis server, write the target request identifier to the Redis server, set the expiration time of the target request identifier in the Redis server, allow the target business request through the AOP interceptor, and execute the target operation method to process the target business request.
[0030] Thirdly, embodiments of this application also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0031] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, can implement the above-described method.
[0032] This application provides a business processing method, apparatus, computer equipment, and storage medium. The method includes: receiving a target business request that requests to invoke a target operation method; when the target operation method is marked with a preset anti-duplicate annotation, intercepting the target business request through a preset AOP interceptor; generating a target request identifier corresponding to the target business request according to a preset target request identifier generation rule; determining whether the target request identifier exists in the requested Redis server; if the target request identifier exists in the Redis server, rejecting the target business request; if the target request identifier does not exist in the Redis server, writing the target request identifier to the Redis server, setting an expiration time for the target request identifier in the Redis server, allowing the target business request through the AOP interceptor, and executing the target operation method to process the target business request. This application embodiment uses an AOP interceptor to intercept operation methods marked with anti-duplicate annotations. Before executing the operation method corresponding to the business request, it first determines whether the corresponding business request has been executed within a preset time (expiration time) based on the request identifier of the corresponding business request. If it has been executed, the business request is rejected; otherwise, the business request is executed through the corresponding operation method. It can be seen that this solution can avoid multiple identical business requests accessing the Redis server in a short period of time, thus solving the cache breakdown problem in high-frequency call scenarios. Attached Figure Description
[0033] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 A flowchart illustrating the business processing method provided in the embodiments of this application;
[0035] Figure 2This is a schematic diagram of a sub-process of the business processing method provided in the embodiments of this application;
[0036] Figure 3 A schematic block diagram of a business processing apparatus provided in the embodiments of this application;
[0037] Figure 4 A schematic block diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0038] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0039] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0040] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0041] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0042] This application provides a business processing method, apparatus, computer equipment, and storage medium.
[0043] The entity executing the business processing method may be the business processing device provided in the embodiments of this application, or a computer device that integrates the business processing device. The business processing device may be implemented in hardware or software, and the computer device may be a terminal or a server.
[0044] Figure 1 This is a flowchart illustrating the business processing method provided in an embodiment of this application. For example... Figure 1 As shown, the method includes the following steps S110-S160.
[0045] S110. Receive the target service request, which requests to invoke the target operation method.
[0046] In this embodiment, the target operation method includes at least one target Redis operation, which is used to access the corresponding Redis server. The Redis server is a middleware that is independent of the business processing device (a computer device that integrates the business processing device) and provides distributed data storage and coordination services for the Starter component.
[0047] The Redis server acts as both the caller and the service provider. It receives commands (such as SET, GET, SETNX, etc.) issued by the target operation methods in this application and returns the results. Its core function is to provide the following functionalities for the business processing system:
[0048] Cache storage: Used to store frequently accessed data, reducing database pressure.
[0049] Atomic operation capabilities: Provides atomic commands such as SETNX and INCR, which are the technical foundation for implementing distributed locks and anti-duplicate judgment.
[0050] Key-value expiration mechanism: Setting a time-to-live (TTL) for stored data is the core of implementing debounce time windows and automatic cache invalidation.
[0051] Furthermore, in some embodiments, the method is applied to a business processing device that integrates a starter component, the starter component including an automation configuration module and an encapsulation module, the target operation method including at least one target Redis operation, the target Redis operation being configured by the starter component; before receiving the target business request, the method further includes;
[0052] When the target service starts, the configuration parameter file corresponding to the target service is read through the preset automatic configuration module, and multiple Redis operation tool beans are created and registered to the application context of the business service through the configuration parameter file. The Redis operation tool beans are used for business requests of the target service to execute corresponding Redis operations.
[0053] The encapsulation module performs encapsulation operations on multiple target Redis tool beans among the multiple Redis operation tool beans to obtain at least one Redis operation method. The target Redis operation tool bean is a Redis operation tool bean of a preset type among the multiple Redis operation tool beans.
[0054] Specifically, based on Solon's `@Configuration` mechanism, automated configuration of the Redis client (business processing device) module is implemented: supporting multi-data source configuration (default connection, cluster connection, sentinel mode, etc.), and dynamically injecting Redisson / lettuce client parameters through property files (configuration parameter files). Core beans (RedisTemplate, StringRedisTemplate, and custom encapsulation utility classes) are automatically registered, eliminating the need for manual initialization code. Furthermore, this application provides extension point interfaces, allowing the business layer to customize advanced parameters such as serializers and connection pool configurations.
[0055] Then, the high-frequency static methods are encapsulated through the encapsulation module. Specifically, some commonly used methods are encapsulated, and common operations on String and Hash types (storage, deletion, expiration time setting, etc.) are encapsulated into thread-safe static utility classes. The target Redis operation utility Bean is one of the Redis operation utility Beans of a preset type among multiple Redis operation utility Beans. This preset type is a commonly used type specified by the user. For example, Redis operation utility Beans of the corresponding types for String operations, Hash operations, and general function operations (providing distributed locks (based on SETNX + expiration time) and expiration subscriptions (combined with Redis Pub / Sub)) are encapsulated for convenient subsequent calls.
[0056] S120. When the target operation method is marked by a preset anti-duplicate annotation, the target service request is intercepted by a preset AOP interceptor.
[0057] In this embodiment, the target service provides various different services, which are invoked through different service requests. Different service requests correspond to different operation methods, which are Redis server invocation methods. Since some requests may be invoked frequently, there is a cache breakdown problem. This application sets anti-duplicate annotation markers (e.g., @RedisDegrade annotation) for the operation methods corresponding to these requests. After receiving the target service request, it first determines whether the target operation method corresponding to the target service request is marked with a preset anti-duplicate annotation. If it is not marked with a preset anti-duplicate annotation, the target operation method can be executed directly. If it is marked with a preset anti-duplicate annotation, the target service request is intercepted by a preset AOP interceptor, which is registered by the Starter component.
[0058] S130. Generate a target request identifier corresponding to the target service request according to the preset target request identifier generation rules.
[0059] Specifically, please refer to Figure 2 Step S130 includes:
[0060] S1301. Determine the target request identifier generation rule corresponding to the target operation method from a plurality of preset request identifier generation rules. The target request identifier generation rule is either the same user anti-duplicate identifier generation rule or the global user anti-duplicate identifier generation rule.
[0061] S1302. When the target request identifier is the same as the same user anti-duplicate identifier generation rule, the target request identifier is generated according to the method parameters, class name, method name and username corresponding to the target operation method.
[0062] S1303. When the target request identifier is the global user anti-duplicate identifier generation rule, the target request identifier is generated according to the method parameters, class name and method name corresponding to the target operation method.
[0063] Specifically, this embodiment sets different request identifier generation rules for different types of operation methods to achieve different anti-duplicate mechanisms. When the target request identifier is the same user anti-duplicate identifier generation rule, that is, when anti-duplicate control is performed on the same user, the target request identifier is generated according to the method parameters, class name, method name, and username. Specifically, the method parameters, class name, method name, and username can be concatenated, and then the concatenated data is hashed to obtain the target request identifier. At this time, the generated target request identifier is used to verify whether the same request from the same user has been processed within a preset time period (e.g., 5 seconds). When the target request identifier is the global user anti-duplicate identifier generation rule, that is, when anti-duplicate control is performed on the same business request (which can correspond to multiple different users), the target request identifier is generated according to the method parameters, class name, and method name. Specifically, the method parameters, class name, and method name can be concatenated, and then the concatenated data is hashed to obtain the target request identifier. At this time, the generated target request identifier is used to verify whether the same type of request has been processed within a preset time period.
[0064] Furthermore, before generating the target request identifier according to the preset rules, the method also includes:
[0065] Read the target data corresponding to the target operation method from the Redis server; determine whether the target data meets the preset conditions.
[0066] The step of generating a target request identifier corresponding to the target service request according to a preset target request identifier generation rule includes:
[0067] If the target data meets the preset conditions, then a target request identifier corresponding to the target service request is generated according to the preset target request identifier generation rules.
[0068] Furthermore, if the target data does not meet the preset conditions, the target operation method is directly executed to process the target business request, thereby improving the data processing speed.
[0069] For example, if the preset condition is that the remaining quantity of goods is less than 50, then the anti-duplicate mechanism is activated. According to the preset target request identifier generation rules, a target request identifier corresponding to the target business request is generated. The target request identifier is used to determine whether the same request is received within a preset time period to prevent the occurrence of "overselling".
[0070] S140. Determine whether the target request identifier exists in the requested Redis server. If yes, proceed to step S150; otherwise, proceed to step S160.
[0071] In this embodiment, the existence of the target request identifier in the Redis server is determined specifically through a preset Redis atomic operation.
[0072] If the target request identifier does not exist in the Redis server, it means that the Redis server has not been accessed by the same user with the same request or the same business request within the preset time period. In this case, proceed to step S150. If the target request identifier does not exist in the Redis server, it means that the Redis server has not been accessed by the same user with the same request or the same business request within the preset time period. In this case, proceed to step S160.
[0073] S150, Reject the target service request.
[0074] In this embodiment, if the anti-duplicate mechanism is set for the same user making the same request, after rejecting the target business request, a preset message corresponding to the target request is returned to the user, such as "Your application has been submitted, please do not click again", or "The interval between repeated submissions cannot be less than 5 seconds", or the request result of the previous request is returned (at this time, for the operation method marked by the preset anti-duplicate annotation, the repeated requests need to be merged within the specified time window (preset duration), only the first call is executed, and the cached result is returned directly afterward).
[0075] S160. Write the target request identifier into the Redis server, set the expiration time of the target request identifier in the Redis server, allow the target business request through the AOP interceptor, and execute the target operation method to process the target business request.
[0076] Specifically, a distributed lock is implemented using Redis's atomic operations (SETNX + EXPIRE) to control the number of times the same request is executed within a time window. SETNX is used to write the target request identifier, and EXPIRE is used to set the expiration time of the target request identifier.
[0077] In this embodiment, when executing the target operation method, if the target operation method is a commonly used method that has been encapsulated, the target operation method is called directly. If it is a method that has not been encapsulated, the target operation method is executed by calling the Redis operation tool Bean in the context information and executing the corresponding Redis operation.
[0078] Furthermore, the starter component provided in this application also includes a key name constant pool, which includes multiple key templates. Each key template includes key constant naming parameters and placeholders. The data in the Redis server is stored based on the key name constant pool.
[0079] Specifically, this application centrally manages all Redis key names through a key name constant pool, avoiding problems caused by hardcoding (without unified management of Redis key naming and caching time, it is easy to cause disordered expansion of Redis data, leading to difficulties in later maintenance). Among them, the key templates in the key name constant pool of this application have a prescribed naming standard, such as adopting a hierarchical naming rule of business prefix-module-function-ID (e.g., user:auth:token:123456), and the final Redis key name is generated by dynamic concatenation (supporting parameterized keys (e.g., order:{orderId}:status), and dynamic replacement of placeholders through utility classes). In addition, key names are classified and managed: constant groups are divided according to business domains (user, order, payment, etc.), improving readability and maintainability.
[0080] Specifically, in some embodiments, when executing the target operation method, the business processing device dynamically generates a globally unique and compliant target key name based on the predefined key name templates and rules in the key name constant pool, thereby achieving unified management and maintenance of Redis operations.
[0081] Furthermore, after executing the target operation method to process the target service request, the method further includes:
[0082] The AOP interceptor intercepts the execution result of the target business request; if the execution result is a failure, the target data is retrieved from the corresponding persistent database and populated back into the Redis server to prevent a large number of concurrent requests from breaking down the cache.
[0083] Specifically, the target operation method is executed to process the target business request. For example, if the cache is not hit, the execution result is execution failure. At this time, the Redis server returns null or nil, indicating that the cache does not exist. Then, the business processing device queries the database to obtain the required data by querying the persistent database. Before returning the result to the client, the cache is backfilled. When the same request comes again, the data can be directly hit from the Redis server.
[0084] If the execution result is successful, the execution result is cached, and a time-to-live (TTL) window is set for the execution result. This ensures that if the same business request is received again within the TTL window, the same execution result will be returned.
[0085] Furthermore, when the data processing device receives a business request, this application first performs an initial interception and verification of the request using JavaScript or native code (such as intercepting repeated click events (button disabling, form submission locking)). After the interception and verification pass, a corresponding request identifier is generated. The existence of the target request identifier in the Redis server is determined through a preset Redis atomic operation, and a second duplicate verification is performed on the request. It can be seen that this application provides a "dual protection mechanism of client-server linkage", and achieves a more comprehensive debouncing effect through the synergistic cooperation of this technology.
[0086] In summary, this application embodiment uses an AOP interceptor to intercept operation methods marked with anti-duplicate annotations. Before executing the operation method corresponding to the business request, it first determines whether the corresponding business request has been executed within a preset time (expiration time) based on the request identifier of the corresponding business request. If it has been executed, the business request is rejected; otherwise, the business request is executed through the corresponding operation method. It can be seen that this solution can avoid multiple identical business requests accessing the Redis server in a short period of time, solving the cache breakdown problem and hot key pressure problem in high-frequency call scenarios.
[0087] Among them, the Redis wrapper Starter in this application can serve as a standardized and highly available Redis operation solution. With its core capabilities such as high-frequency operation optimization, debouncing control, key-value management, and distributed coordination, it can be applied in any Solon framework that requires the use of Redis middleware.
[0088] Figure 3 This is a schematic block diagram of a service processing apparatus provided in an embodiment of this application. Figure 3As shown, corresponding to the above-described business processing method, this application also provides a business processing apparatus 300. The business processing apparatus 300 includes a unit for executing the above-described business processing method, and the business processing apparatus 300 can be configured in a terminal. Specifically, please refer to... Figure 3 The service processing device 300 includes a transceiver unit 301 and a processing unit 302, wherein:
[0089] Transceiver unit 301 is used to receive a target service request, wherein the target service request requests to invoke a target operation method;
[0090] The processing unit 302 is configured to: intercept the target business request through a preset AOP interceptor when the target operation method is marked by a preset anti-duplicate annotation; generate a target request identifier corresponding to the target business request according to a preset target request identifier generation rule; determine whether the target request identifier exists in the requested Redis server; if the target request identifier exists in the Redis server, reject the target business request; if the target request identifier does not exist in the Redis server, write the target request identifier into the Redis server, set the expiration time of the target request identifier in the Redis server, allow the target business request through the AOP interceptor, and execute the target operation method to process the target business request.
[0091] In some embodiments, when the processing unit 302 performs the step of generating a target request identifier corresponding to the target service request according to a preset target request identifier generation rule, it is specifically used for:
[0092] The target request identifier generation rule corresponding to the target operation method is determined from a plurality of preset request identifier generation rules. The target request identifier generation rule is either the same user anti-duplicate identifier generation rule or the global user anti-duplicate identifier generation rule.
[0093] When the target request identifier is the same as the same user anti-duplicate identifier generation rule, the target request identifier is generated according to the method parameters, class name, method name and username corresponding to the target operation method.
[0094] When the target request identifier is the global user anti-duplicate identifier generation rule, the target request identifier is generated according to the method parameters, class name, and method name corresponding to the target operation method.
[0095] In some embodiments, after executing the step of the target operation method to process the target service request, the processing unit 302 is further configured to:
[0096] The AOP interceptor intercepts the execution result of the target service request;
[0097] If the execution result is an execution failure, the target data is retrieved from the corresponding persistent database and then populated back into the Redis server.
[0098] In some embodiments, after executing the step of intercepting the target service request through the AOP interceptor, the processing unit 302 is further configured to:
[0099] If the execution result is successful, then the execution result is cached, and a time-to-live window for the execution result is set.
[0100] In some embodiments, when the processing unit 302 performs the step of determining whether the target request identifier exists in the requested Redis server, it is specifically used for:
[0101] The existence of the target request identifier in the Redis server is determined by a preset Redis atomic operation.
[0102] In some embodiments, the method is applied to a business processing device that integrates a starter component, the starter component including an automation configuration module and an encapsulation module, the target operation method including at least one target Redis operation, the target Redis operation being configured by the starter component; before performing the step of receiving the target business request, the processing unit 302 is further configured to;
[0103] When the target service starts, the configuration parameter file corresponding to the target service is read through the preset automatic configuration module, and multiple Redis operation tool beans are created and registered to the application context of the business service through the configuration parameter file. The Redis operation tool beans are used for business requests of the target service to execute corresponding Redis operations.
[0104] The encapsulation module performs encapsulation operations on multiple target Redis tool beans among the multiple Redis operation tool beans to obtain at least one Redis operation method. The target Redis operation tool bean is a Redis operation tool bean of a preset type among the multiple Redis operation tool beans.
[0105] In some embodiments, the starter component further includes a key name constant pool, which includes multiple key templates. Each key template includes a key constant naming parameter and a placeholder. The data in the Redis server is stored based on the key name constant pool.
[0106] In summary, this application embodiment uses an AOP interceptor to intercept operation methods marked with anti-duplicate annotations. Before executing the operation method corresponding to the business request, it first determines whether the corresponding business request has been executed within a preset time (expiration time) based on the request identifier of the corresponding business request. If it has been executed, the business request is rejected; otherwise, the business request is executed through the corresponding operation method. It can be seen that this solution can avoid multiple identical business requests accessing the Redis server in a short period of time, solving the cache breakdown problem and hot key pressure problem in high-frequency call scenarios.
[0107] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned business processing device and each unit can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.
[0108] The aforementioned business processing device can be implemented as a computer program, which can, for example... Figure 4 It runs on the computer device shown.
[0109] Please see Figure 4 , Figure 4 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 400 can be a terminal or a server. The terminal can be an electronic device with communication functions, such as a smartphone, tablet, laptop, desktop computer, personal digital assistant, or wearable device. The server can be a standalone server or a server cluster composed of multiple servers.
[0110] See Figure 4 The computer device 400 includes a processor 402, a memory, and a network interface 405 connected via a system bus 401. The memory may include a non-volatile storage medium 403 and internal memory 404.
[0111] The non-volatile storage medium 403 may store an operating system 4031 and a computer program 4032. The computer program 4032 includes program instructions that, when executed, cause the processor 402 to perform a business processing method.
[0112] The processor 402 provides computing and control capabilities to support the operation of the entire computer device 400.
[0113] The internal memory 404 provides an environment for the execution of the computer program 4032 in the non-volatile storage medium 403. When the computer program 4032 is executed by the processor 402, the processor 402 can execute a business processing method.
[0114] This network interface 405 is used for network communication with other devices. Those skilled in the art will understand that... Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 400 to which the present application is applied. The specific computer device 400 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0115] The processor 402 is used to run a computer program 4032 stored in the memory to perform the following steps:
[0116] Receive a target service request, which requests the invocation of a target operation method;
[0117] When the target operation method is marked with a preset anti-duplicate annotation, the target service request is intercepted by a preset AOP interceptor;
[0118] Generate a target request identifier corresponding to the target service request according to the preset target request identifier generation rules;
[0119] Determine whether the target request identifier exists in the requested Redis server;
[0120] If the target request identifier exists in the Redis server, then the target business request is rejected;
[0121] If the target request identifier does not exist in the Redis server, then the target request identifier is written to the Redis server, the expiration time of the target request identifier in the Redis server is set, the target business request is allowed through the AOP interceptor, and the target operation method is executed to process the target business request.
[0122] It should be understood that in the embodiments of this application, the processor 402 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0123] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0124] Therefore, this application also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When executed by a processor, the program instructions cause the processor to perform the following steps:
[0125] Receive a target service request, which requests the invocation of a target operation method;
[0126] When the target operation method is marked with a preset anti-duplicate annotation, the target service request is intercepted by a preset AOP interceptor;
[0127] Generate a target request identifier corresponding to the target service request according to the preset target request identifier generation rules;
[0128] Determine whether the target request identifier exists in the requested Redis server;
[0129] If the target request identifier exists in the Redis server, then the target business request is rejected;
[0130] If the target request identifier does not exist in the Redis server, then the target request identifier is written to the Redis server, the expiration time of the target request identifier in the Redis server is set, the target business request is allowed through the AOP interceptor, and the target operation method is executed to process the target business request.
[0131] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0132] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0133] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0134] The steps in the methods of this application embodiment can be adjusted, merged, or deleted according to actual needs. The units in the apparatus of this application embodiment can be merged, divided, or deleted according to actual needs. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0135] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0136] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A service processing method characterized by, The method comprises: receiving a target service request, the target service request requesting to call a target operation method; when the target operation method is marked by a preset anti-repetition annotation, intercepting the target service request by a preset AOP interceptor; generating a target request identifier corresponding to the target service request according to a preset target request identifier generation rule; judging whether the target request identifier exists in a requested Redis server; if the target request identifier exists in the Redis server, rejecting the target service request; if the target request identifier does not exist in the Redis server, writing the target request identifier into the Redis server, setting an expiration time of the target request identifier in the Redis server, passing the target service request through the AOP interceptor, and executing the target operation method to process the target service request.
2. The method of claim 1, wherein, The method further comprises: intercepting an execution result of the target service request by the AOP interceptor; if the execution result is a failure, obtaining target data from a corresponding persistent database, and backfilling the target data into the Redis server. The method further comprises:
3. The method of claim 1, wherein, if the execution result is a success, caching the execution result and setting a survival time window of the execution result. The judging whether the target request identifier exists in the requested Redis server comprises: judging whether the target request identifier exists in the Redis server by a preset Redis atomic operation.
4. The method of claim 3, wherein, The method is applied to a service processing device integrated with a starter component, the starter component comprising an automatic configuration module and an encapsulation module, the target operation method comprising at least one target Redis operation, the target Redis operation being obtained by the starter component configuration; before receiving the target service request, the method further comprises: 5. The method of claim 1, wherein, 6. The method of claim 1, wherein, When the target service is started, a preset automatic configuration module reads a configuration parameter file corresponding to the target service, and creates and registers a plurality of Redis operation tool Beans in an application context of the business service through the configuration parameter file, the Redis operation tool Beans being used for the business request of the target service to call to perform corresponding Redis operations; The encapsulation module performs encapsulation operation on a plurality of target Redis tool Beans in the plurality of Redis operation tool Beans, and at least one Redis operation method is obtained through encapsulation, the target Redis operation tool Beans being Redis operation tool Beans of a preset type in the plurality of Redis operation tool Beans.
7. The method of claim 6, wherein, The starter component further includes a key name constant pool, the key name constant pool including a plurality of key templates, the key templates including key constant naming parameters and placeholders, and data in the Redis server being stored based on the key name constant pool.
8. A service processing apparatus characterized by comprising: The method comprises: a receiving unit configured to receive a target business request, the target business request requesting to call a target operation method; a processing unit configured to, when the target operation method is marked by a preset anti-repeated annotation, intercept the target business request through a preset AOP interceptor; generate a target request identifier corresponding to the target business request according to a preset target request identifier generation rule; determine whether the target request identifier exists in the Redis server; if the target request identifier exists in the Redis server, reject the target business request; if the target request identifier does not exist in the Redis server, write the target request identifier into the Redis server, set an expiration time of the target request identifier in the Redis server, pass the target business request through the AOP interceptor, and execute the target operation method to process the target business request.
9. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the business processing method according to any one of claims 1-7 when executing the computer program.
10. A storage medium, characterized by The storage medium stores a computer program, the computer program including program instructions, the program instructions causing the processor to execute the business processing method according to any one of claims 1-7 when executed by the processor.
Citation Information
Patent Citations
Identification analysis method and device, equipment and storage medium
CN117544593A
Method and apparatus for browsing using alternative linkbases
US20140123186A1