Data processing method and device, storage medium and electronic device

By using aspect-oriented programming, caching operations are extracted into aspects, and the target program code is marked with annotations to dynamically calculate cache keys. This solves the data caching limitations of the MyBatis framework in non-database scenarios, achieving more efficient caching operations and wider applicability.

CN114510301BActive Publication Date: 2025-10-24NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210147798.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-17
Publication Date
2025-10-24
Estimated Expiration
2042-02-17

AI Technical Summary

Technical Problem

The existing MyBatis framework is designed specifically for database access, which results in significant limitations in data caching and makes it difficult to apply in other data processing scenarios.

Method used

Aspect-Oriented Programming (AOP) extracts caching operations into aspects, uses annotations to mark target program code, dynamically calculates cache keys, writes the results to storage space after method execution, and reads the cached results from storage space before the next execution, providing a unified object storage operation interface and marking method.

Benefits of technology

It reduces the limitations of data caching, reduces code duplication, improves development efficiency and adaptability, and is suitable for various data access scenarios and object storage methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114510301B_ABST
    Figure CN114510301B_ABST
Patent Text Reader

Abstract

The application discloses a data processing method and device, a storage medium and an electronic device. The method comprises the following steps: detecting a target program code to be executed; in response to the target program code being identified by a corresponding first target identifier and the execution result of the target program code not being called from a target storage space, executing the target program code to obtain the execution result; and writing the execution result into the target storage space as to-be-called data of to-be-executed program code associated with the target program code. The application solves the technical problem of large limitation of data caching.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of data processing, and in particular, to a data processing method and device, a storage medium and an electronic device. BACKGROUND

[0002] At present, when data is stored, a MyBatis caching method can be used. The method abstracts the object storage at the bottom layer, and the storage object can be replaced at any time.

[0003] However, the above method is specially designed for the MyBatis framework, which can only be used when database access is performed through the MyBatis framework, and other frameworks may also be used in data processing scenarios, such as a service framework (Hibernate) for object-relational persistent storage and query, a MyBatis enhancement tool (MyBatisPlus), a framework for implementing a storage repository based on a Java persistence interface (SpringDataJPA), and the like. Therefore, it is difficult to adapt to other data processing scenarios by using only MyBatis, thereby making the data caching limited.

[0004] At present, no effective solution has been proposed for the above problem of limited data caching. SUMMARY

[0005] Embodiments of the present application at least partially solve the technical problem of limited data caching.

[0006] In order to achieve the above purpose, according to one embodiment of the present application, a data processing method is provided. The method can be applied to a storage operation module obtained by aspect-oriented programming, and the method can include: detecting a target program code to be executed; in response to the target program code being identified by a corresponding first target identifier, and determining that the execution result of the target program code is not called from a target storage space, executing the target program code to obtain an execution result; and writing the execution result to the target storage space as to-be-called data of a to-be-executed program code associated with the target program code.

[0007] Optionally, the target parameter is obtained based on the first target identifier; and the determination that the execution result is not called from the target storage space includes: determining that the execution result is not called from the target storage space based on the target parameter.

[0008] Optionally, determining that the execution result is not invoked from the target storage space based on the target parameter comprises: determining a cache key based on a key parameter in the target parameter; and determining that the execution result is not invoked from the target storage space in response to a value corresponding to the cache key not being stored in the target storage space.

[0009] Optionally, after executing the target program code to obtain the execution result, the method further comprises: in response to the target parameter comprising a target value, prohibiting writing the execution result into the target storage space.

[0010] Optionally, in response to the value corresponding to the cache key being stored in the target storage space, invoking the value corresponding to the cache key from the target storage space, and determining the value corresponding to the cache key as the execution result invoked from the target storage space.

[0011] Optionally, determining that the execution result is not invoked from the target storage space based on the target parameter comprises: in response to obtaining a cache context bound to the target program code, and the cache context declaring that the execution result of the target storage space is allowed to be used, determining that the execution result is not invoked from the target storage space based on the target parameter, wherein the cache context is used to represent writing the execution result into the target storage space.

[0012] Optionally, the binding relationship between the target program code and the cache context is established based on a thread local variable.

[0013] Optionally, after executing the target program code to obtain the execution result, the method further comprises: canceling the binding relationship between the target program code and the cache context.

[0014] Optionally, the cache context is generated based on a second target identifier, wherein the second target identifier is used to declare a cache entry, and the cache entry is used to determine the target storage space.

[0015] Optionally, determining that the execution result of the target program code is not invoked from the target storage space comprises: in response to not obtaining a cache context bound to the target program code, or obtaining the cache context bound to the target program code and the cache context declaring that the execution result of the target storage space is prohibited to be used, determining that the execution result is not invoked from the target storage space, wherein the cache context is used to represent writing the execution result into the target storage space.

[0016] Optionally, in response to identifying a third target identifier corresponding to the target program code, the execution result is read from the target storage space, wherein the third target identifier is used to declare that the execution result is read from the target storage space.

[0017] Optionally, the writing the execution result into the target storage space comprises: in response to identifying a fourth target identifier corresponding to the target program code, writing the execution result into the target storage space, wherein the fourth target identifier is used to declare writing the execution result into the target storage space.

[0018] Optionally, the deleting the execution result from the target storage space comprises: in response to identifying a fifth target identifier corresponding to the target program code, deleting the execution result from the target storage space, wherein the fifth target identifier is used to declare deleting the execution result from the target storage space.

[0019] Optionally, the target storage space is a first cache storage space.

[0020] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a data processing apparatus is further provided. The apparatus can be applied to a storage operation module obtained by aspect-oriented programming, and can comprise: a detection unit configured to detect a target program code to be executed at a current time; an execution unit configured to execute the target program code to obtain an execution result in response to the target program code being identified by a corresponding first target identifier and determining that the execution result of the target program code is not called from a target storage space; and a writing unit configured to write the execution result into the target storage space as to-be-called data of to-be-executed program code associated with the target program code.

[0021] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a computer readable storage medium is further provided. The computer readable storage medium stores a computer program, wherein the computer program controls a device where the computer readable storage medium is located to execute the data processing method of the embodiments of the present application when the computer program is run by a processor.

