CN112052263A - Method, system, computer device, and readable storage medium for requesting instruction processing - Google Patents

Method, system, computer device, and readable storage medium for requesting instruction processing Download PDF

Info

Publication number
CN112052263A
CN112052263A CN202010667873.3A CN202010667873A CN112052263A CN 112052263 A CN112052263 A CN 112052263A CN 202010667873 A CN202010667873 A CN 202010667873A CN 112052263 A CN112052263 A CN 112052263A
Authority
CN
China
Prior art keywords
request instruction
annotation
cache
processing
return value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010667873.3A
Other languages
Chinese (zh)
Inventor
陈浩翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dasou Vehicle Software Technology Co Ltd
Original Assignee
Zhejiang Dasou Vehicle Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dasou Vehicle Software Technology Co Ltd filed Critical Zhejiang Dasou Vehicle Software Technology Co Ltd
Priority to CN202010667873.3A priority Critical patent/CN112052263A/en
Publication of CN112052263A publication Critical patent/CN112052263A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请涉及一种请求指令处理的方法、系统、计算机设备和可读存储介质,其中,该请求指令处理的方法包括:接收请求指令,通过拦截器获取该请求指令的注解,将该注解与缓存抽象接口进行匹配,获取对该请求指令的处理方式,其中,该处理方式与该注解对应,根据该处理方式对该请求指令进行处理,并返回该请求指令的返回值。通过本申请,解决了开发人员需要手动管理缓存和连接缓存数据库,增加开发成本,耗费时间较长,效率较低的问题,实现了缓存数据库的自动管理,提高对请求命令的处理效率,节省时间。

Figure 202010667873

The present application relates to a method, system, computer device, and readable storage medium for processing a request instruction, wherein the method for processing a request instruction includes: receiving a request instruction, obtaining an annotation of the request instruction through an interceptor, and storing the annotation with a cache The abstract interface is matched to obtain the processing method of the request instruction, wherein the processing method corresponds to the annotation, the request instruction is processed according to the processing method, and the return value of the request instruction is returned. This application solves the problems that developers need to manually manage the cache and connect to the cache database, increase the development cost, consume a long time, and have low efficiency, realize the automatic management of the cache database, improve the processing efficiency of the request command, and save time. .

Figure 202010667873

Description

请求指令处理的方法、系统、计算机设备和可读存储介质Method, system, computer device, and readable storage medium for requesting instruction processing

技术领域technical field

本申请涉及数据处理技术领域,特别是涉及请求指令处理的方法、系统、计算机设备和可读存储介质。The present application relates to the technical field of data processing, and in particular, to a method, system, computer device and readable storage medium for requesting instruction processing.

背景技术Background technique

随着互联网技术的发展,互联网中的内容和信息越来越复杂,互联网用户的数量和用户访问量越来越大,以互联网为基础的应用需要支撑更多的并发量,同时,应用服务器和数据库服务器需要完成的计算也越来越多。然而,应用服务器的资源有限,数据库每秒能接受的请求次数同样有限。With the development of Internet technology, the content and information on the Internet are becoming more and more complex, the number of Internet users and the number of user visits are increasing, and Internet-based applications need to support more concurrency. At the same time, application servers and Database servers also need to perform more and more computations. However, the resources of the application server are limited, and the number of requests per second the database can accept is also limited.

在相关技术中,例如,在一些秒杀场景下,为避免卖出的货物数量大于预计销售量,开发人员需要自己手动连接远程字典服务(Remote Dictionary Server,简称为Redis),管理缓存以及缓存过期,或者是手动写分布式锁,以提供尽可能大的吞吐量,让有限的资源服务更多的用户。然而,通过开发人员手动连接Redis和管理缓存,会增加开发成本,耗费较长的时间,效率较低。In related technologies, for example, in some seckill scenarios, in order to avoid the number of goods sold being greater than the estimated sales volume, developers need to manually connect to the remote dictionary service (Remote Dictionary Server, Redis for short), manage the cache and cache expiration, Or manually write distributed locks to provide the greatest possible throughput and allow limited resources to serve more users. However, manually connecting to Redis and managing the cache by developers will increase development costs, take a long time, and be inefficient.

目前针对相关技术中开发人员手动连接Redis和管理缓存,会增加开发成本,耗费较长的时间,效率较低的问题,尚未提出有效的解决方案。At present, in the related technologies, developers manually connect Redis and manage the cache, which will increase the development cost, take a long time, and have low efficiency, and no effective solution has been proposed yet.

发明内容SUMMARY OF THE INVENTION

本申请实施例提供了一种请求指令处理的方法、系统、计算机设备和计算机可读存储介质,以至少解决相关技术中开发人员手动连接Redis和管理缓存,会增加开发成本,耗费较长的时间,效率较低的问题。Embodiments of the present application provide a method, system, computer device, and computer-readable storage medium for processing request instructions, so as to at least solve the problem in the related art that developers manually connect to Redis and manage cache, which increases development costs and takes a long time. , the problem of lower efficiency.

第一方面,本申请实施例提供了一种请求指令处理的方法,所述方法包括:In a first aspect, an embodiment of the present application provides a method for requesting instruction processing, the method comprising:

接收请求指令,通过拦截器获取所述请求指令的注解;Receive the request instruction, and obtain the annotation of the request instruction through the interceptor;

将所述注解与缓存抽象接口进行匹配,获取对所述请求指令的处理方式,其中,所述处理方式与所述注解对应;Matching the annotation with the cache abstract interface to obtain a processing method for the request instruction, wherein the processing method corresponds to the annotation;

根据所述处理方式对所述请求指令进行处理,并返回所述请求指令的返回值。The request instruction is processed according to the processing method, and the return value of the request instruction is returned.

在其中一些实施例中,在所述注解为第一注解的情况下,所述根据所述处理方式对所述请求指令进行处理包括以下之一:In some of the embodiments, when the annotation is the first annotation, the processing the request instruction according to the processing method includes one of the following:

在Redis缓存中存在所述请求指令的返回值的情况下,调用所述Redis缓存,在所述Redis缓存中获取所述请求指令的返回值;In the case that the return value of the request instruction exists in the Redis cache, call the Redis cache, and obtain the return value of the request instruction in the Redis cache;

在所述Redis缓存中不存在所述请求指令的返回值的情况下,在存储介质中获取所述请求指令的返回值,通过序列化将所述返回值设置至所述Redis缓存中,并对所述第一注解的配置属性进行设置。In the case that the return value of the request instruction does not exist in the Redis cache, obtain the return value of the request instruction in the storage medium, set the return value to the Redis cache through serialization, and The configuration properties of the first annotation are set.

在其中一些实施例中,所述序列化包括以下至少之一:fastjson序列化、kryo序列化和JDK序列化。In some of these embodiments, the serialization includes at least one of: fastjson serialization, kryo serialization, and JDK serialization.

在其中一些实施例中,在所述注解为第二注解的情况下,所述根据所述处理方式对所述请求指令进行处理包括:In some of the embodiments, when the annotation is the second annotation, the processing the request instruction according to the processing method includes:

加载lua脚本,在Redis缓存中获取分布式锁,所述第二注解的配置属性包括可重入锁次数和间隔时间;Load the lua script, obtain distributed locks in the Redis cache, and the configuration attributes of the second annotation include the number of reentrant locks and the interval time;

