Data acquisition method and device, storage medium and computer equipment

By using custom cache annotations and sections in distributed systems, combining distributed configuration centers and multi-level caching, the cache logic complexity problem is solved, higher flexibility and maintainability are achieved, and system performance is improved.

CN119669108APending Publication Date: 2025-03-21E-SURFING DIGITAL LIFE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411808788.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

The cache logic in distributed systems is complex, resulting in poor maintainability and low flexibility.

Method used

By customizing cache annotations and sections, obtain configuration values ​​from the distributed configuration center, determine whether the target interface meets preset specifications, and retrieve cache values ​​in multi-level cache to quickly respond to user needs.

Benefits of technology

Improves the flexibility and maintainability of cache logic, avoids code duplication and bloat, and improves system throughput and response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119669108A_ABST
    Figure CN119669108A_ABST
Patent Text Reader

Abstract

According to the data acquisition method and device, the storage medium and the computer equipment, when it is detected that a user sends the data acquisition request, whether the user-defined cache annotation is attached to the target interface called by the data acquisition request or not can be determined firstly; if the user-defined cache annotation is pasted, after a configuration value is obtained from a distributed configuration center through a user-defined cache tangent, whether the target interface meets a preset specification or not is judged when the configuration value meets a preset condition; if yes, obtaining a cache value configured by the user-defined cache annotation through the user-defined cache aspect, and retrieving whether the cache value exists in the multi-level cache; if yes, directly returning a result; and if the user-defined cache annotation is not pasted, or the preset specification is not met, or the cache value does not exist, entering a service method to obtain an output parameter value, writing the output parameter value into the multi-level cache, and returning a result. According to the method and the device, user requirements can be quickly responded by customizing the cache section, and the flexibility is relatively high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of emerging information technology, and in particular to a data acquisition method, device, storage medium and computer equipment. Background Art

[0002] With the rapid development of the Internet, software user experience has become one of the measurement standards. As a key technology to improve response speed, cache essentially trades space for time, sacrificing the real-time nature of data to improve efficiency.

[0003] Currently, when using caching technology to respond to user needs, the corresponding caching logic is generally set in advance according to the system architecture. When the system architecture is a microservice architecture or other distributed architecture, the caching logic is relatively complex, which leads to poor maintainability and low flexibility of the caching logic. Summary of the invention

[0004] The purpose of this application is to solve at least one of the above-mentioned technical defects, especially the technical defect that the cache logic corresponding to the distributed system in the prior art is relatively complex, which leads to poor maintainability and low flexibility of the cache logic.

[0005] The present application provides a data acquisition method, the method comprising:

[0006] When detecting that a user sends a data acquisition request, determining whether a target interface called by the data acquisition request is affixed with a custom cache annotation;

[0007] If the custom cache annotation is affixed, after obtaining the configuration value from the distributed configuration center through the custom cache aspect, when the configuration value meets the preset condition, it is determined whether the target interface meets the preset specification;

[0008] If satisfied, the cache value configured by the custom cache annotation is obtained through the custom cache aspect, and the cache value is retrieved whether it exists in the multi-level cache;

[0009] If it exists, the result is returned directly;

[0010] If the custom cache annotation is not affixed, or the preset specification is not met, or the cache value does not exist, the business method is entered to obtain the output parameter value, and the output parameter value is written into the multi-level cache before returning the result.

[0011] Optionally, after obtaining the configuration value from the distributed configuration center through the custom cache aspect, when the configuration value meets a preset condition, determining whether the target interface meets a preset specification includes:

[0012] Obtain configuration values ​​from the distributed configuration center through the custom cache aspect, where the configuration values ​​include cache time and overall switch status;

[0013] Determine whether the main switch is turned on and whether the cache time has expired through the custom cache aspect;

[0014] If the main switch is turned on and the cache time has not expired, it is determined that the configuration value meets the preset condition, and it is judged whether the target interface meets the preset specification.

[0015] Optionally, the method further comprises:

[0016] If the main switch is not turned on, and / or the cache time has expired, the business method is entered to obtain the output parameter value, and after the output parameter value is written into the multi-level cache, the result is returned.