[0022] In order to achieve the above-mentioned purpose, according to another aspect of the present application, an electronic device is further provided. The electronic device can comprise a memory and a processor, and is characterized in that the memory stores a computer program, and the processor is configured to run the computer program to execute the data processing method of the embodiments of the present application.

[0023] In the embodiment of the present application, the target program code currently to be executed is detected; in response to the target program code being identified by a corresponding first target identifier and it being determined that the execution result of the target program code is not called from the target storage space, the target program code is executed to obtain an execution result; and the execution result is written into the target storage space as to-be-called data of the to-be-executed program code associated with the target program code. That is, on the basis of extracting the cached processing operation to the aspect of the aspect programming, the present application uses the manner of marking the target program code to write the execution result of the target program code into the target storage space after the execution result of the target program code is returned; and reads the cached execution result from the target storage space before the target program code is executed next time and returns the execution result to the upper-layer method call, so as to realize the technical effect of reducing the limitation of data caching and solve the technical problem of large limitation of data caching. BRIEF DESCRIPTION OF DRAWINGS

[0024] The accompanying drawings, which are included to provide a further understanding of the present application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and serve to explain the present application, and do not limit the present application in any manner. In the drawings:

[0025] Figure 1 is a hardware structure block diagram of a mobile terminal according to a data processing method of one embodiment of the present application;

[0026] Figure 2 is a flow chart of a data processing method according to one embodiment of the present application;

[0027] Figure 3 is a schematic diagram of a data processing component module according to one embodiment of the present application;

[0028] Figure 4 is a schematic diagram of an entry definition cache operation annotation class diagram according to one embodiment of the present application;

[0029] Figure 5 is a schematic diagram of a read cache operation annotation class diagram according to one embodiment of the present application;

[0030] Figure 6 is a schematic diagram of a write cache operation class diagram according to one embodiment of the present application;

[0031] Figure 7 is a schematic diagram of a delete cache operation annotation class diagram according to one embodiment of the present application;

[0032] Figure 8 is a schematic diagram of a read-write cache operation annotation class diagram according to one embodiment of the present application;

[0033] Figure 9 is a schematic diagram of an entry definition cache operation annotation marking method according to an embodiment of the present application;

[0034] Figure 10 is a schematic diagram of a read-write cache operation annotation marking method according to an embodiment of the present application;

[0035] Figure 11 is a structural block diagram of a data processing device according to an embodiment of the present application. DETAILED DESCRIPTION

[0036] In order to make the personnel in the technical field better understand the present application scheme, the technical scheme in the embodiment of the present application will be described clearly and completely in the following with reference to the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, not all. Based on the embodiment in the present application, all other embodiments obtained by the person skilled in the art without creative labor should belong to the scope of protection of the present application.

[0037] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0038] According to an embodiment of the present application, an embodiment of a data processing method is provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in a different order.

[0039] The method embodiment can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking the running on the mobile terminal as an example, the mobile terminal can be a smart phone (such as Android phone, iOS phone, etc.), tablet computer, palm computer and mobile internet device (Mobile Internet Devices, abbreviated as MID), PAD, game console and other terminal devices. Figure 1FIG. 1 is a hardware structure diagram of a mobile terminal according to a data processing method of an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 (the processor 102 may include but is not limited to a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a field-programmable logic device (FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. Optionally, the mobile terminal may further include a transmission device 106 for communication functions, an input and output device 108, and a display device 110. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0040] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data processing method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned data processing method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0041] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by the mobile terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0042] The input in the input / output device 108 can come from a plurality of human interface devices (HID). For example: keyboard and mouse, gamepad, other special game controllers (such as steering wheel, fishing rod, dance mat, remote control, etc.). Some human interface devices can provide input functions in addition to providing output functions, for example: force feedback and vibration of gamepad, audio output of controller, etc.

[0043] The display device 110 can be, for example, a head-up display (HUD), a touch screen liquid crystal display (LCD), and a touch display (also referred to as "touch screen" or "touch display screen"). The liquid crystal display can enable a user to interact with the user interface of the mobile terminal. In some embodiments, the above-mentioned mobile terminal has a graphical user interface (GUI), and the user can interact with the GUI through finger contact and / or gestures on the touch-sensitive surface. The human-computer interaction function can optionally include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interface, playing digital video, playing digital music, and / or web browsing, etc. The executable instructions for performing the above human-computer interaction functions are configured / stored in one or more computer program products or readable storage media executable by the processor.

[0044] In the present embodiment, a data processing method running on the above-mentioned mobile terminal is provided. The method is applied to a storage operation module obtained by aspect-oriented programming. The aspect-oriented programming can be referred to as Aspect Oriented Programming, which can be represented by AOP. Figure 2 A flowchart of a data processing method according to an embodiment of the present application is shown in FIG. 2, which includes the following steps: Figure 2

[0045] In step S202, the target program code currently to be executed is detected.

[0046] In the technical solution provided in the above step S202 of the present application, the target program code currently to be executed is detected, wherein the target program code can be the program code currently selected by the user, and can be a code line.

[0047] In step S204, the target program code is identified by the corresponding first target identifier in response to the target program code, and it is determined that the execution result of the target program code is not called from the target storage space. The target program code is executed to obtain the execution result.

[0048] ​In the technical solution provided in the step S204 of the present application, the target program code currently selected is determined, the target program code is identified by the corresponding first target identifier, and it is determined whether the execution result of the target program code is invoked from the target storage space. If the execution result of the target program code is not invoked from the target storage space, the target program code is executed to obtain the execution result, wherein the first target identifier can be referred to as an annotation mark corresponding to the program code; the target storage space can be a memory space; and the execution result can be represented by value.

[0049] Optionally, the target program code currently selected is determined, the first target identifier corresponding to the target program code currently selected is identified, the target program code is identified by the first target identifier corresponding to the target program code, and it is determined whether the execution result of the target program code is invoked from the target storage space. If the execution result of the target program code is not invoked from the target storage space, the target program code is executed, and the execution result can be determined according to the parameters of the first target identifier corresponding to the target program code.