在所述Redis缓存中存在所述分布式锁的情况下,不对所述请求指令进行处理,或者,在所述Redis缓存中不存在所述分布式锁的情况下,从存储介质中获取所述请求指令的返回值,将所述分布式锁进行释放。In the case that the distributed lock exists in the Redis cache, the request instruction is not processed, or, in the case that the distributed lock does not exist in the Redis cache, the request instruction is obtained from the storage medium The return value of the request instruction is requested, and the distributed lock is released.

在其中一些实施例中,在所述注解为第三注解的情况下,所述根据所述处理方式对所述请求指令进行处理包括:In some of the embodiments, when the annotation is a third annotation, the processing the request instruction according to the processing method includes:

在Redis缓存中,删除键值对,其中,所述键值对的键为所述第三注解标注的键。In the Redis cache, delete the key-value pair, wherein the key of the key-value pair is the key marked by the third annotation.

在其中一些实施例中,在所述注解为第四注解的情况下,所述根据所述处理方式对所述请求指令进行处理还包括:In some of the embodiments, when the annotation is a fourth annotation, the processing the request instruction according to the processing method further includes:

获取第四注解,所述第四注解标注的参数用于组装Redis缓存中的键。The fourth annotation is obtained, and the parameters marked by the fourth annotation are used to assemble the keys in the Redis cache.

在其中一些实施例中,所述缓存抽象接口的配置参数包括过期时间。In some of these embodiments, the configuration parameter of the cache abstraction interface includes an expiration time.

在其中一些实施例中,在所述通过拦截器获取所述请求指令的注解之后,所述方法还包括:In some of the embodiments, after obtaining the annotation of the request instruction through the interceptor, the method further includes:

在所述注解不能与所述缓存抽象接口匹配的情况下,在存储介质中获取所述请求指令的返回值。In the case that the annotation cannot be matched with the cache abstract interface, the return value of the request instruction is obtained in the storage medium.

第二方面,本申请实施例提供了一种请求指令处理的系统,所述系统包括:缓存模块和核心模块;In a second aspect, an embodiment of the present application provides a system for requesting instruction processing, the system comprising: a cache module and a core module;

所述缓存模块接收请求指令,通过拦截器获取所述请求指令的注解;The cache module receives the request instruction, and obtains the annotation of the request instruction through the interceptor;

所述核心模块将所述注解与缓存抽象接口进行匹配,获取对所述请求指令的处理方式,其中,所述处理方式与所述注解对应;The core module matches the annotation with the cache abstract interface, and obtains a processing method for the request instruction, wherein the processing method corresponds to the annotation;

所述缓存模块根据所述处理方式对所述请求指令进行处理,所述核心模块返回所述请求指令的返回值。The cache module processes the request instruction according to the processing method, and the core module returns a return value of the request instruction.

第三方面,本申请实施例提供了一种计算机设备,包括存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述任一所述方法。In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, when the processor executes the computer program Implement any of the methods described above.

第四方面,本申请实施例提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述任一所述方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, any one of the foregoing methods is implemented.

相比于相关技术,本申请实施例提供的请求指令处理的方法,通过接收请求指令,通过拦截器获取该请求指令的注解,将该注解与缓存抽象接口进行匹配,获取对该请求指令的处理方式,其中,该处理方式与该注解对应,根据该处理方式对该请求指令进行处理,并返回该请求指令的返回值,解决了开发人员需要手动管理缓存和连接缓存数据库,增加开发成本,耗费时间较长,效率较低的问题,实现了缓存数据库的自动管理,提高对请求命令的处理效率,节省时间。Compared with the related art, the method for processing a request instruction provided by the embodiment of the present application, by receiving the request instruction, obtaining the annotation of the request instruction through an interceptor, matching the annotation with the cache abstract interface, and obtaining the processing of the request instruction. method, wherein the processing method corresponds to the annotation, the request instruction is processed according to the processing method, and the return value of the request instruction is returned, which solves the need for developers to manually manage the cache and connect to the cache database, which increases development costs and consumes The problem of long time and low efficiency realizes the automatic management of the cache database, improves the processing efficiency of the request command, and saves time.

附图说明Description of drawings

此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The schematic embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation of the present application. In the attached image:

图1是根据本申请实施例的请求指令处理的方法的应用环境示意图;1 is a schematic diagram of an application environment of a method for processing a request instruction according to an embodiment of the present application;

图2是根据本申请实施例的请求指令处理的方法的流程图;2 is a flowchart of a method for processing a request instruction according to an embodiment of the present application;

图3是根据本申请实施例的另一种请求指令处理的方法的流程图;3 is a flowchart of another method for requesting instruction processing according to an embodiment of the present application;

图4是根据本申请实施例的请求指令处理的系统的结构框图;4 is a structural block diagram of a system for requesting instruction processing according to an embodiment of the present application;

图5是根据本申请实施例的请求指令处理的缓存框架的结构示意图;5 is a schematic structural diagram of a cache framework for request instruction processing according to an embodiment of the present application;

图6是根据本申请优选实施例的请求指令处理的流程图;6 is a flowchart of request instruction processing according to a preferred embodiment of the present application;

图7是根据本申请实施例的电子设备的内部结构示意图。FIG. 7 is a schematic diagram of an internal structure of an electronic device according to an embodiment of the present application.

具体实施方式Detailed ways

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行描述和说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。基于本申请提供的实施例,本领域普通技术人员在没有作出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

显而易见地,下面描述中的附图仅仅是本申请的一些示例或实施例,对于本领域的普通技术人员而言,在不付出创造性劳动的前提下,还可以根据这些附图将本申请应用于其他类似情景。此外,还可以理解的是,虽然这种开发过程中所作出的努力可能是复杂并且冗长的,然而对于与本申请公开的内容相关的本领域的普通技术人员而言,在本申请揭露的技术内容的基础上进行的一些设计,制造或者生产等变更只是常规的技术手段,不应当理解为本申请公开的内容不充分。Obviously, the accompanying drawings in the following description are only some examples or embodiments of the present application. For those of ordinary skill in the art, the present application can also be applied to the present application according to these drawings without any creative effort. other similar situations. In addition, it will also be appreciated that while such development efforts may be complex and lengthy, for those of ordinary skill in the art to which the present disclosure pertains, the techniques disclosed in this application Some changes in design, manufacture or production based on the content are only conventional technical means, and it should not be understood that the content disclosed in this application is not sufficient.

在本申请中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域普通技术人员显式地和隐式地理解的是,本申请所描述的实施例在不冲突的情况下,可以与其它实施例相结合。Reference in this application to an "embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor a separate or alternative embodiment that is mutually exclusive of other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.

除非另作定义,本申请所涉及的技术术语或者科学术语应当为本申请所属技术领域内具有一般技能的人士所理解的通常意义。本申请所涉及的“一”、“一个”、“一种”、“该”等类似词语并不表示数量限制,可表示单数或复数。本申请所涉及的术语“包括”、“包含”、“具有”以及它们任何变形,意图在于覆盖不排他的包含;例如包含了一系列步骤或模块(单元)的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可以还包括没有列出的步骤或单元,或可以还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。本申请所涉及的“连接”、“相连”、“耦接”等类似的词语并非限定于物理的或者机械的连接,而是可以包括电气的连接,不管是直接的还是间接的。本申请所涉及的“多个”是指两个或两个以上。“和/或”描述关联对象的关联关系,表示可以存在三种关系,例如,“A和/或B”可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。本申请所涉及的术语“第一”、“第二”、“第三”等仅仅是区别类似的对象,不代表针对对象的特定排序。Unless otherwise defined, the technical or scientific terms involved in this application shall have the usual meanings understood by those with ordinary skill in the technical field to which this application belongs. Words such as "a", "an", "an", "the" and the like mentioned in this application do not denote a quantitative limitation, and may denote the singular or the plural. The terms "comprising", "comprising", "having" and any of their variants referred to in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product or process comprising a series of steps or modules (units) The apparatus is not limited to the steps or units listed, but may further include steps or units not listed, or may further include other steps or units inherent to the process, method, product or apparatus. Words like "connected," "connected," "coupled," and the like referred to in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "plurality" referred to in this application refers to two or more. "And/or" describes the association relationship between associated objects, indicating that there can be three kinds of relationships. For example, "A and/or B" can mean that A exists alone, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects are an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only to distinguish similar objects, and do not represent a specific order for the objects.