[0017] Optionally, the determining whether the target interface meets a preset specification includes:

[0018] Determine whether the target interface meets the unified input parameter and unified output parameter requirements.

[0019] Optionally, obtaining the cache value configured by the custom cache annotation through the custom cache aspect includes:

[0020] Obtain the attribute value configured in the custom cache annotation through the custom cache section reflection;

[0021] The attribute values ​​are assembled into cache values ​​using an encryption algorithm.

[0022] Optionally, the multi-level cache includes a local cache and a distributed cache, and the searching whether the cache value exists in the multi-level cache includes:

[0023] Retrieve, through the custom cache aspect, whether the cache value exists in the local cache or the distributed cache;

[0024] The local cache and the distributed cache are both generic receiving classes and generic responding classes.

[0025] The present application also provides a data acquisition device, comprising:

[0026] A cache annotation determination module, used to determine whether a target interface called by the data acquisition request is affixed with a custom cache annotation when detecting that a user sends a data acquisition request;

[0027] A first judgment module is used to, if the custom cache annotation is affixed, obtain the configuration value from the distributed configuration center through the custom cache aspect, and when the configuration value meets the preset condition, judge whether the target interface meets the preset specification;

[0028] The second judgment module is used to obtain the cache value configured by the custom cache annotation through the custom cache aspect if the conditions are met, and to retrieve whether the cache value exists in the multi-level cache;

[0029] The first return module is used to directly return the result if it exists;

[0030] The second return module is used to enter the business method to obtain the output parameter value if the custom cache annotation is not affixed, or the preset specification is not met, or the cache value does not exist, and write the output parameter value into the multi-level cache and then return the result.

[0031] Optionally, the first determination module includes:

[0032] A configuration value acquisition module, used to obtain configuration values ​​from a distributed configuration center through a custom cache aspect, wherein the configuration values ​​include cache time and overall switch status;

[0033] A third judgment module is used to judge whether the main switch is turned on and whether the cache time has expired through the custom cache section;

[0034] The fourth judgment module is used to determine whether the configuration value meets the preset condition and whether the target interface meets the preset specification if the main switch has been turned on and the cache time has not expired.

[0035] The present application also provides a computer-readable storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the data acquisition method described in any one of the above embodiments.

[0036] The present application also provides a computer device, comprising: one or more processors, and a memory;

[0037] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the data acquisition method described in any one of the above embodiments are performed.

[0038] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0039] The data acquisition method, device, storage medium and computer equipment provided by the present application can first determine whether the target interface called by the data acquisition request is affixed with a custom cache annotation when it is detected that a user sends a data acquisition request; if it is affixed with a custom cache annotation, after obtaining the configuration value from the distributed configuration center through the custom cache aspect, when the configuration value meets the preset condition, determine whether the target interface meets the preset specification; if it is satisfied, obtain the cache value configured by the custom cache annotation through the custom cache aspect, and search whether the cache value exists in the multi-level cache; if it exists, directly return the result; if there is no custom cache annotation, or the preset specification is not met, or the cache value does not exist, enter the business method to obtain the output parameter value, and after writing the output parameter value into the multi-level cache, return the result. During this process, the application sets the input parameters according to the actual scenario. For scenarios with high real-time requirements, the cache may not be set. For some scenarios with low real-time requirements, custom cache annotations can be set. In this way, user needs can be quickly responded to by whether to set custom cache annotations and according to the content of custom cache annotations. It has high flexibility and does not need to write cache logic for each interface, thereby avoiding code duplication and bloat, improving the maintainability of the code, and does not affect the reading of business code. In addition, the multi-level cache in the application can make full use of local server memory, effectively eliminating the network overhead of requesting distributed cache, and improving the throughput and response speed of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0041] Figure 1 A flowchart of a data acquisition method provided in an embodiment of the present application;

[0042] Figure 2 A system architecture diagram of the data acquisition process provided in an embodiment of the present application;

[0043] Figure 3 A flowchart of the data acquisition process provided in the embodiment of the present application;

[0044] Figure 4 A timing diagram of the data acquisition process provided in the embodiment of the present application;

[0045] Figure 5 A schematic diagram of the structure of a data acquisition device provided in an embodiment of the present application;