[0050] In the technical solution provided in the step S206 of the present application, the execution result is written into the target storage space as the to-be-invoked data of the to-be-executed program code associated with the target program code, wherein the to-be-executed program code can be the program code used by the upper-layer method, i.e., the program code used by the invoker.

[0051] In the technical solution provided in the step S206 of the present application, the execution result is written into the target storage space as the to-be-invoked data of the to-be-executed program code associated with the target program code, wherein the to-be-executed program code can be the program code used by the upper-layer method, i.e., the program code used by the invoker.

[0052] Optionally, the target program code is executed to obtain the execution result, the execution result is written into the target storage space as the to-be-invoked data of the to-be-executed program code associated with the target program code, and the to-be-invoked data of the to-be-executed program code is read from the target storage space when the target program code is executed next time, and the to-be-invoked data is returned to the upper-layer method for invocation.

[0053] By the above steps S202 to S206 of the present application, the target program code to be executed is detected; in response to the target program code being identified by the corresponding first target identifier and it being determined that the execution result of the target program code is not called from the target storage space, the target program code is executed to obtain the execution result; and the execution result is written to the target storage space as the to-be-called data of the to-be-executed program code associated with the target program code. That is, on the basis of extracting the cached processing operation to the aspect of the aspect programming, the present application uses the way of marking the target program code to write the execution result of the target program code to the target storage space after the execution result of the target program code is returned; and reads the cached execution result from the target storage space before the target program code is executed next time and returns it to the upper-layer method call, thereby realizing the technical effect of reducing the limitation of data caching and solving the technical problem of large limitation of data caching.

[0054] The above method of the embodiment will be further introduced below.

[0055] As an optional implementation, the target parameter is obtained based on the first target identifier; and in step S204, determining that the execution result is not called from the target storage space includes: determining that the execution result is not called from the target storage space based on the target parameter.

[0056] In the embodiment, the first target identifier is parsed to obtain the target parameter, and it is determined whether the execution result corresponding to the target parameter exists. If not, it is determined that the target parameter is not called from the target storage space. The target parameter can be a parameter used when the operation is cached, which can be a key expression, a key evaluator, a cache validity period, etc.

[0057] Optionally, the first target identifier (annotation parameter) is parsed to obtain the target parameter used when the operation of the marked method is cached, such as a key expression, a key evaluator, a cache validity period, etc. By determining the key expression, the key evaluator, the cache validity period and other data, it is determined that the execution result corresponding to the target parameter does not exist, so as to determine that the target parameter is not called from the target storage space.

[0058] As an optional implementation, determining that the execution result is not called from the target storage space based on the target parameter includes: determining a cache key based on a key parameter in the target parameter; and in response to the value corresponding to the cache key not being stored in the target storage space, determining that the execution result is not called from the target storage space.

[0059] In this embodiment, a key parameter in the target parameter is determined, a cache key is determined based on the key parameter in the target parameter, and if the value corresponding to the cache key is not stored in the target storage space, it is determined that the execution result is not invoked from the target storage space. The key parameter can be a key expression and a key evaluator, and the cache key can be a cache key of a real operation calculated according to the key expression and the key evaluator.

[0060] Optionally, the key parameter of the real operation (the cache key) is calculated according to the key parameter (the key expression and the key evaluator), the calculated cache key parameter is read, and it is determined whether the value corresponding to the key parameter exists in the target storage space. If the value corresponding to the cache key is not stored in the target storage space, it is determined that the execution result is not invoked from the target storage space.

[0061] As an optional implementation, after the target program code is executed to obtain the execution result, the method further includes: in response to the target parameter including a target value, the execution result is prohibited from being written into the target storage space.

[0062] In this embodiment, after the execution result is obtained, it is determined whether the target value is included in the target parameter before the execution result is written into the target storage space. If the target value is included, the execution result is prohibited from being written into the target storage space. The target value can be an invalid value (a null value) returned by a marked method.

[0063] Optionally, before the execution result is written into the target storage space, it is determined whether the target value (an invalid value returned by a marked method) is included in the target parameter. If the invalid value returned by the marked method is configured to be ignored in the target parameter, the write cache operation is stopped, so as to achieve the purpose of prohibiting the execution result from being written into the target storage space.

[0064] As an optional implementation, in response to the value corresponding to the cache key being stored in the target storage space, the value corresponding to the cache key is invoked from the target storage space, and the value corresponding to the cache key is determined as the execution result invoked from the target storage space.

[0065] In this embodiment, it is determined whether the value corresponding to the cache key is stored in the target storage space. If the value corresponding to the cache key is stored in the target storage space, the value corresponding to the cache key is invoked from the target storage space, and the value corresponding to the cache key is determined as the execution result invoked from the target storage space.

[0066] Optionally, the target program code is selected, a first target identifier corresponding to the selected target program code is parsed to obtain a target parameter, a key parameter in the target parameter is determined, a cache key is determined based on the key parameter in the target parameter, if a value corresponding to the cache key is stored in a target storage space, the value corresponding to the cache key is called from the target storage space, and the value corresponding to the cache key is determined as an execution result called from the target storage space, so that the cached value can be directly used, thereby effectively reducing the method call and improving the program running speed.

[0067] As an optional implementation, the execution result not being called from the target storage space is determined based on the target parameter, including: in response to obtaining a cache context bound to the target program code, and the cache context declaring that the execution result of the target storage space is allowed to be used, the execution result not being called from the target storage space is determined based on the target parameter, wherein the cache context is used to represent that the execution result is written into the target storage space.

[0068] In this embodiment, the target program code is bound to a cache context, the cache context bound to the selected target program code is obtained, if the cache context declares that the execution result of the target storage space is allowed to be used, it is determined that the execution result is not called from the target storage space, wherein the cache context can include relevant data such as a cache entry method and a cache operation manager, and can be used to represent that the execution result is written into the target storage space.

[0069] Optionally, the cache context bound to the target program code is obtained, which can be the position of the cache entry method stack frame in the method call stack, the cache key resolver configuration, the cache read-write configuration and the like, and whether the cache context declares that the execution result of the target storage space is allowed to be used can be determined based on the cache key resolver configuration information in the obtained cache context, if the execution result of the target storage space is allowed to be used, it is determined that the execution result is not called from the target storage space.