本申请提供的请求指令处理的方法,可以应用于如图1所示的应用环境中,图1是根据本申请实施例的请求指令处理的方法的应用环境示意图,如图1所示。其中,缓存数据库102与服务器104通过网络进行通信。服务器104接收请求指令,基于拦截器获取该请求指令的注解,并将该注解与缓存数据库102的缓存抽象接口进行匹配,获取对该请求指令的处理方式,服务器104根据该处理方式对该请求指令进行处理,并获取请求指令的返回值。其中,缓存数据库102可以为Redis缓存数据库,服务器104可以用独立的服务器或者是多个服务器组成的服务器集群来实现。The method for processing a request instruction provided by the present application can be applied to the application environment shown in FIG. 1 , which is a schematic diagram of an application environment of the method for processing a request instruction according to an embodiment of the present application, as shown in FIG. 1 . The cache database 102 communicates with the server 104 through the network. The server 104 receives the request instruction, obtains the annotation of the request instruction based on the interceptor, matches the annotation with the cache abstract interface of the cache database 102, obtains the processing method of the request instruction, and the server 104 executes the request instruction according to the processing method. Process and get the return value of the request instruction. The cache database 102 may be a Redis cache database, and the server 104 may be implemented by an independent server or a server cluster composed of multiple servers.

本实施例提供了一种请求指令处理的方法。图2是根据本申请实施例的请求指令处理的方法的流程图,如图2所示,该方法包括如下步骤:This embodiment provides a method for requesting instruction processing. FIG. 2 is a flowchart of a method for processing a request instruction according to an embodiment of the present application. As shown in FIG. 2 , the method includes the following steps:

步骤S201,接收请求指令,通过拦截器获取该请求指令的注解;Step S201, receiving the request instruction, and obtaining the annotation of the request instruction through the interceptor;

本实施例中的请求指令可以为秒杀场景下,顾客将目标商品加入购物车的指令。该请求指令在被接收之后,服务器可以对该请求指令的注解进行拦截和识别,本实施例中,服务器可以通过拦截器拦截使用了特定注解的请求指令。拦截器可以基于使用Spring的面向切面编程(Aspect Oriented Programming,简称为AOP)实现,其中,AOP为通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术。The request instruction in this embodiment may be an instruction for the customer to add the target product to the shopping cart in a seckill scenario. After the request instruction is received, the server may intercept and identify the annotation of the request instruction. In this embodiment, the server may intercept the request instruction using a specific annotation through an interceptor. Interceptors can be implemented based on Aspect Oriented Programming (AOP) using Spring, where AOP is a technology that achieves unified maintenance of program functions through pre-compilation and runtime dynamic agents.

步骤S202,将该注解与缓存抽象接口进行匹配,获取对该请求指令的处理方式,其中,该处理方式与该注解对应;在缓存数据库中,可以设置多个缓存抽象接口与注解进行匹配,在注解与缓存抽象接口匹配成功的情况下,可以通过开发人员在xml配置文件中注册得到的注解处理器,对该注解进行处理,通过识别注解,获取与注解对应的对请求指令的处理方式,该处理方式可以为在缓存数据库中查询请求指令的返回值,可以为在缓存数据库中查询分布式锁,也可以为将缓存数据库中与注解对应的缓存删除。本实施例中的缓存抽象接口为多个定义了缓存功能的抽象方法的集合,其中,“抽象”为一类事物共同特征的宏观描述,缓存抽象接口可以提高程序的复用率,增加程序的可维护性和可扩展性。Step S202, matching the annotation with the cache abstract interface to obtain a processing method for the request instruction, wherein the processing method corresponds to the annotation; in the cache database, multiple cache abstract interfaces can be set to match the annotation, and in the cache database If the annotation and the cache abstract interface are successfully matched, the annotation processor can be processed by the developer registered in the xml configuration file, and the processing method of the request instruction corresponding to the annotation can be obtained by identifying the annotation. The processing method may be querying the return value of the request instruction in the cache database, querying the distributed lock in the cache database, or deleting the cache corresponding to the annotation in the cache database. The cache abstraction interface in this embodiment is a collection of multiple abstract methods that define a cache function, wherein “abstract” is a macro description of the common characteristics of a class of things. The cache abstraction interface can improve the reuse rate of programs and increase the Maintainability and Extensibility.

步骤S203,根据该处理方式对该请求指令进行处理,并返回请求指令的返回值,本实施例中,请求指令的返回值为对请求指令的处理结果。Step S203, process the request instruction according to the processing method, and return a return value of the request instruction. In this embodiment, the return value of the request instruction is a processing result of the request instruction.

通过上述步骤S201至步骤S203,通过对请求指令使用的注解进行识别,可以直接进入缓存数据库对请求指令进行处理,开发人员不需要再手动编写代码,解决了开发人员需要手动管理缓存和连接缓存数据库,增加开发成本,耗费时间较长,效率较低的问题,实现了缓存数据库的自动管理,提高对请求命令的处理效率,节省时间,同时提高了程序的一致性和规范性。Through the above steps S201 to S203, by identifying the annotations used by the request instructions, the cache database can be directly entered to process the request instructions, and developers do not need to manually write codes, which solves the need for developers to manually manage the cache and connect to the cache database. , increases the development cost, takes a long time, and has low efficiency. It realizes the automatic management of the cache database, improves the processing efficiency of the request command, saves time, and improves the consistency and standardization of the program.

在其他实施例中,为请求指令添加注解的过程在缓存框架获取请求指令之前完成,例如可以在业务层完成,进一步地,请求指令处理的方法可以通过缓存框架完成,该缓存框架在封装后可以用于对接多种业务层,缓存框架从业务层获取带有注解的请求指令,根据注解对请求指令进行处理。其中,该注解可以由开发人员手动为请求指令添加,也可以通过编程实现,便于对请求指令进行处理。In other embodiments, the process of adding annotations to the request instruction is completed before the cache framework acquires the request instruction, for example, it can be completed at the business layer. Further, the method for processing the request instruction can be completed through the cache framework, which can It is used to connect to various business layers. The caching framework obtains request instructions with annotations from the business layer, and processes the request instructions according to the annotations. The annotation can be manually added by the developer for the request instruction, or can be implemented by programming, so as to facilitate the processing of the request instruction.