[0046] Figure 6 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0048] In one embodiment, Figure 1 As shown, Figure 1 A flow chart of a data acquisition method provided in an embodiment of the present application; the present application provides a data acquisition method, which may include:

[0049] S110: When it is detected that the user sends a data acquisition request, determine whether the target interface called by the data acquisition request is affixed with a custom cache annotation; if so, execute S120; otherwise, execute S150.

[0050] In this step, HTTP (Hypertext Transfer Protocol) is an application layer protocol for distributed, collaborative, and hypermedia information systems. It is the basis of data communication on the World Wide Web and is used for communication between clients and servers. Clients (such as browsers, mobile applications, etc.) send HTTP requests to obtain resources on the server or ask the server to perform certain operations, and the server returns HTTP responses to satisfy the requests.

[0051] Based on this, when the present application detects that a user sends a data acquisition request, it can first determine the target interface called by the data acquisition request, and then determine whether the target interface has a custom cache annotation, and determine what method to use to acquire and return the data based on the judgment result.

[0052] Among them, this application can create a custom cache annotation for the corresponding interface according to different business scenarios. The custom cache annotation contains the following attributes: specifying the key prefix, specifying the field for generating the cache key, specifying the cache expiration time, etc. In this way, when receiving a data acquisition request sent by a user, the type of business scenario corresponding to it can be determined based on whether the target interface called by the data acquisition request is affixed with a custom cache annotation, and then the acquisition path of the data to be acquired can be determined according to different types of business scenarios, so as to quickly respond to user needs and have high flexibility.

[0053] S120: If a custom cache annotation is attached, after obtaining the configuration value from the distributed configuration center through the custom cache section, when the configuration value meets the preset condition, it is determined whether the target interface meets the preset specification; if it does, S130 is executed; if not, S150 is executed.

[0054] In this step, when it is determined through S110 that the target interface called by the data acquisition request is affixed with a custom cache annotation, the configuration value can be obtained from the distributed configuration center through the custom cache aspect, and when the configuration value meets the preset condition, it is determined whether the target interface meets the preset specification.

[0055] The distributed configuration center of this application is used to centrally manage the configuration of applications in different environments and clusters, and push the modified configuration to the application end in real time. For example, Apollo, the distributed configuration center can well solve the problems of decentralized configuration, difficult maintenance and update.

[0056] Based on this, the present application can pre-establish a multi-level cache and configure the total switch and cache time of the multi-level cache in the configuration center. If the switch is turned off, the cache will no longer be recorded, and data will no longer be retrieved from the multi-level cache. Instead, data will be obtained directly through the database. When the switch is turned on and within the set cache time, the cached data can be obtained through the multi-level cache.

[0057] On this basis, the present application can obtain configuration values ​​from the distributed configuration center through a custom cache aspect. The configuration values ​​include but are not limited to the cache time and the main switch of the multi-level cache. After obtaining the configuration values, the custom cache aspect can determine whether the configuration values ​​meet the preset conditions, and if the preset conditions are met, determine whether the target interface meets the preset specifications. When both are met, data can be obtained directly through the multi-level cache.

[0058] It can be understood that in this application, users can dynamically set the cache time and the main switch through the distributed configuration center, and update the cache strategy in real time to improve the flexibility of the cache strategy. The distributed configuration center has standardized permissions, process governance and other features, which is particularly suitable for microservice configuration management scenarios.

[0059] The custom cache aspect of this application can be used to process methods based on custom cache annotations to implement the core strategy of centralized caching. This aspect programming technology realizes the automation of cache logic, thereby reducing the complexity of cache logic development and maintenance. In addition, custom cache annotations are located through custom cache aspects, and there is no need to write cache logic for each interface, avoiding code duplication and bloat, no code intrusion, and does not affect the reading of business code.

[0060] S130: Obtain the cache value configured by the custom cache annotation through the custom cache aspect, and retrieve whether the cache value exists in the multi-level cache; if it exists, execute S140; if not, execute S150.

[0061] S140: Return the result directly.

[0062] S150: Enter the business method to obtain the output parameter value, write the output parameter value into the multi-level cache, and then return the result.