[0070] As an optional implementation, the binding relationship between the target program code and the cache context is established based on a thread local variable.

[0071] In this embodiment, the binding relationship between the target program code and the cache context is established by referencing the thread local variable, wherein the thread local variable is a variable reference, which can be used to ensure that different variable instances referenced when different target program codes access the variable do not affect each other. If a cache context exists before this method is entered, the binding with the previous cache context is released.

[0072] Optionally, before the binding relationship between the target program code and the cache context is established, if there is another cache context before the target program code, the binding relationship with the previous cache context is released first.

[0073] As an optional implementation, after the target program code is executed to obtain the execution result, the method further includes: releasing the binding relationship between the target program code and the cache context.

[0074] In this embodiment, after the target program code is executed to obtain the execution result, the current cache context is cleaned up, including releasing the binding relationship between the cache context and the current target program code, and if there is a cache context before the execution of the target program code, the previous cache context is bound to the current target program code.

[0075] As an optional implementation, the cache context is generated based on a second target identifier, wherein the second target identifier is used to declare a cache entrance, and the cache entrance is used to determine a target storage space.

[0076] In this embodiment, the cache context is generated based on a second target identifier, wherein the second target identifier can be a cache entrance annotation, which is used to declare a cache entrance; and the cache entrance is used to determine a target storage space, which can be represented by L1CacheEntrance.

[0077] Optionally, if the target program has a second target identifier, it will be processed by the aspect module.

[0078] Optionally, in the same method call stack, the second target identifier can appear repeatedly on different target program codes, and when it appears repeatedly, the target program code of the upper layer method will cover the target program code of the lower layer method, and the second target identifier of the upper layer target program code can select to disable the first-level cache or inherit the configuration of the first-level cache in the lower layer stack frame, wherein the upper layer can represent the caller, and the lower layer can represent the callee.

[0079] As an optional implementation, in step S204, determining that the execution result of the target program code is not called from the target storage space includes: in response to that the cache context bound by the target program code is not obtained, or the cache context bound by the target program code is obtained and the cache context declares to prohibit the use of the execution result of the target storage space, determining that the execution result is not called from the target storage space, wherein the cache context is used to represent that the execution result is written to the target storage space.

[0080] In this embodiment, if the cache context bound by the target program code is not acquired, or the cache context bound by the target program code is acquired and the cache context declares that the execution result of the target storage space is prohibited from being used, it can be determined that the execution result is not called from the target storage space, and the data in the cache context can be used to write the execution result to the target storage space.

[0081] Optionally, if the cache context bound by the target program code does not exist, or the cache context declares that the execution result of the target storage space is prohibited from being used, it can be determined that the execution result is not called from the target storage space.

[0082] As an optional implementation, in response to identifying the third target identifier corresponding to the target program code, the execution result is read from the target storage space, wherein the third target identifier is used to declare that the execution result is read from the target storage space.

[0083] In this embodiment, the third target identifier corresponding to the target program code is identified, and the execution result is read from the target storage space, wherein the third target identifier can be represented by L1CacheRead, and can also be called read operation cache, and can be used to declare that the execution result is read from the target storage space.

[0084] Optionally, the third target identifier corresponding to the target program code is identified, and the execution result is read from the target storage space, and if the execution result exists, it is directly returned to the upper method call; if not, the target program code is executed.

[0085] As an optional implementation, in step S206, the execution result is written to the target storage space, including: in response to identifying the fourth target identifier corresponding to the target program code, the execution result is written to the target storage space, wherein the fourth target identifier is used to declare that the execution result is written to the target storage space.

[0086] In this embodiment, the target identifier of the target program code is identified, and when the fourth target identifier is identified, the execution result is written to the target storage space, wherein the fourth target identifier can be L1CacheWrite, and can also be called write operation cache, and can be used to declare that the execution result is written to the target storage space. The validity duration of the execution result in the target storage space can be controlled through the annotation parameter in the fourth target identifier, and if it is not declared, the execution result will always be valid before the target program code exits the call.

[0087] As an optional implementation, in response to identifying the fifth target identifier corresponding to the target program code, the execution result is deleted from the target storage space, wherein the fifth target identifier is used to declare that the execution result is deleted from the target storage space.

[0088] In this embodiment, the target identification of the target program code is identified, and when the fifth target identification is identified, the execution result is deleted from the target storage space, wherein the fifth target identification can be L1CacheDelete, also known as delete operation cache, which can be used to declare that the execution result will be deleted from the target storage space.

[0089] Optionally, the fifth target identification declares to delete the cache operation, and the execution result corresponding to the specified target program code in the target storage space can be cleaned up. The execution result can be deleted before the target program code is executed or after the method target program code is executed through the parameter control.

[0090] As an optional implementation, the target storage space is a first cache storage space.

[0091] In this embodiment, the target program code to be executed is detected; in response to the target program code being identified by the corresponding first target identification and determining that the execution result of the target program code is not called from the target storage space, the target program code is executed to obtain the execution result; and the execution result is written into the target storage space as the to-be-called data of the to-be-executed program code associated with the target program code. That is, on the basis of extracting the cached processing operation to the aspect of the aspect programming, the execution result of the target program code is written into the target storage space after the execution result of the target program code is returned by using the marking manner of the target program code; and the cached execution result is read from the target storage space before the target program code is executed next time, and is returned to the upper method call, so that the technical effect of reducing the limitation of data caching is realized, and the technical problem of large limitation of data caching is solved.

[0092] The technical solutions of the embodiments of the present application will be further introduced with reference to the preferred embodiments.

[0093] In the current Internet application design, in order to realize the rapid migration of data between devices, a scheme of storing data on the server and requesting the server interface for data read and write on the client is often used, that is, a single server application provides services to multiple client applications, and the commonly used data persistence middleware of the server is generally a database, and the data is stored on the external storage of the computer, such as a mechanical hard disk, a solid state disk, etc. However, compared with memory access, external storage access speed is generally lower, generally 1 to 2 orders of magnitude lower, for example, the read and write speed of the mainstream fifth-generation double data rate synchronous dynamic random access memory (DDR5 SDRAM) is above 100 GB / s, and the read and write speed of a good solid state disk is only about 3 GB / s. Therefore, when the read request is frequent, the request processing capability of the server is limited by the read operation of the database, and the disk access becomes the bottleneck of the server concurrency capability, so in order to improve the speed of reading data, the server often uses memory cache to reduce the number of data read access.