在其中一些实施例中,在注解为第一注解的情况下,对请求指令进行处理包括:在Redis缓存中存在该请求指令的返回值的情况下,调用该Redis缓存,在该Redis缓存中获取该请求指令的返回值;或者,在Redis缓存中不存在请求指令的返回值的情况下,在存储介质中获取该请求指令的返回值,通过序列化将该返回值设置至该Redis缓存中,并对第一注解的配置属性进行设置。In some of the embodiments, in the case that the annotation is the first annotation, processing the request instruction includes: in the case that the return value of the request instruction exists in the Redis cache, calling the Redis cache, and obtaining in the Redis cache The return value of the request instruction; or, if the return value of the request instruction does not exist in the Redis cache, obtain the return value of the request instruction in the storage medium, and set the return value to the Redis cache through serialization, And set the configuration properties of the first annotation.

需要说明的是,Redis为远程字典服务(Remote Dictionary Server,简称为Redis),是一个键值对(key-value)数据库。Redis使用美国国家标准协会(AmericanNational Standards Institute,简称为ANSI)制定的C语言标准编写,遵守BSD协议(Berkeley Software Distribution),支持网络,可基于内存亦可持久化,同时可以提供多种语言的应用程序接口(Application Programming Interface,简称为API)。本实施例中的第一注解可以为CacheSet,该第一注解作用于请求指令上,可以将请求指令的返回值设置至Redis缓存中。在第一注解为Cache Set的情况下,第一注解的配置属性可以为keyHead和expire,其中,keyHead为Redis中key的前缀,expire为过期时间,默认值为600s。It should be noted that Redis is a Remote Dictionary Server (Redis for short), which is a key-value database. Redis is written using the C language standard formulated by the American National Standards Institute (ANSI), complies with the BSD protocol (Berkeley Software Distribution), supports the network, can be memory-based or persistent, and can provide applications in multiple languages. Program interface (Application Programming Interface, referred to as API). The first annotation in this embodiment may be CacheSet, the first annotation acts on the request instruction, and the return value of the request instruction may be set in the Redis cache. When the first annotation is Cache Set, the configuration properties of the first annotation can be keyHead and expire, where keyHead is the prefix of the key in Redis, expire is the expiration time, and the default value is 600s.

本实施例中的存储介质可以为临时或者永久性存储区,序列化为将对象的状态信息转换为可以存储或传输的形式的过程。在序列化期间,对象将其当前状态写入到临时或持久性存储区。在写入之后,可以通过从存储区中读取或者反序列化对象的状态,重新创建该对象,反序列化为把变量内容从序列化的对象重新读到内存里。The storage medium in this embodiment may be a temporary or permanent storage area, and serialization is a process of converting state information of an object into a form that can be stored or transmitted. During serialization, objects write their current state to temporary or persistent storage. After writing, the object can be recreated by reading or deserializing the state of the object from storage, and deserialization re-reads the variable contents from the serialized object into memory.

本实施例可以通过第一注解,直接在Redis缓存中查找与请求指令对应的返回值是否存在,在Redis缓存中不存在该返回值的情况下,可以在存储介质中查找该返回值,并将该返回值序列化至Redis缓存,由于Redis的读写速度快,因此本实施例中的方法可以提高请求指令的处理速度。另一方面,将返回值序列化至Redis缓存,有利于对之后的请求指令进行快速处理。In this embodiment, the first annotation can be used to directly search the Redis cache for the existence of the return value corresponding to the request command. If the return value does not exist in the Redis cache, the return value can be searched in the storage medium, and the The return value is serialized to the Redis cache. Since the read and write speed of Redis is fast, the method in this embodiment can improve the processing speed of the request instruction. On the other hand, serializing the return value to the Redis cache is conducive to fast processing of subsequent request instructions.

在其中一些实施例中,序列化包括以下至少之一:fastjson序列化、kryo序列化和JDK序列化。其中,kryo序列化的速度快,且序列化后数据的size小,性能佳,但kryo序列化的兼容性不是最好,不能支持所有对象的序列化;fastjson性能较好且稳定;JDK序列化的速度最慢,但是稳定性最好。本实施例中,开发人员可以通过对配置文件进行配置,选择不同的序列化方式,本实施例可以通过配置类来区别序列化方式。本实施例提供的多种序列化方式,为开发人员提供了多种选择,开发人员可以根据不同的场景需求选择合适的序列化方式,提高了请求指令处理的方法的适应性。In some of these embodiments, serialization includes at least one of: fastjson serialization, kryo serialization, and JDK serialization. Among them, kryo serialization is fast, the size of the serialized data is small, and the performance is good, but the compatibility of kryo serialization is not the best, and cannot support the serialization of all objects; fastjson has better and stable performance; JDK serialization The speed is the slowest, but the stability is the best. In this embodiment, the developer can select different serialization methods by configuring the configuration file, and in this embodiment, the serialization methods can be distinguished by configuring classes. The multiple serialization methods provided in this embodiment provide developers with multiple choices, and developers can choose appropriate serialization methods according to different scenario requirements, which improves the adaptability of the method for processing request instructions.

本实施例还提供了另一种请求指令处理的方法。在注解为第二注解的情况下,图3是根据本申请实施例的另一种请求指令处理的方法的流程图,如图3所示,该方法包括如下步骤:This embodiment also provides another method for requesting instruction processing. When the annotation is the second annotation, FIG. 3 is a flowchart of another method for requesting instruction processing according to an embodiment of the present application. As shown in FIG. 3 , the method includes the following steps:

步骤S301,加载lua脚本,在Redis缓存中获取分布式锁,该第二注解的配置属性包括可重入锁次数和间隔时间,本实施例中的第二注解可以为CacheLock,该注解可以实现对请求指令添加分布式锁。其中,分布式锁为控制分布式系统之间同步访问共享资源的一种方式。本实施例中,注解CacheLock的可配置属性包括key、expire、retry Times和waitTime,其中,key为Redis缓存的key,expire为过期时间,通常情况下,默认为60s,retryTimes为可重入锁次数,表示分布式锁的重试次数,waitTime为间隔时间,表示两次重试的间隔时长。Step S301, load the lua script, obtain the distributed lock in the Redis cache, the configuration attributes of the second annotation include the number of reentrant locks and the interval time, the second annotation in this embodiment can be CacheLock, and the annotation can The request directive adds distributed locks. Among them, distributed locks are a way to control synchronous access to shared resources between distributed systems. In this embodiment, the configurable attributes of the annotation CacheLock include key, expire, retry Times and waitTime, where key is the key of the Redis cache, expire is the expiration time, usually, the default is 60s, and retryTimes is the number of reentrant locks , indicating the number of retries of the distributed lock, and waitTime is the interval time, indicating the length of the interval between two retries.

lua脚本可以灵活嵌入应用程序中,从而为应用程序提供灵活的扩展和定制功能,本实施例中,lua脚本是为了在Redis缓存进行操作时,保证分布式锁的原子性,其中,原子性为表示组成一个事务的多个数据库操作是一个不可分割的原子单元,只有所有的操作执行成功,整个事务才提交,事务中任何一个数据库操作失败,已经执行的所有操作都必须被撤销,让数据库返回初始状态。The lua script can be flexibly embedded in the application program, so as to provide flexible extension and customization functions for the application program. In this embodiment, the lua script is used to ensure the atomicity of the distributed lock when the Redis cache operates, where the atomicity is Indicates that multiple database operations that make up a transaction are an indivisible atomic unit. Only when all operations are executed successfully, the entire transaction is committed. If any database operation in the transaction fails, all operations that have been performed must be undone and the database returns. initial state.