[0063] In this step, after obtaining the configuration value from the distributed configuration center through the custom cache aspect in S120, when the configuration value meets the preset conditions, it is determined whether the target interface meets the preset specifications. If so, the cache value configured by the custom cache annotation can be obtained through the custom cache aspect, and the cache value can be retrieved whether it exists in the multi-level cache. If it exists, the cache data corresponding to the cache value is directly returned. If it does not exist, the business method is entered to obtain the output parameter value, and the output parameter value is written into the multi-level cache before returning the result.

[0064] Among them, when the present application obtains the configuration value from the distributed configuration center through the custom cache aspect, a multi-level cache can be pre-set. The multi-level cache can make full use of the local server memory. When the custom cache aspect obtains the cache value configured by the custom cache annotation, it can directly search whether the cache value exists in the multi-level cache. If it exists, the result corresponding to the cache value can be directly returned, thereby effectively eliminating the network overhead of requesting the distributed cache and improving the throughput and response speed of the system. In addition, when the target interface is not affixed with a custom cache annotation, or the configuration value of the distributed configuration center does not meet the preset conditions, or the cache value does not exist in the multi-level cache, the present application can also process the data acquisition request by querying the database, and after obtaining the output parameter value, write the output parameter value to the multi-level cache and return the corresponding data, thereby effectively improving the response speed.

[0065] In the above embodiment, when it is detected that a user sends a data acquisition request, it can be determined first whether the target interface called by the data acquisition request is affixed with a custom cache annotation; if it is affixed with a custom cache annotation, after obtaining the configuration value from the distributed configuration center through the custom cache aspect, when the configuration value meets the preset condition, it is determined whether the target interface meets the preset specification; if it is satisfied, the cache value configured by the custom cache annotation is obtained through the custom cache aspect, and whether the cache value exists in the multi-level cache; if it exists, the result is returned directly; if there is no custom cache annotation, or the preset specification is not met, or the cache value does not exist, the business method is entered to obtain the output parameter value, and the output parameter value is written into the multi-level cache before returning the result. During this process, the application sets the input parameters according to the actual scenario. For scenarios with high real-time requirements, the cache may not be set. For some scenarios with low real-time requirements, custom cache annotations can be set. In this way, user needs can be quickly responded to by whether to set custom cache annotations and according to the content of custom cache annotations. It has high flexibility and does not need to write cache logic for each interface, thereby avoiding code duplication and bloat, improving the maintainability of the code, and does not affect the reading of business code. In addition, the multi-level cache in the application can make full use of local server memory, effectively eliminating the network overhead of requesting distributed cache, and improving the throughput and response speed of the system.

[0066] In one embodiment, after obtaining the configuration value from the distributed configuration center through the custom cache section in S120, when the configuration value meets the preset condition, determining whether the target interface meets the preset specification may include:

[0067] S121: Obtain configuration values ​​from a distributed configuration center through a custom cache section, where the configuration values ​​include cache time and a general switch status.

[0068] S122: Determine whether the main switch is turned on and whether the cache time has expired through the custom cache aspect.

[0069] S123: If the main switch is turned on and the cache time has not expired, determine whether the configuration value meets the preset condition, and judge whether the target interface meets the preset specification.

[0070] In this embodiment, after obtaining the configuration value from the distributed configuration center through the custom cache aspect, it can be determined whether the configuration value meets the preset conditions first, and if the preset conditions are met, it can be determined whether the target interface meets the preset specifications.

[0071] It is understandable that since users can dynamically set the cache time and the main switch of the multi-level cache through the distributed configuration center, and update the cache strategy in real time, the flexibility of the cache strategy can be improved. Therefore, this application can first determine whether the main switch of the distributed configuration center is turned on and whether the cache time of the multi-level cache has expired through a custom cache aspect. If it is turned on and has not expired, the custom cache aspect can be used to continue to determine whether the target interface meets the preset specifications, which can improve the flexibility of the cache strategy.

[0072] In one embodiment, the method may further include:

[0073] S124: If the main switch is not turned on, and / or the cache time has expired, enter the business method to obtain the output parameter value, write the output parameter value into the multi-level cache, and return the result.