[0094] There are two common memory cache implementation schemes: one is the memory cache in the process of processing a single request, which can be called first-level cache; the other is the memory cache in the entire application range, which is not limited to a single request, called second-level cache, which is also a general cache.

[0095] The second-level cache is effective for different requests, that is, a read request causes data to be read from the database, and this part of data is written to the cache, and other read requests can also hit the cache and do not need to read the database, thereby effectively reducing the request processing time. However, in some scenarios, only data caching within the current request range is desired, for example, for data with more writes and less reads, it is desired that the cache be hit when reading data multiple times in a request processing process to improve read operation speed, but because the data is volatile, it is desired that other requests read the latest data. In this scenario, if a second-level cache is used for processing, it will cause frequent read and write of the cache, and the second-level cache is generally implemented using a distributed cache middleware, such as Redis and MemCached. Frequent cache read and write will generate network overhead, and in complex network environments, it may be more time-consuming than directly reading the database. Therefore, data with more writes and less reads and scenarios where cache is desired are more suitable for first-level cache, not only database access, but also scenarios of remote invocation between services.

[0096] Common existing first-level cache has high-performance cache (CaffeineCache), distributed cache (EhCache), persistence framework first-level cache (MyBatis) and the like.

[0097] The distributed cache is an object storage scheme, which can serialize the object data during the program running into a binary data stream and then store it. The distributed cache supports setting the expiration time of object storage, object cleaning strategy and the like. In addition, when the memory is insufficient to store a large amount of data, the distributed cache also supports using the disk as the swap area of the cold data that is not frequently used, thereby improving the upper limit of the storage capacity.

[0098] The high-performance cache is similar to the distributed cache, which is an object storage technology, supports setting the storage expiration time and object cleaning strategy, but does not support storage to a file.

[0099] The persistence framework first-level cache is an upper-layer cache technology based on the persistence framework, which focuses on the upper-layer capabilities such as cache reading, writing and cleaning time, and does not care about the implementation details of the underlying object storage. Therefore, the underlying of the persistence framework first-level cache can adapt to multiple object storage schemes, such as the high-performance cache and the distributed cache mentioned above, or even directly use a hash table (HashMap) for storage.

[0100] However, the high-performance cache and the distributed cache belong to the underlying implementation of the first-level cache, and when used, the write and read of the cache need to be manually coded before and after the logic of the program running. The above operation is easy to produce a large amount of repeated code, and the repeated code will reduce the development efficiency, is not conducive to code reading, will distract the attention from the core logic, and a separate implementation of a first-level cache may not adapt to complex and variable running scenarios. When the demand for the first-level cache changes, it becomes extremely difficult to modify the code. For example, a high-performance cache is first selected as the first-level cache in a certain scenario. When the workload increases and the cache data volume increases, the memory resource is insufficient and needs to be switched to a distributed cache for caching, which will need to modify the running process, thereby destroying the open-closed principle in object-oriented programming.

[0101] The first-level cache of the persistence framework abstracts the object storage at the bottom, and can replace the object storage scheme at any time, so that the cache is replaced conveniently, and the first-level cache of the persistence framework encapsulates the write and read operations of the cache, uses computer languages, such as dynamic proxy technology in a development application (Java) language and an AOP programming method without invasion of business logic, avoids manual operation of the first-level cache, and reduces repeated codes. However, the first-level cache of the persistence framework is specially designed for the persistence framework, can be used only when database access is performed through the persistence framework, other frameworks such as Hibernate, persistence framework Plus, SpringDataJPA and the like can be used in a work scene, the limitation is relatively large, and the scene in which the first-level cache is used is not only database access, but also remote procedure call (RPC) in a micro-service architecture. Therefore, the first-level cache of the persistence framework is not applicable when the call result is considered.

[0102] To solve the above problems, an embodiment of the present application provides a first-level cache implementation scheme suitable for various data access scenes and various object storage modes. The scheme provides an abstract interface of object storage operation, the abstract interface is used for shielding implementation details of an underlying object storage scheme, and is used for providing uniform object storage operation functions for an upper cache operation module. In addition, a marking method of first-level cache operation is provided. The marking method exists in the form of an annotation in a Java language, a dynamic proxy mechanism provided by a development application language is used to intercept a method marked by a specified annotation, a cache key is dynamically calculated before the method is executed, a return value of the method is written into a memory space associated with a current thread stack after the method is executed, and the method is intercepted before next execution of the method. The cached value is read from the memory space associated with the current thread stack and returned to the upper method call, so that the effect of the first-level cache is achieved. The problem that a large amount of sample code needs to be written when a high-performance cache and a distributed cache are used is solved. The dynamic proxy technology used in the first-level cache of the persistence framework is used, the cache operation module is uniformly encapsulated, and the shortcoming that the first-level cache of the persistence framework is suitable for a narrow scene is solved.

[0103] The above method of the embodiment is further introduced below.

[0104] Figure 3 is a schematic diagram of a data processing component module according to an embodiment of the present application, as shown in Figure 3 The component module is sequentially arranged from bottom to top as follows: an object storage module, a cache abstraction module, an AOP aspect module, and a spring starter module. The upper layer depends on the abstract interface of the lower layer, and an external application depends on the spring starter module.

[0105] Optionally, the object storage module is an implementation of the cache abstraction module, and different interface implementations are available according to actual selection of a bottom object storage scheme, and the object storage based on a hash table and the object storage based on high performance can be available.

[0106] Optionally, the cache abstraction module is a definition of a cache interface, and belongs to an upper application programming interface, and the specific implementation is not involved in the module, and only the functions required by the cache are defined through the interface, and the cache module can be further subdivided into a configuration storage module, a cache key evaluator module and the like.