步骤S302,在该Redis缓存中存在该分布式锁的情况下,不对该请求指令进行处理,或者,在该Redis缓存中不存在该分布式锁的情况下,从存储介质中获取该请求指令的返回值,将该分布式锁进行释放。在Redis缓存中存在分布式锁的情况下,说明分布式锁被其他线程占用,本实施例的请求指令需要等待处理,在Redis缓存中不存在分布式锁的情况下,本实施例中的请求指令获取分布式锁,在获取到返回值之后,再将分布式锁进行释放。Step S302, in the case that the distributed lock exists in the Redis cache, do not process the request instruction, or, in the case that the distributed lock does not exist in the Redis cache, obtain the request instruction from the storage medium. Return value to release the distributed lock. In the case that there is a distributed lock in the Redis cache, it means that the distributed lock is occupied by other threads, and the request instruction in this embodiment needs to be processed. The instruction acquires the distributed lock, and after the return value is acquired, the distributed lock is released.

通过上述步骤S301和步骤S302,本实施例中的注解可以实现分布式锁的功能,基于lua脚本保证分布式锁的原子性,减少接入缓存的代码量。Through the above steps S301 and S302, the annotation in this embodiment can realize the function of a distributed lock, ensure the atomicity of the distributed lock based on the lua script, and reduce the amount of code to access the cache.

在其中一些实施例中,在注解为第三注解的情况下,对请求指令进行处理包括:在Redis缓存中,删除键值对,其中,该键值对的键为该第三注解标注的键。本实施例中的第三注解可以为CacheDel,该第三注解作用于请求指令上,可以将与第三注解对应的缓存删除,然后在存储介质中获取请求指令的返回值。第三注解的配置属性可以为keyHeads,其中,keyHeads为key的前缀集合,可以配置多个key,删除多个缓存,以在Redis缓存中删除不必要的数据,节约存储空间。In some of the embodiments, when the annotation is the third annotation, processing the request instruction includes: in the Redis cache, deleting a key-value pair, where the key of the key-value pair is the key marked by the third annotation . The third annotation in this embodiment may be CacheDel, the third annotation acts on the request instruction, and the cache corresponding to the third annotation may be deleted, and then the return value of the request instruction is obtained in the storage medium. The configuration attribute of the third annotation can be keyHeads, where keyHeads is a prefix set of keys, multiple keys can be configured, and multiple caches can be deleted to delete unnecessary data in the Redis cache and save storage space.

在其中一些实施例中,在注解为第四注解的情况下,对请求指令进行处理包括:获取第四注解,该第四注解标注的参数用于组装Redis缓存中的键。本实施例中的第四注解可以为KeyParam,该第四注解作用于请求指令的参数上,可以设置实际的参数key。在请求指令包括参数的情况下,至少需要一个参数配置KeyParam,keyHead可以设置该请求指令的前缀,实际的key还会组装使用了该KeyParam注解的参数值。其中,KeyParam的配置属性可以包括order、returnClassValueType和returnClassType。其中,order为参数值作为key时的排序,returnClassValueType为在返回值与classType的下标对应的情况下,表示参数值为classValueType的值时,返回参数为classType,returnClassType表示返回值的类型。其中,returnClassValueType与returnClassType可以在返回值为父类的情况下,区分实际的返回类型。In some of the embodiments, when the annotation is the fourth annotation, processing the request instruction includes: obtaining the fourth annotation, and the parameter marked by the fourth annotation is used to assemble the key in the Redis cache. The fourth annotation in this embodiment may be KeyParam, and the fourth annotation acts on the parameter of the request instruction, and can set the actual parameter key. When the request command includes parameters, at least one parameter is required to configure KeyParam, keyHead can set the prefix of the request command, and the actual key will also assemble the parameter value annotated with the KeyParam. The configuration properties of KeyParam may include order, returnClassValueType and returnClassType. Among them, order is the order when the parameter value is used as the key, returnClassValueType is when the return value corresponds to the subscript of classType, when the parameter value is the value of classValueType, the return parameter is classType, and returnClassType indicates the type of the return value. Among them, returnClassValueType and returnClassType can distinguish the actual return type when the return value is the parent class.

在其他实施例中,在请求指令不包括参数的情况下,不需要进行KeyParam的配置。In other embodiments, when the request instruction does not include parameters, it is not necessary to configure the KeyParam.

在其中一些实施例中,缓存抽象接口的配置参数包括过期时间。本实施例中,缓存抽象接口的过期时间可以在注解中设置,也可以设置为默认值,在对请求指令处理的过程中,可以通过请求指令的注解获取过期时间,在过期时间到达之后,无法在缓存里使用与过期时间对应的键值对。本实施例中通过设置过期时间,可以节省缓存空间,同时避免脏数据。In some of these embodiments, the configuration parameters of the cache abstraction interface include an expiration time. In this embodiment, the expiration time of the cache abstract interface can be set in the annotation, or can be set as a default value. During the process of processing the request instruction, the expiration time can be obtained through the annotation of the request instruction. After the expiration time arrives, the expiration time cannot be Use the key-value pair corresponding to the expiration time in the cache. In this embodiment, by setting the expiration time, the cache space can be saved, and dirty data can be avoided at the same time.

在其中一些实施例中,在通过拦截器获取请求指令的注解之后,还包括:在注解不能与缓存抽象接口匹配的情况下,在存储介质中获取该请求指令的返回值。其中,“注解不能与缓存抽象接口匹配”具体为缓存抽象接口没有为该注解设置对应的接口,此时,可以直接从存储介质中获取请求指令的返回值。本实施例提供的方法提高了请求指令处理的方法的场景适应性。In some of the embodiments, after obtaining the annotation of the request instruction through the interceptor, the method further includes: in the case that the annotation cannot match the cache abstract interface, obtaining the return value of the request instruction in the storage medium. The "annotation cannot match the cache abstract interface" specifically means that the cache abstract interface does not set a corresponding interface for the annotation. In this case, the return value of the request instruction can be directly obtained from the storage medium. The method provided by this embodiment improves the scene adaptability of the method for processing a request instruction.

需要说明的是,在上述流程中或者附图的流程图中示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。It should be noted that the steps shown in the above flow or the flow chart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical sequence is shown in the flow chart, in the In some cases, steps shown or described may be performed in an order different from that herein.

本实施例还提供了一种请求指令处理的系统,该系统用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”、“单元”、“子单元”等可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。This embodiment also provides a system for processing request instructions, and the system is used to implement the above-mentioned embodiments and preferred implementation manners, which have been described and will not be repeated. As used below, the terms "module," "unit," "subunit," etc. may be a combination of software and/or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.

图4是根据本申请实施例的请求指令处理的系统的结构框图,如图4所示,该系统包括:缓存模块41和核心模块42;该缓存模块41接收请求指令,通过拦截器获取该请求指令的注解;该核心模块42将该注解与缓存抽象接口进行匹配,获取对该请求指令的处理方式,其中,该处理方式与该注解对应;该缓存模块41根据该处理方式对该请求指令进行处理,该核心模块42返回该请求指令的返回值。FIG. 4 is a structural block diagram of a system for processing request instructions according to an embodiment of the present application. As shown in FIG. 4 , the system includes: a cache module 41 and a core module 42; the cache module 41 receives a request instruction and obtains the request through an interceptor The annotation of the instruction; the core module 42 matches the annotation with the cache abstract interface, and obtains the processing method of the request instruction, wherein the processing method corresponds to the annotation; the cache module 41 performs the request instruction according to the processing method. processing, the core module 42 returns the return value of the request instruction.