[0074] In this embodiment, when the custom cache aspect detects that the main switch of the distributed configuration center is not turned on, and / or the cache time configured in the distributed configuration center has expired, it means that the current multi-level cache is not effective. At this time, you can directly enter the business method, such as obtaining the output parameter value corresponding to the data acquisition request through the database, and writing the output parameter value into the multi-level cache, and then returning the corresponding data. This can fill the blank data in the multi-level cache and respond to user needs in a timely manner.

[0075] In one embodiment, determining whether the target interface meets a preset specification in S120 or S123 may include:

[0076] Determine whether the target interface meets the unified input parameter and unified output parameter requirements.

[0077] In this embodiment, when judging whether the target interface meets the preset specifications, it can be judged whether the target interface meets the specifications of unified input parameters and unified output parameters. If so, the data corresponding to the cache value is obtained through multi-level cache and the result is returned; if not, the data acquisition request is processed through the database and the corresponding data is returned.

[0078] It is understandable that before the present application obtains the configuration value from the distributed configuration center through the custom cache aspect, a multi-level cache can be pre-set, and a unified input parameter and a unified output parameter can be set for the multi-level cache. Among them, when encapsulating the unified input parameter, a generic receiving class can be created, which has a member variable of a generic type for receiving the input parameter of the interface. By setting the generic receiving class, different types of input parameters can be received. When encapsulating the unified output parameter, a generic response class can be created, which has a member variable of a generic type for receiving the output parameter of the interface. By setting the generic response class, different types of input parameters can be received, and static factory methods can be implemented for easy calling. And it is agreed that only unified input parameters and unified output parameters will take effect, otherwise they will not take effect, so that the present application can set the input parameters according to the actual scenario. For scenarios with high real-time requirements, cache can be set without setting, which has high flexibility, and the generic parameter encapsulation mechanism unifies the cache key generation method of different data types, thereby simplifying the cache logic.

[0079] In one embodiment, obtaining the cache value configured by the custom cache annotation through the custom cache aspect in S1241 may include:

[0080] S411: Obtain the attribute value configured in the custom cache annotation through the custom cache section reflection.

[0081] S412: Assemble the attribute values ​​into cache values ​​using an encryption algorithm.

[0082] In this embodiment, when determining the cache value corresponding to the custom cache annotation through the custom cache aspect, since the custom cache annotation contains attribute values ​​such as the specified key prefix, the field for generating the cache key, and the specified cache expiration time, this application can first obtain the attribute value configured in the custom cache annotation through reflection, and then use the encryption algorithm to assemble the attribute value into a cache value, and then retrieve the corresponding cache data through the cache value.

[0083] In a specific implementation method, the present application can use a custom cache aspect to determine whether the target interface simultaneously meets the specifications of unified switch, unified input parameters, and unified output parameters. If so, the attribute value of the custom cache annotation configuration is obtained through reflection: the key prefix and the field value for generating the cache key, and assembled into a cache key through algorithms such as md5, and then retrieve whether the local cache and distributed cache already have the cache value, and then return the corresponding cache data.

[0084] In one embodiment, Figure 2 , 3 , 4, Figure 2 This is a system architecture diagram of the data acquisition process provided in the embodiment of the present application. Figure 3The following is a flowchart of the data acquisition process provided in the embodiment of the present application. Figure 4 A timing diagram of a data acquisition process provided in an embodiment of the present application; the multi-level cache in the present application includes a local cache and a distributed cache, and searching in S130 whether the cache value exists in the multi-level cache may include:

[0085] S131: Retrieve through the custom cache aspect whether the cache value exists in the local cache or the distributed cache.

[0086] The local cache and the distributed cache are both generic receiving classes and generic responding classes.

[0087] In this embodiment, Figure 2 , 3 As shown in 4, when retrieving whether there is a cache value in the multi-level cache through a custom cache aspect, this application can set the multi-level cache to local cache and distributed cache; among them, the local cache can use Caffeine as the local cache, which provides an excellent local cache implementation; and the distributed cache can use Redis as the distributed cache. Of course, this application can also choose other types of cache as local cache or distributed cache, which can be set according to the actual situation and is not limited here.