[0107] Optionally, the aspect-oriented programming module is an extraction of logic executed before and after a cached method, and the aspect-oriented programming technology is used to reduce repeated codes, and the AspectJ implementation in the aspect-oriented programming technology can be used, the AspectJ is a stable aspect-oriented programming extension framework in a development application language, is widely supported, and the AspectJ compiles the logic of the aspect-oriented programming into generated byte codes during compilation, and is non-invasive to original codes, and the modification logic is convenient and has no side effects.

[0108] Optionally, the starting module is a tool module, and is used for quickly accessing the method of the embodiment of the application in the use of a spring-boot, and the starting module can simplify the configuration work of development and improve the development efficiency.

[0109] In the embodiment of the application, the first-level cache operation is defined as READ, WRITE and DELET, corresponding to the read, write and delete operations of the cache, and five first-level cache operation annotations are defined, and can include: an entrance definition cache operation, a read cache operation, a write cache operation, a delete cache operation and a read-write cache operation.

[0110] Optionally, the L1CacheEntrance annotation is used to declare a first-level cache entrance, Figure 4 is a schematic diagram of an entrance cache operation annotation class according to one of the embodiments of the application, as Figure 4 indicated, in the method call stack, if the first-level cache operation annotation exists on the method, the stack frame above the method stack frame marked by the annotation will be processed by the AOP aspect module. In the same method call stack, the cache entrance annotation can repeatedly appear on the methods of different stack frames, and the configuration of the entrance annotation of the upper method stack frame will cover the configuration of the lower layer when the entrance annotation repeatedly appears, and the entrance annotation of the upper stack frame can select to disable the first-level cache or inherit the configuration of the first-level cache in the lower stack frame.

[0111] Optionally, the L1CacheRead annotation declares a read cache operation, Figure 5 is a schematic diagram of a read cache operation annotation class according to one of the embodiments of the application, asFigure 5 As shown, the method is executed before calling the cache according to the key, and if the corresponding result exists, the cached value is used. The cached key is calculated by the cache key evaluator module.

[0112] Optionally, the L1CacheWrite annotation declares a write cache operation, Figure 6 is a schematic diagram of a write cache operation annotation class diagram according to an embodiment of the present application, as shown, Figure 6 The annotation writes the return value of the method call into the cache of the current thread stack. The validity duration of the return value in the first-level cache can be controlled by the annotation parameter. If the parameter is not declared, the cache will be valid until the exit of the cache entry method from the call stack. When the method returns a null value, the parameter can be used to control whether the null value is written into the cache. The cached key is calculated by the cache key evaluator module.

[0113] Optionally, the L1CacheDelete annotation declares a delete cache operation, Figure 7 is a schematic diagram of a delete cache operation annotation class diagram according to an embodiment of the present application, as shown, Figure 7 The annotation will clean up the value corresponding to the specified key from the first-level cache of the current method stack. The parameter can be used to control whether the cache is deleted before or after the method is executed. The cached key is calculated by the cache key evaluator module.

[0114] Optionally, the L1Cacheable annotation declares read and write cache operations, Figure 8 is a schematic diagram of a read-write cache operation annotation class diagram according to an embodiment of the present application, as shown, Figure 8 The annotation reads the cache before executing the method. If it exists, it is directly returned. If it does not exist, the method is executed and the return value is written into the cache. The annotation parameter integrates read and write cache operations, which have the same effect.

[0115] The following further introduces the execution process of the method marked by the L1CacheEntrance annotation of the embodiment.

[0116] Figure 9 is a schematic diagram of an entry definition cache operation annotation marked method execution according to an embodiment of the present application, as shown, Figure 9 The method execution marked by the L1CacheEntrance annotation can include the following steps.

[0117] Step S901, generate the cache context of the method stack.

[0118] The method marked by the entry annotation is called, and the method enters the method stack. According to the code written at the time, the method marked in the entry annotation fills in the specified parameters, generates a cache context, and the cache context stores the cache entry method, cache operation manager and other related data. If a cache context has been bound in the method stack before, the cache context can be inherited or a new cache context can be started. After starting a new context, the cache operations in the method stack frames after the current method stack frame only affect the newly generated cache context and have no effect on the previous context.

[0119] In step S902, a binding relationship between the cache context and the current thread is established.

[0120] After generating the cache context of the method stack, a binding relationship between the cache context and the current thread is established. Here, a thread-local variable in the language used to develop the application is used to achieve the binding. The thread-local variable is a variable reference that can ensure that different variable instances are referenced when accessing the variable in different method stacks, and they will not affect each other. If a cache context exists before the method enters, the binding with the previous cache context will be released.

[0121] In step S903, the marked method is executed.

[0122] The marked method is executed, and the marked method actually enters the method stack at this time.

[0123] In step S904, the current cache context is cleaned up.

[0124] After the execution of the marked method is completed, the current cache context is cleaned up, including the unbinding of the binding relationship between the context and the current thread. If a cache context exists before the method enters, the previous cache context will be bound to the current method stack at this time.

[0125] In steps S901-S904, the cache context can be configured according to the parameters of the annotation to choose to inherit or not to inherit the previous context, and the scope of the cache in the method stack can be flexibly controlled. If the previous context is inherited, the current cache context is called a "child context" and the inherited context is called a "parent context". In subsequent cache lookup operations, the parent context is searched first when looking up a cached value, and the child context is searched only when the parent context does not exist. For the same cached method, an entry that disables the first-level cache can be explicitly declared to achieve the effect of directly calling the method without bypassing the cache.

[0126] The execution process of the method marked by the L1Cacheable annotation of the embodiment will be further introduced below.

[0127] Figure 10is a schematic diagram of a state annotation marking method according to an embodiment of the present application, as shown in Figure 10 The L1Cacheable annotation marking method can include the following steps.

[0128] Step S1001, read the cache context method stack cache bound to the current method stack.

[0129] Read the cache context bound to the current method stack. If the cache context does not exist or is declared to disable caching, i.e., the cache context method stack cache bound to the current method stack is not enabled, then execute step S1005 to directly call the method reference through the reflection mechanism of the development application language to execute the marked method, and return the result to the upper method call after the marked method call returns the result, and exit the method stack frame.