本实施例通过缓存模块41对请求指令使用的注解进行识别,可以直接进入缓存数据库对请求指令进行处理,开发人员不要再手动编写代码,解决了开发人员需要手动管理缓存和连接缓存数据库,增加开发成本,耗费时间较长,效率较低的问题,实现了缓存数据库的自动管理,提高对请求命令的处理效率,节省时间,同时提高了程序的一致性和规范性。In this embodiment, the cache module 41 identifies the annotation used by the request instruction, and can directly enter the cache database to process the request instruction. The developer does not need to manually write code, which solves the need for the developer to manually manage the cache and connect to the cache database. Cost, time-consuming and low-efficiency problems, realize the automatic management of the cache database, improve the processing efficiency of the request command, save time, and improve the consistency and standardization of the program.

下面结合应用场景对本申请实施例进行描述和说明。The embodiments of the present application are described and illustrated below in combination with application scenarios.

图5是根据本申请实施例的请求指令处理的缓存框架的结构示意图,如图5所示,缓存框架51包括缓存模块41和核心模块42,缓存模块41中包括lua脚本文件、缓存实现、注解、分布式锁实现、分布式锁注解拦截器、缓存注解拦截器、缓存注解处理器和分布式锁注解处理器,核心模块42中包括配置、缓存接口、枚举、异常、注解返回值、序列化实现、工具类和序列化工厂。FIG. 5 is a schematic structural diagram of a cache framework for request instruction processing according to an embodiment of the present application. As shown in FIG. 5 , the cache framework 51 includes a cache module 41 and a core module 42 , and the cache module 41 includes a lua script file, cache implementation, annotations , distributed lock implementation, distributed lock annotation interceptor, cache annotation interceptor, cache annotation processor and distributed lock annotation processor, the core module 42 includes configuration, cache interface, enumeration, exception, annotation return value, sequence implementations, utility classes, and serialization factories.

其中,缓存模块41中的lua脚本文件是为了在Redis缓存中操作时,保证分布式锁的原子性;缓存实现提供了各种序列化方式的缓存实现;注解可以提供给开发人员对请求指令进行处理;分布式锁实现提供了各种序列化方式的分布式锁实现;基于Spring AOP的拦截器,拦截使用了注解的请求指令,包括分布式锁注解拦截器和缓存注解拦截器的拦截器;本实施例提供了多种序列化方式供开发人员选择,处理器是为了处理不同的序列化方式,包括缓存注解处理器和分布式锁处理器。Among them, the lua script file in the cache module 41 is to ensure the atomicity of distributed locks when operating in the Redis cache; the cache implementation provides cache implementations in various serialization methods; annotations can be provided for developers to perform request instructions. Processing; distributed lock implementation provides distributed lock implementation in various serialization methods; Spring AOP-based interceptors intercept request instructions that use annotations, including distributed lock annotation interceptors and cache annotation interceptors; This embodiment provides a variety of serialization methods for developers to choose from, and the processor is to handle different serialization methods, including a cache annotation processor and a distributed lock processor.

其中,核心模块42中的配置,用于配置缓存,例如Redis的地址,端口,密码等配置数据;缓存接口用于定义框架的接口规范,可以提供缓存抽象接口和分布式锁接口;枚举和异常分别定义了枚举类和异常类,可以实现统一代码规范,统一错误码,便于查错;注解返回值便于解析反序列化后的数据;工具类的创建便于代码开发;序列化实现提供了多种序列化方式,例如,jdk序列化、kryo序列化和fastjson序列化,开发人员可以根据实际需求,调用不同的序列化工厂,使用不同的序列化实现。Among them, the configuration in the core module 42 is used to configure the cache, such as Redis address, port, password and other configuration data; the cache interface is used to define the interface specification of the framework, which can provide a cache abstract interface and a distributed lock interface; enumeration and Exception defines an enumeration class and an exception class respectively, which can implement unified code specification, unified error code, and facilitate error checking; annotated return value is convenient for parsing the deserialized data; the creation of tool classes is convenient for code development; serialization implementation provides Multiple serialization methods, such as jdk serialization, kryo serialization and fastjson serialization, developers can call different serialization factories and use different serialization implementations according to actual needs.

本实施例中包括四个缓存抽象接口,第一缓存抽象接口用于设置值,可以设置缓存的key、缓存对象、过期时间和返回对象,第二缓存抽象接口用于设置值,可以设置缓存的key、缓存对象和返回对象,过期时间为默认一个月,第三缓存抽象接口用于获取值,可以设置缓存的key和返回对象,第四缓存抽象接口用于删除值,可以设置缓存的key。通过上述缓存抽象接口,可以使用序列化实现类在获取(get)和设置(set)的过程中,分别进行序列化与反序列化。This embodiment includes four cache abstract interfaces. The first cache abstract interface is used to set the value, and the cache key, cache object, expiration time, and return object can be set. The second cache abstract interface is used to set the value. The expiration time of key, cache object and return object is one month by default. The third cache abstract interface is used to obtain the value, and the cache key and return object can be set. The fourth cache abstract interface is used to delete the value, and the cache key can be set. Through the above cache abstract interface, the serialization implementation class can be used to serialize and deserialize respectively in the process of getting (get) and setting (set).

在对缓存框架51进行使用的过程中,图6是根据本申请优选实施例的请求指令处理的流程图,如图6所示,该方法包括如下步骤:In the process of using the cache framework 51, FIG. 6 is a flowchart of request instruction processing according to a preferred embodiment of the present application. As shown in FIG. 6, the method includes the following steps:

步骤S601,请求指令的注解被缓存模块的拦截器拦截。Step S601, the annotation of the request instruction is intercepted by the interceptor of the cache module.

步骤S602,缓存模块对请求指令的注解进行判断,读取注解的配置属性中的key与过期时间,调用缓存实现类。Step S602, the cache module judges the annotation of the request instruction, reads the key and expiration time in the configuration attribute of the annotation, and calls the cache implementation class.

步骤S603,核心模块调用序列化实现类,设置或读取请求指令的返回值。Step S603, the core module invokes the serialization implementation class to set or read the return value of the request instruction.

步骤S604,核心模块将返回值返回至缓存模块,缓存模块将返回值返回至开发人员业务项目,其中,开发人员业务项目为开发人员对各类业务进行对接和查看的模块。In step S604, the core module returns the return value to the cache module, and the cache module returns the return value to the developer business item, where the developer business item is a module for the developer to connect and view various services.

开发人员在需要用到缓存和分布式锁的请求指令上添加缓存或者分布式锁注解,缓存模块会通过AOP的方式,拦截该请求指令,通过配置的keyHead和参数值组装真正的缓存key,在没有返回值的情况下,会调用原有方法的实现,在Redis缓存中存在返回值的情况下,会直接返回缓存的返回值,而不会继续调用方法的实现。Developers add cache or distributed lock annotations to the request instructions that need to use cache and distributed locks. The cache module will intercept the request instructions through AOP, and assemble the real cache key through the configured keyHead and parameter values. If there is no return value, the implementation of the original method will be called, and if there is a return value in the Redis cache, the cached return value will be returned directly without continuing to call the method implementation.