[0088] After the application configures multi-level cache, the custom cache aspect can first determine the cache value corresponding to the custom cache annotation, and then retrieve whether the cache value exists in the local cache or distributed cache. If it exists, the cache data corresponding to the cache value is returned directly through the local cache or distributed cache. If it does not exist, the corresponding data is returned through the database. This can not only quickly respond to user needs, but also flexibly read data.

[0089] Among them, the local cache and distributed cache of this application are both set as generic receiving classes and generic response classes. The generic receiving class can provide a flexible way to handle various types of request data through generic properties, while keeping the code neat and maintainable. The generic response class can provide a unified and efficient way to handle different types of response data through the use of generic properties and static factory methods.

[0090] The data acquisition device provided in the embodiment of the present application is described below. The data acquisition device described below and the data acquisition method described above can refer to each other.

[0091] In one embodiment, Figure 5 As shown, Figure 5A structural diagram of a data acquisition device provided in an embodiment of the present application; the present application also provides a data acquisition device, which may include a cache annotation determination module 210, a first judgment module 220, a second judgment module 230, a first return module 240, and a second return module 250, specifically including the following:

[0092] The cache annotation determination module 210 is used to determine whether a target interface called by the data acquisition request is affixed with a custom cache annotation when it is detected that the user sends a data acquisition request.

[0093] The first judgment module 220 is used to determine whether the target interface meets the preset specification after obtaining the configuration value from the distributed configuration center through the custom cache aspect if the custom cache annotation is attached, and when the configuration value meets the preset condition.

[0094] The second judgment module 230 is used to obtain the cache value configured by the custom cache annotation through the custom cache aspect if the conditions are met, and search whether the cache value exists in the multi-level cache.

[0095] The first returning module 240 is used to directly return the result if it exists.

[0096] The second return module 250 is used to enter the business method to obtain the output parameter value if the custom cache annotation is not attached, or the preset specification is not met, or the cache value does not exist, and write the output parameter value into the multi-level cache and then return the result.

[0097] In the above embodiment, when it is detected that a user sends a data acquisition request, it can be determined first whether the target interface called by the data acquisition request is affixed with a custom cache annotation; if it is affixed with a custom cache annotation, after obtaining the configuration value from the distributed configuration center through the custom cache aspect, when the configuration value meets the preset condition, it is determined whether the target interface meets the preset specification; if it is satisfied, the cache value configured by the custom cache annotation is obtained through the custom cache aspect, and whether the cache value exists in the multi-level cache; if it exists, the result is returned directly; if there is no custom cache annotation, or the preset specification is not met, or the cache value does not exist, the business method is entered to obtain the output parameter value, and the output parameter value is written into the multi-level cache before returning the result. During this process, the application sets the input parameters according to the actual scenario. For scenarios with high real-time requirements, the cache may not be set. For some scenarios with low real-time requirements, custom cache annotations can be set. In this way, user needs can be quickly responded to by whether to set custom cache annotations and according to the content of custom cache annotations. It has high flexibility and does not need to write cache logic for each interface, thereby avoiding code duplication and bloat, improving the maintainability of the code, and does not affect the reading of business code. In addition, the multi-level cache in the application can make full use of local server memory, effectively eliminating the network overhead of requesting distributed cache, and improving the throughput and response speed of the system.

[0098] In one embodiment, the first determining module 220 may include:

[0099] The configuration value acquisition module is used to obtain configuration values ​​from the distributed configuration center through the custom cache section, and the configuration values ​​include cache time and overall switch status.

[0100] The third judgment module is used to judge whether the main switch is turned on and whether the cache time has expired through the custom cache aspect.

[0101] The fourth judgment module is used to determine whether the configuration value meets the preset condition and whether the target interface meets the preset specification if the main switch has been turned on and the cache time has not expired.

[0102] In one embodiment, the present application also provides a computer-readable storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the data acquisition method described in any of the above embodiments.

[0103] In one embodiment, the present application also provides a computer device, including: one or more processors, and a memory.

[0104] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the data acquisition method described in any one of the above embodiments are performed.