[0130] Step S1002, parse the annotation parameters.

[0131] Determine that the cache context method stack cache bound to the method stack is enabled, then parse the parameters used by the marked method to operate the cache according to the annotation parameters, such as the key expression, key evaluator, cache expiration period, etc., and calculate the real cache key according to the key expression and key evaluator.

[0132] Step S1003, execute the read cache operation.

[0133] Execute the read cache operation and determine whether the execution result corresponding to the cache key exists.

[0134] Step S1004, determine whether there is a cached value

[0135] Determine whether the value corresponding to the cache key exists. If it exists, execute step S1007 to directly return to the upper method call and exit the method stack frame; if it does not exist, execute S1005 to call the marked method, at which time the marked method actually enters the method stack for execution.

[0136] Step S1005, execute the method.

[0137] Step S1006, get the method return value and execute the write cache operation.

[0138] Write the result of the method execution in step S1005 to the cache and execute the write operation to write the return value to the memory area associated with the current method stack (i.e., the thread local variable) for subsequent reading. Before writing to the cache, if the annotation parameters are configured to ignore invalid values returned by the marked method, and the marked method also returns invalid values after executing step S1004, then the write cache operation will be aborted.

[0139] Step S1007, return the read value to the read-write cache operation, and the marked method exits the method stack.

[0140] Directly return to the upper method call, and exit the method stack frame.

[0141] In steps S1001-S1007, the cache key is calculated by the evaluator, and after being written into the cache, subsequent calls will not execute the logic of the marked method, but directly use the cached value, which can effectively reduce method calls and improve program running speed, and when used in an Internet environment, the throughput of the service can be improved.

[0142] In the embodiment of the application, the cache processing operation is extracted into an AOP aspect, reducing a large amount of repeated code generated by cache reading and writing in a conventional development process, greatly improving the development efficiency, and the cache processing logic in the AOP aspect does not invade the original code logic, so that the scheme of the application can be easily integrated into the original project, and the developer can pay more attention to the business process.

[0143] Optionally, in step S1001, the cache key evaluator is used, and various script languages can be flexibly used for processing, such as expression language (SpEL), interpreted programming language (Javascript), lightweight script language (Lua), etc., and the evaluator module is an abstract module, and the cache module only depends on the evaluator interface, so that more script language support can be easily extended.

[0144] Optionally, in step S1006, the cache write operation is inserted after the original method call stack exits, and the method return value can be temporarily stored in the cache and bound to the current method call stack. When the L1Cacheable or L1CacheRead annotated method is called again, if the calculated cache key is the same, the cache read operation is inserted before the original method call stack enters through step S1003, the real method call is not executed, and the temporarily stored value is directly returned, thereby reducing the number of original method calls, effectively reducing the important processor and memory overhead in the original method execution process, effectively reducing the execution time of the entire method stack, and when used in an Internet environment, the response speed of the server can be improved, thereby enabling the developed application server to have higher load capacity.

[0145] In the cache key evaluator module in the embodiment of the application, an expression script language is used to implement the evaluator module. The use of the evaluator module is interface-oriented, and since the interpreter and executor of the expression script language are implemented by Java and the Spring framework provides long-term support for the expression script language, the expression script language is preferred to implement the cache key evaluator.

[0146] In the aspect module for aspect-oriented programming, the embodiment of the application adopts the aspect-oriented framework (AspectJ) to perform dynamic proxying. In actual implementation, other aspect-oriented programming technologies can be adopted, such as the dynamic proxying of the development toolkit (Jave Development Tool Kit, referred to as JDK), CGLib, and the like. However, the dynamic proxying of the development toolkit needs to depend on specific interfaces, and is not flexible to use. CGLib needs to dynamically generate bytecodes in the running period, and the efficiency is slightly lower than the static weaving performance of the aspect-oriented framework. The embodiment of the application finally selects the aspect-oriented framework as the implementation of dynamic proxying, thereby achieving the technical effect of improving the development efficiency, and solving the technical problem of low development efficiency.

[0147] Through the description of the above implementation, those skilled in the art can clearly understand that the method according to the above embodiment can be realized by means of software and the necessary general hardware platform, and of course it can also be realized by hardware, but in many cases the former is a better implementation. Based on such understanding, the technical solutions of the application can be embodied in the form of a software product, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, an optical disk), and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the method described in each embodiment of the application.

[0148] The embodiment of the application also provides a data processing device, which is used to implement the above embodiments and preferred embodiments, and has been described above. As used below, the term "unit" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware or a combination of software and hardware is also possible and is contemplated.

[0149] Figure 11 is a structural block diagram of a data processing device according to an embodiment of the application. The device can be applied to a storage operation module, which is obtained by aspect-oriented programming, as shown in Figure 11 The data processing device 1100 can include a detection unit 1101, an execution unit 1102, and a writing unit 1103.

[0150] The detection unit 1101 is configured to detect a target program code to be executed at a current time.

[0151] The execution unit 1102 is configured to, in response to the target program code being identified by a corresponding first target identifier and determining that an execution result of the target program code is not called from a target storage space, execute the target program code to obtain the execution result.

[0152] The writing unit 1103 is configured to write the execution result to the target storage space as to-be-called data of the to-be-executed program code associated with the target program code.

[0153] In the data processing apparatus of the embodiment, the current to-be-executed target program code is detected by the detecting unit; the target program code is executed to obtain an execution result in response to the target program code being identified by the corresponding first target identifier and the execution result of the target program code not being called from the target storage space by the executing unit; and the execution result is written to the target storage space as to-be-called data of the to-be-executed program code associated with the target program code by the writing unit. That is, based on extracting the cached processing operation to the aspect of the aspect programming, the execution result of the target program code is written to the target storage space after the execution result of the target program code is returned by marking the target program code; and the cached execution result is read from the target storage space and returned to the upper method call before the target program code is executed next time, so as to realize the technical effect of reducing the limitation of data caching and solve the technical problem of large limitation of data caching.

[0154] It should be noted that the above units can be implemented by software or hardware, and for the latter, the following implementation manners can be used, but are not limited thereto: the above units are located in the same processor; or the above units are located in different processors in any combination.