本实施例提供的框架可以减少开发人员使用缓存的工作量,只需要在请求指令上添加注解,便可以实现缓存,开发人员可以更加专注于业务的开发。进一步地,通过本实施例的框架,开发人员也可以基于框架中的接口,对实现类进行实现,因此本实施例中的框架具有极大的便利性。The framework provided by this embodiment can reduce the workload of developers using the cache, and only need to add annotations to the request instructions to implement the cache, and developers can focus more on business development. Further, through the framework of this embodiment, developers can also implement implementation classes based on interfaces in the framework, so the framework in this embodiment has great convenience.

需要说明的是,上述各个模块可以是功能模块也可以是程序模块,既可以通过软件来实现,也可以通过硬件来实现。对于通过硬件来实现的模块而言,上述各个模块可以位于同一处理器中;或者上述各个模块还可以按照任意组合的形式分别位于不同的处理器中。It should be noted that each of the above modules may be functional modules or program modules, and may be implemented by software or hardware. For the modules implemented by hardware, the above-mentioned modules may be located in the same processor; or the above-mentioned modules may also be located in different processors in any combination.

在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口、显示屏和输入装置。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种请求指令处理的方法。该计算机设备的显示屏可以是液晶显示屏或者电子墨水显示屏,该计算机设备的输入装置可以是显示屏上覆盖的触摸层,也可以是计算机设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。In one embodiment, a computer device is provided, which may be a terminal. The computer equipment includes a processor, memory, a network interface, a display screen, and an input device connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium, an internal memory. The nonvolatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of requesting instruction processing. The display screen of the computer equipment may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment may be a touch layer covered on the display screen, or a button, a trackball or a touchpad set on the shell of the computer equipment , or an external keyboard, trackpad, or mouse.

在一个实施例中,图7是根据本申请实施例的电子设备的内部结构示意图,如图7所示,提供了一种电子设备,该电子设备可以是服务器,其内部结构图可以如图7所示。该电子设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该电子设备的处理器用于提供计算和控制能力。该电子设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该电子设备的数据库用于存储数据。该电子设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种请求指令处理的方法。In one embodiment, FIG. 7 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application. As shown in FIG. 7 , an electronic device is provided. The electronic device may be a server, and its internal structure diagram may be as shown in FIG. 7 . shown. The electronic device includes a processor, memory, network interface and database connected by a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The nonvolatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium. The database of the electronic device is used to store the data. The network interface of the electronic device is used to communicate with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of requesting instruction processing.

本领域技术人员可以理解,图7中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 7 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may be Include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.

在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现上述各实施例提供的请求指令处理的方法中的步骤。In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the processor implements the request instruction processing provided by the above embodiments steps in the method.