[0105] Indicatively, Figure 6 As shown, Figure 6 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 may be provided as a server. Figure 6 The computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by a memory 301 for storing instructions executable by the processing component 302, such as an application. The application stored in the memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute instructions to perform the data acquisition method of any of the above embodiments.

[0106] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.

[0107] Those skilled in the art will understand that Figure 6 The structure shown in the figure 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 computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0108] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0109] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.

[0110] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data acquisition method, characterized in that: The method comprises: When detecting that a user sends a data acquisition request, determining whether a target interface called by the data acquisition request is affixed with a custom cache annotation; If the custom cache annotation is affixed, after obtaining the configuration value from the distributed configuration center through the custom cache aspect, when the configuration value meets the preset condition, it is determined whether the target interface meets the preset specification; If satisfied, the cache value configured by the custom cache annotation is obtained through the custom cache aspect, and the cache value is retrieved whether it exists in the multi-level cache; If it exists, the result is returned directly; If the custom cache annotation is not affixed, or the preset specification is not met, or the cache value does not exist, the business method is entered to obtain the output parameter value, and the output parameter value is written into the multi-level cache before returning the result.

2. The data acquisition method according to claim 1, characterized in that: After obtaining the configuration value from the distributed configuration center through the custom cache section, when the configuration value meets the preset condition, determining whether the target interface meets the preset specification includes: Obtain configuration values ​​from the distributed configuration center through the custom cache aspect, where the configuration values ​​include cache time and overall switch status; Determine whether the main switch is turned on and whether the cache time has expired through the custom cache aspect; If the main switch is turned on and the cache time has not expired, it is determined that the configuration value meets the preset condition, and it is judged whether the target interface meets the preset specification.

3. The data acquisition method according to claim 2, characterized in that: The method further comprises: If the main switch is not turned on, and / or the cache time has expired, the business method is entered to obtain the output parameter value, and after the output parameter value is written into the multi-level cache, the result is returned.

4. The data acquisition method according to claim 1 or 2, characterized in that: The determining whether the target interface meets a preset specification includes: Determine whether the target interface meets the unified input parameter and unified output parameter requirements.

5. The data acquisition method according to claim 1, characterized in that: The obtaining the cache value configured by the custom cache annotation through the custom cache aspect includes: Obtain the attribute value configured in the custom cache annotation through the custom cache section reflection; The attribute values ​​are assembled into cache values ​​using an encryption algorithm.

6. The data acquisition method according to claim 1, characterized in that: The multi-level cache includes a local cache and a distributed cache, and the step of searching whether the cache value exists in the multi-level cache includes: Retrieve, through the custom cache aspect, whether the cache value exists in the local cache or the distributed cache; The local cache and the distributed cache are both generic receiving classes and generic responding classes.

7. A data acquisition device, characterized in that: include: A cache annotation determination module, used to determine whether a target interface called by the data acquisition request is affixed with a custom cache annotation when detecting that a user sends a data acquisition request; A first judgment module is used to, if the custom cache annotation is affixed, obtain the configuration value from the distributed configuration center through the custom cache aspect, and when the configuration value meets the preset condition, judge whether the target interface meets the preset specification; The second judgment module is used to obtain the cache value configured by the custom cache annotation through the custom cache aspect if the conditions are met, and to retrieve whether the cache value exists in the multi-level cache; The first return module is used to directly return the result if it exists; The second return module is used to enter the business method to obtain the output parameter value if the custom cache annotation is not affixed, or the preset specification is not met, or the cache value does not exist, and write the output parameter value into the multi-level cache and then return the result.

8. The data acquisition device according to claim 7, characterized in that: The first judgment module includes: A configuration value acquisition module, used to obtain configuration values ​​from a distributed configuration center through a custom cache aspect, wherein the configuration values ​​include cache time and overall switch status; A third judgment module is used to judge whether the main switch is turned on and whether the cache time has expired through the custom cache section; The fourth judgment module is used to determine whether the configuration value meets the preset condition and whether the target interface meets the preset specification if the main switch has been turned on and the cache time has not expired.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the data acquisition method according to any one of claims 1 to 6.

10. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the data acquisition method according to any one of claims 1 to 6 are performed.