[0155] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is arranged to execute the steps in any of the above method embodiments when running.

[0156] Optionally, in the embodiment, the above computer readable storage medium can be arranged to store a computer program for executing the following steps:

[0157] S1, detecting a current to-be-executed target program code;

[0158] S2, executing the target program code to obtain an execution result in response to the target program code being identified by the corresponding first target identifier and the execution result of the target program code not being called from the target storage space;

[0159] S3, writing the execution result to the target storage space as to-be-called data of the to-be-executed program code associated with the target program code.

[0160] Optionally, in the embodiment, the computer readable storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various computer program storage media.

[0161] The embodiment of the present application further provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the above method embodiments.

[0162] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected with the processor, and the input / output device is connected with the processor.

[0163] Optionally, in the embodiment, the processor can be configured to execute the following steps through the computer program:

[0164] S1, detecting a target program code to be executed currently;

[0165] S2, in response to the target program code being identified by a corresponding first target identifier and determining that an execution result of the target program code is not called from a target storage space, executing the target program code to obtain the execution result;

[0166] S3, writing the execution result into the target storage space as to-be-called data of to-be-executed program code associated with the target program code.

[0167] Optionally, specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, and the embodiment will not be described here.

[0168] The serial numbers of the above embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0169] In the above embodiments of the present application, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can refer to the related description of other embodiments.

[0170] In several embodiments provided in the present application, it should be understood that the disclosed technology can be implemented by other means. Among them, the above-mentioned device embodiments are only schematic, for example, the division of the units can be a logical function division, and actual implementation can have another division mode, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between units or modules, which can be electrical or other forms.

[0171] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed to multiple units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0172] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0173] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.

[0174] The above is only the preferred embodiment of the present application. It should be noted that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should be considered as the protection scope of the present application.

Claims

1. A data processing method, characterized by, The method is applied to a storage operation module obtained by aspect-oriented programming, and comprises the following steps: detecting a target program code to be executed currently; in response to the target program code being identified by a corresponding first target identifier, obtaining a target parameter based on the first target identifier, and determining that an execution result of the target program code is not called from a target storage space based on the target parameter, executing the target program code to obtain the execution result; in response to the target parameter not including a target value, writing the execution result into the target storage space as to-be-called data of to-be-executed program code associated with the target program code; the method further comprises: based on a thread local variable, binding the target program code with a cache context, wherein the cache context is used to represent writing the execution result into the target storage space; the method further comprises: based on the target parameter, determining that the execution result of the target program code is not called from the target storage space, including: in response to the cache context bound by the target program code declaring that the execution result of the target storage space is allowed to be used, determining that the execution result of the target program code is not called from the target storage space based on the target parameter.

2. The method of claim 1, wherein, based on the target parameter, determining that the execution result of the target program code is not called from the target storage space, including: determining a cache key based on a key parameter in the target parameter; in response to the value corresponding to the cache key not being stored in the target storage space, determining that the execution result is not called from the target storage space.

3. The method of claim 2, wherein, after executing the target program code to obtain the execution result, the method further comprises: in response to the target parameter including the target value, prohibiting writing the execution result into the target storage space.

4. The method of claim 2, wherein, the method further comprises: in response to the value corresponding to the cache key being stored in the target storage space, calling the value corresponding to the cache key from the target storage space, and determining the value corresponding to the cache key as the execution result called from the target storage space.

5. The method of claim 1, wherein, after executing the target program code to obtain the execution result, the method further comprises: canceling the binding relationship between the target program code and the cache context.

6. The method of claim 5, wherein, the method further comprises: generating the cache context based on a second target identifier, wherein the second target identifier is used to declare a cache entry, and the cache entry is used to determine the target storage space.

7. The method of claim 1, wherein, determining that the execution result of the target program code is not called from the target storage space, including: in response to not obtaining the cache context bound by the target program code, or obtaining the cache context bound by the target program code and the cache context declaring that the execution result of the target storage space is prohibited to be used, determining that the execution result is not called from the target storage space, wherein the cache context is used to write the execution result into the target storage space.

8. The method according to any one of claims 1 to 7, characterized in that, the method further comprises: In response to identifying a third target identifier corresponding to the target program code, reading the execution result from the target storage space, wherein the third target identifier is used to declare reading the execution result from the target storage space.

9. The method according to any one of claims 1 to 7, characterized in that, writing the execution result to the target storage space comprises: In response to identifying a fourth target identifier corresponding to the target program code, writing the execution result to the target storage space, wherein the fourth target identifier is used to declare writing the execution result to the target storage space.

10. The method according to any one of claims 1 to 7, characterized in that, The method further comprises: In response to identifying a fifth target identifier corresponding to the target program code, deleting the execution result from the target storage space, wherein the fifth target identifier is used to declare deleting the execution result from the target storage space.

11. The method according to any one of claims 1 to 7, characterized in that, The target storage space is a level one cache storage space.

12. A data processing apparatus, characterized by The application is applied to a storage operation module obtained by aspect-oriented programming, and the device comprises: a detection unit configured to detect target program code to be executed at a current time; an execution unit configured to, in response to the target program code being identified by a corresponding first target identifier, acquire a target parameter based on the first target identifier, and determine that an execution result of the target program code is not called from a target storage space based on the target parameter, execute the target program code to obtain the execution result; a writing unit configured to, in response to the target parameter not including a target value, write the execution result to the target storage space as to-be-called data of to-be-executed program code associated with the target program code; The device is further configured to bind the target program code and a cache context based on a thread local variable, wherein the cache context is used to represent writing the execution result to the target storage space. The execution unit is further configured to determine that the execution result of the target program code is not called from the target storage space based on the target parameter by the following steps: in response to the cache context bound by the target program code declaring that the execution result of the target storage space is allowed to be used, determining that the execution result of the target program code is not called from the target storage space based on the target parameter.

13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, wherein the computer program is set to be executed by the processor to perform the method in any one of claims 1 to 11. 14.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is set to execute the computer program to perform the method in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Data processing method and system, processor and storage medium

    CN110858201A