在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现上述各个实施例提供的请求指令处理的方法中的步骤。In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, implements the steps in the method for processing a request instruction provided in each of the foregoing embodiments.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,该计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium , when the computer program is executed, it may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other medium used in the various embodiments provided in this application may include non-volatile and/or volatile memory. Nonvolatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Road (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above-described embodiments can be combined arbitrarily. For the sake of brevity, all possible combinations of the technical features in the above-described embodiments are not described. However, as long as there is no contradiction between the combinations of these technical features, All should be regarded as the scope described in this specification.

以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several embodiments of the present application, and the descriptions thereof are relatively specific and detailed, but should not be construed as a limitation on the scope of the invention patent. It should be noted that, for those skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the scope of protection of the patent of the present application shall be subject to the appended claims.

Claims (10)

1.一种请求指令处理的方法,其特征在于,所述方法包括:1. A method for requesting instruction processing, wherein the method comprises: 接收请求指令,通过拦截器获取所述请求指令的注解;Receive the request instruction, and obtain the annotation of the request instruction through the interceptor; 将所述注解与缓存抽象接口进行匹配,获取对所述请求指令的处理方式,其中,所述处理方式与所述注解对应;Matching the annotation with the cache abstract interface to obtain a processing method for the request instruction, wherein the processing method corresponds to the annotation; 根据所述处理方式对所述请求指令进行处理,并返回所述请求指令的返回值。The request instruction is processed according to the processing method, and the return value of the request instruction is returned. 2.根据权利要求1所述的方法,其特征在于,在所述注解为第一注解的情况下,所述根据所述处理方式对所述请求指令进行处理包括以下之一:2 . The method according to claim 1 , wherein, when the annotation is the first annotation, the processing of the request instruction according to the processing method comprises one of the following: 在Redis缓存中存在所述请求指令的返回值的情况下,调用所述Redis缓存,在所述Redis缓存中获取所述请求指令的返回值;In the case that the return value of the request instruction exists in the Redis cache, call the Redis cache, and obtain the return value of the request instruction in the Redis cache; 在所述Redis缓存中不存在所述请求指令的返回值的情况下,在存储介质中获取所述请求指令的返回值,通过序列化将所述返回值设置至所述Redis缓存中,并对所述第一注解的配置属性进行设置。In the case that the return value of the request instruction does not exist in the Redis cache, obtain the return value of the request instruction in the storage medium, set the return value to the Redis cache through serialization, and The configuration properties of the first annotation are set. 3.根据权利要求1所述的方法,其特征在于,在所述注解为第二注解的情况下,所述根据所述处理方式对所述请求指令进行处理包括:3 . The method according to claim 1 , wherein, when the annotation is a second annotation, the processing the request instruction according to the processing method comprises: 3 . 加载lua脚本,在Redis缓存中获取分布式锁,所述第二注解的配置属性包括可重入锁次数和间隔时间;Load the lua script, obtain distributed locks in the Redis cache, and the configuration attributes of the second annotation include the number of reentrant locks and the interval time; 在所述Redis缓存中存在所述分布式锁的情况下,不对所述请求指令进行处理,或者,在所述Redis缓存中不存在所述分布式锁的情况下,从存储介质中获取所述请求指令的返回值,将所述分布式锁进行释放。In the case that the distributed lock exists in the Redis cache, the request instruction is not processed, or, in the case that the distributed lock does not exist in the Redis cache, the request instruction is obtained from the storage medium The return value of the request instruction is requested, and the distributed lock is released. 4.根据权利要求1所述的方法,其特征在于,在所述注解为第三注解的情况下,所述根据所述处理方式对所述请求指令进行处理包括:4 . The method according to claim 1 , wherein, when the annotation is a third annotation, the processing the request instruction according to the processing method comprises: 5 . 在Redis缓存中,删除键值对,其中,所述键值对的键为所述第三注解标注的键。In the Redis cache, delete the key-value pair, wherein the key of the key-value pair is the key marked by the third annotation. 5.根据权利要求1所述的方法,其特征在于,在所述注解为第四注解的情况下,所述根据所述处理方式对所述请求指令进行处理还包括:5 . The method according to claim 1 , wherein, when the annotation is a fourth annotation, the processing the request instruction according to the processing method further comprises: 6 . 获取第四注解,所述第四注解标注的参数用于组装Redis缓存中的键。The fourth annotation is obtained, and the parameters marked by the fourth annotation are used to assemble the keys in the Redis cache. 6.根据权利要求1所述的方法,其特征在于,所述缓存抽象接口的配置参数包括过期时间。6. The method according to claim 1, wherein the configuration parameter of the cache abstract interface includes an expiration time. 7.根据权利要求1所述的方法,其特征在于,在所述通过拦截器获取所述请求指令的注解之后,所述方法还包括:7. The method according to claim 1, characterized in that, after obtaining the annotation of the request instruction through the interceptor, the method further comprises: 在所述注解不能与所述缓存抽象接口匹配的情况下,在存储介质中获取所述请求指令的返回值。In the case that the annotation cannot be matched with the cache abstract interface, the return value of the request instruction is obtained in the storage medium. 8.一种请求指令处理的系统,其特征在于,所述系统包括:缓存模块和核心模块;8. A system for requesting instruction processing, wherein the system comprises: a cache module and a core module; 所述缓存模块接收请求指令,通过拦截器获取所述请求指令的注解;The cache module receives the request instruction, and obtains the annotation of the request instruction through the interceptor; 所述核心模块将所述注解与缓存抽象接口进行匹配,获取对所述请求指令的处理方式,其中,所述处理方式与所述注解对应;The core module matches the annotation with the cache abstract interface, and obtains a processing method for the request instruction, wherein the processing method corresponds to the annotation; 所述缓存模块根据所述处理方式对所述请求指令进行处理,所述核心模块返回所述请求指令的返回值。The cache module processes the request instruction according to the processing method, and the core module returns a return value of the request instruction. 9.一种计算机设备,包括存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至7中任一项所述方法的步骤。9. A computer device, comprising a memory, a processor and a computer program stored on the memory and running on the processor, wherein the processor implements the computer program as claimed in the claims The steps of any one of 1 to 7. 10.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如权利要求1至7中任一项所述方法的步骤。10. A computer-readable storage medium on which a computer program is stored, characterized in that, when the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
CN202010667873.3A 2020-07-13 2020-07-13 Method, system, computer device, and readable storage medium for requesting instruction processing Pending CN112052263A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010667873.3A CN112052263A (en) 2020-07-13 2020-07-13 Method, system, computer device, and readable storage medium for requesting instruction processing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010667873.3A CN112052263A (en) 2020-07-13 2020-07-13 Method, system, computer device, and readable storage medium for requesting instruction processing

Publications (1)

Publication Number Publication Date
CN112052263A true CN112052263A (en) 2020-12-08

Family

ID=73602395

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010667873.3A Pending CN112052263A (en) 2020-07-13 2020-07-13 Method, system, computer device, and readable storage medium for requesting instruction processing

Country Status (1)

Country Link
CN (1) CN112052263A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540834A (en) * 2020-12-18 2021-03-23 郑州阿帕斯数云信息科技有限公司 Cache processing method, device and equipment in distributed transaction
CN113282626A (en) * 2021-05-31 2021-08-20 平安国际智慧城市科技股份有限公司 Redis-based data caching method and device, computer equipment and storage medium
CN113407553A (en) * 2021-05-14 2021-09-17 重庆锐云科技有限公司 Method, system, equipment and storage medium for realizing distributed lock
CN114020250A (en) * 2021-10-09 2022-02-08 济南浪潮智投智能科技有限公司 Dictionary translation implementation method and system based on AOP, electronic device and storage medium
CN114064523A (en) * 2021-11-19 2022-02-18 杭州安恒信息安全技术有限公司 Data processing method, device and equipment and readable storage medium
CN114579194A (en) * 2022-03-08 2022-06-03 杭州每刻科技有限公司 Spring remote call-based exception handling method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628891A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 Realize method, apparatus, electronic equipment and the readable storage medium storing program for executing of data buffer storage layer
CN109614559A (en) * 2018-11-16 2019-04-12 泰康保险集团股份有限公司 Data processing method and device
CN110020271A (en) * 2017-08-04 2019-07-16 北京京东尚科信息技术有限公司 Method and system for cache management
CN110109983A (en) * 2017-12-29 2019-08-09 北京京东尚科信息技术有限公司 A kind of method and apparatus operating Redis database

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628891A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 Realize method, apparatus, electronic equipment and the readable storage medium storing program for executing of data buffer storage layer
CN110020271A (en) * 2017-08-04 2019-07-16 北京京东尚科信息技术有限公司 Method and system for cache management
CN110109983A (en) * 2017-12-29 2019-08-09 北京京东尚科信息技术有限公司 A kind of method and apparatus operating Redis database
CN109614559A (en) * 2018-11-16 2019-04-12 泰康保险集团股份有限公司 Data processing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
孙滨,李恋,陈强: "《Java EE 入门到实战》", 30 November 2019, 哈尔滨工程大学出版社, pages: 274 *
朱智胜: "《SPRING BOOT技术内幕 架构设计与实现原理》", 30 June 2020, 机械工业出版社, pages: 176 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540834A (en) * 2020-12-18 2021-03-23 郑州阿帕斯数云信息科技有限公司 Cache processing method, device and equipment in distributed transaction
CN112540834B (en) * 2020-12-18 2023-04-14 郑州阿帕斯数云信息科技有限公司 Cache processing method, device and equipment in distributed transaction
CN113407553A (en) * 2021-05-14 2021-09-17 重庆锐云科技有限公司 Method, system, equipment and storage medium for realizing distributed lock
CN113282626A (en) * 2021-05-31 2021-08-20 平安国际智慧城市科技股份有限公司 Redis-based data caching method and device, computer equipment and storage medium
CN114020250A (en) * 2021-10-09 2022-02-08 济南浪潮智投智能科技有限公司 Dictionary translation implementation method and system based on AOP, electronic device and storage medium
CN114064523A (en) * 2021-11-19 2022-02-18 杭州安恒信息安全技术有限公司 Data processing method, device and equipment and readable storage medium
CN114579194A (en) * 2022-03-08 2022-06-03 杭州每刻科技有限公司 Spring remote call-based exception handling method and system
CN114579194B (en) * 2022-03-08 2024-04-05 杭州每刻科技有限公司 Exception handling method and system based on Spring remote call

Similar Documents

Publication Publication Date Title
CN112052263A (en) Method, system, computer device, and readable storage medium for requesting instruction processing
US10970277B2 (en) System and method for dynamic conversion of database accessing scripts during runtime in a mainframe rehosting platform
US10706166B1 (en) Application specific schema extensions for a hierarchical data structure
WO2019136800A1 (en) Service processing method, apparatus and device, and computer-readable storage medium
US10817312B2 (en) Programming model for performant computing in document-oriented storage services
US9104437B2 (en) Efficient serialization of mutable objects
US11595299B2 (en) System and method of suppressing inbound payload to an integration flow of an orchestration based application integration
CN112867999B (en) Version-based table locking
CN111198751A (en) Service processing method and device
US11836116B2 (en) Managing operations between heterogeneous file systems
US10379914B2 (en) System and method for achieving specific behaviors by intercepting file access calls in a mainframe rehosting platform
CN112579698B (en) Data synchronization method, device, gateway equipment and storage medium
US10977223B2 (en) Data storage method and system
WO2019205365A1 (en) Method and apparatus for loading dom node data, and computer device and storage medium
CN113806655A (en) Data processing method, device, electronic device and storage medium
CN112347794B (en) Data translation method, device, equipment and computer storage medium
WO2023124422A1 (en) Data read-write control method and electronic device
US9473565B2 (en) Data transmission for transaction processing in a networked environment
WO2023273028A1 (en) Transaction processing method and related product
CN112395437B (en) 3D model loading method and device, electronic equipment and storage medium
CN117807115A (en) Data processing method, device, equipment and storage medium
CN114637969A (en) Authentication method and device for target object
CN114879978A (en) Software package dependency processing method, computing device and readable storage medium
CN114003608A (en) Form data temporary storage method, server, terminal device and storage medium
US20150058071A1 (en) System and method for object lock management using cached lock objects

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20201208

RJ01 Rejection of invention patent application after publication