CN113064678A - Cache configuration method and device - Google Patents

Cache configuration method and device Download PDF

Info

Publication number
CN113064678A
CN113064678A CN202110321107.6A CN202110321107A CN113064678A CN 113064678 A CN113064678 A CN 113064678A CN 202110321107 A CN202110321107 A CN 202110321107A CN 113064678 A CN113064678 A CN 113064678A
Authority
CN
China
Prior art keywords
cache
target
interface
calling
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110321107.6A
Other languages
Chinese (zh)
Inventor
韩金魁
岳晓敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Qianshi Technology Co Ltd
Original Assignee
Beijing Jingdong Qianshi Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Qianshi Technology Co Ltd filed Critical Beijing Jingdong Qianshi Technology Co Ltd
Priority to CN202110321107.6A priority Critical patent/CN113064678A/en
Publication of CN113064678A publication Critical patent/CN113064678A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects

Abstract

The invention discloses a cache configuration method and device, and relates to the technical field of computers. One embodiment of the method comprises: acquiring one or more interfaces in a service system; respectively determining calling frequency and/or calling duration corresponding to one or more interfaces; when the calling frequency and/or the calling duration meet preset conditions, taking the interface meeting the preset conditions as a target interface; a cache is configured for the target interface. According to the implementation method, the target interface can be selected in a targeted manner from one or more interfaces of the service system and the cache is configured for the target interface, so that blind addition of the cache is avoided, resources are saved, and the utilization rate of the resources is improved.

Description

Cache configuration method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a cache configuration method and apparatus.
Background
The cache is a buffer area for data exchange, and the speed of acquiring data can be improved through the cache. Currently, the way to add a cache to a business system is to add a code related to the cache directly on an interface of the business system during the process of writing the code, for example, add a cache note on the interface or write the code added with the cache in a hard coding manner in an interface method.
However, the cache added in the manner of directly adding cache-related codes on the interface in the prior art is not targeted, which may cause some interfaces with low access frequency to be added with the cache, thereby causing waste of resources.
Disclosure of Invention
In view of this, embodiments of the present invention provide a cache configuration method and apparatus, which can respectively determine a call frequency and/or a call duration corresponding to one or more interfaces of a service system, and configure a cache for a target interface by using an interface whose call frequency and/or call duration meet a preset condition as the target interface, so that a target interface can be selected in a targeted manner from the one or more interfaces of the service system and configured with the cache, thereby avoiding blind addition of the cache, saving resources, and improving a utilization rate of the resources.
To achieve the above object, according to an aspect of an embodiment of the present invention, a cache configuration method is provided.
The cache configuration method of the embodiment of the invention comprises the following steps:
acquiring one or more interfaces in a service system;
respectively determining calling frequency and/or calling duration corresponding to one or more interfaces;
when the calling frequency and/or the calling duration meet preset conditions, taking the interface meeting the preset conditions as a target interface;
a cache is configured for the target interface.
Alternatively,
respectively determining the calling frequency and/or the calling duration corresponding to one or more interfaces, including:
for each interface, performing:
determining the corresponding calling times of the interface within a first preset time length;
and determining the calling frequency and/or the calling time length corresponding to the interface according to the first preset time length and the calling times.
Alternatively,
the preset conditions include:
the number of times that the calling frequency and/or the calling duration exceed a preset threshold in a second preset duration; and the second preset time length is not less than the first preset time length.
Alternatively,
acquiring one or more interfaces in a business system, comprising:
when the service system is loaded, the class file corresponding to the service system is analyzed to obtain one or more interfaces in the service system.
Alternatively,
configuring a cache for a target interface, comprising:
determining cache parameters corresponding to a target interface;
and adding a cache for the target interface according to the cache parameter.
Alternatively,
determining a target class and a target method corresponding to a target interface;
sending a cache parameter configuration request to a front-end page, and setting a waiting time length;
when the front-end page returns a response aiming at the cache parameter configuration request within the waiting time length, determining whether the response comprises a target cache hotspot threshold, a target cache time length and target cache server configuration;
if so, configuring the cache for the target interface according to the target class, the target method, the target cache hotspot threshold, the target cache duration and the target cache server configuration.
Alternatively,
and when the front-end page does not return a response aiming at the cache parameter configuration request within the waiting time length, adding a cache for the target interface according to the target class, the target method, the preset cache hotspot threshold value, the preset cache time length and the preset cache server configuration.
Alternatively,
according to the cache parameter, configuring a cache for the target interface, comprising:
generating an agent class corresponding to the target interface according to the cache parameters;
and writing the proxy class into the code corresponding to the target interface, and reloading the code to configure the cache for the target interface.
Alternatively,
the method further comprises the following steps:
receiving a data acquisition request, wherein the data acquisition request indicates a data identifier of target data;
determining whether target data corresponding to the data identification exists in the cache;
if yes, acquiring target data from the cache;
if not, calling a target interface corresponding to the cache to acquire target data, and storing the target data into the cache.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided a cache configuration apparatus.
The cache configuration device comprises an interface acquisition module, a calculation module, a target interface determination module and a configuration module; wherein:
the interface acquisition module is used for acquiring one or more interfaces in the service system;
the computing module is used for respectively determining the calling frequency and/or the calling duration corresponding to one or more interfaces;
the target interface determining module is used for taking the interface meeting the preset condition as a target interface when the calling frequency and/or the calling duration meet the preset condition;
and the configuration module is used for configuring the cache for the target interface.
To achieve the above object, according to another aspect of the embodiments of the present invention, an electronic device for cache configuration is provided.
An electronic device for cache configuration according to an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by one or more processors, the one or more processors implement the cache configuration method of the embodiment of the invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention stores thereon a computer program, and when the computer program is executed by a processor, the computer program implements a cache configuration method of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the method and the device can respectively determine the calling frequency and/or the calling time length corresponding to one or more interfaces of the service system, take the interface with the calling frequency and/or the calling time length meeting the preset conditions as a target interface, and configure the cache for the target interface, so that the target interface can be selected in a targeted manner from the one or more interfaces of the service system and configured with the cache, the blind addition of the cache is avoided, the resources are saved, and the utilization rate of the resources is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a diagram illustrating the main steps of a cache allocation method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main steps of a method for specifically performing step S102;
FIG. 3 is a schematic diagram of the main steps of a method of configuring a cache for a target interface;
FIG. 4 is a schematic diagram of the main steps of a method of using a cache configured for a target interface;
FIG. 5 is a diagram illustrating major blocks of a cache allocation apparatus according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 7 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic diagram illustrating main steps of a cache configuration method according to an embodiment of the present invention.
As shown in fig. 1, a cache configuration method according to an embodiment of the present invention mainly includes the following steps:
step S101: one or more interfaces in a business system are obtained.
In the embodiment of the present invention, when the service system is loaded, the class file corresponding to the service system may be parsed to obtain one or more interfaces in the service system. Specifically, when a class file of the service system is loaded on a Java Virtual Machine (JVM), the class file may be analyzed to obtain one or more interfaces of the service system.
Step S102: and respectively determining the calling frequency and/or the calling duration corresponding to one or more interfaces.
In the embodiment of the present invention, a method for specifically executing step S102 is shown in fig. 2, and in the method, for each interface, the following steps are executed:
step S201: determining the corresponding calling times of the interface within a first preset time length;
step S202: and determining the calling frequency and/or the calling time length corresponding to the interface according to the first preset time length and the calling times.
In the embodiment of the present invention, the call frequency and/or the call duration corresponding to the interface may be determined by the following formula:
the calling frequency is the calling times/a first preset time length;
the calling time length is equal to a first preset time length/calling times.
For example, the first preset time duration is 1 second, the number of calls of an interface in the first preset time duration is 50000 times, the call frequency corresponding to the interface is 50000 times/second, and the call time duration is 0.00002 second.
Step S103: and when the calling frequency and/or the calling duration meet the preset conditions, taking the interface meeting the preset conditions as a target interface.
In the embodiment of the present invention, the preset conditions include: the number of times that the calling frequency and/or the calling duration exceed a preset threshold in a second preset duration; and the second preset time length is not less than the first preset time length.
For example, still taking the interface with the calling frequency of 50000 times/second as an example, the interface is called only 50000 times in the second, and the number of calls in the next second may be greater than 50000 times, or less than 50000 times. If the second preset time length is 1 minute, the preset threshold of the calling frequency is 55000 times/second, and the preset condition is that the number of times that the calling frequency exceeds the preset threshold in 1 minute is 20 times, namely: the interface is taken as a target interface only if the call frequency of 20 seconds is more than or equal to 55000 times/second within 1 minute.
As another example, still taking the interface with the calling frequency of 50000 times/second as an example, the calling duration of the interface in this second is only 0.00002 second, and the calling duration in the next second may be greater than 0.00002 second or less than 0.00002 second. If the second preset time length is 1 minute, the preset threshold value of the calling time length is 0.00001 second, and the preset condition is that the number of times that the calling time length exceeds the preset threshold value within 1 minute is 20, namely: the interface is only used as a target interface within 1 minute and with a call duration of 20 seconds less than or equal to 0.00001 second.
Step S104: a cache is configured for the target interface.
In the embodiment of the present invention, a cache parameter corresponding to a target interface may be determined first; and adding a cache for the target interface according to the cache parameter. The caching parameters comprise a target class, a target method, a caching hotspot threshold, caching duration and caching server configuration; the cache hotspot threshold, the cache duration and the cache server configuration may be a preset cache hotspot threshold, a preset cache duration and a preset cache server configuration, or a target cache hotspot threshold, a target cache duration and a target cache server configuration specified by a user in an operation process.
Specifically, as shown in fig. 3, a method for configuring a cache for a target interface mainly includes the following steps:
step S301: and determining a target class and a target method corresponding to the target interface.
In the embodiment of the invention, the target class and the target method corresponding to the target interface can be determined from the class file corresponding to the service system.
Step S302: and sending a cache parameter configuration request to a front-end page, and setting a waiting time length.
In the embodiment of the present invention, a cache parameter configuration request may be sent to a front-end page to determine whether a user needs to specify a target cache hotspot threshold, a target cache duration, and a target cache server configuration through the front-end page. And moreover, a waiting time length can be set for the caching parameter configuration request, and if a response from the front-end page is not received in the waiting time length, the user does not specify the target caching hotspot threshold, the target caching time length and the target caching server configuration. Further, the front-end page may employ a Browser/Server (B/S) component, a Client/Server (C/S) component, or a Command-Line Interface (CLI) component to provide an interactive manner for the user.
Step S303: when the front-end page returns a response aiming at the cache parameter configuration request within the waiting time length, determining whether the response comprises a target cache hotspot threshold, a target cache time length and target cache server configuration; if so, configuring the cache for the target interface according to the target class, the target method, the target cache hotspot threshold, the target cache duration and the target cache server configuration.
In the embodiment of the present invention, if the front-end page returns a response to the cache parameter configuration request within the waiting time, but the response does not include the target cache hotspot threshold, the target cache duration, and the target cache server configuration, a cache may be added to the target interface according to the target class, the target method, and the preset cache hotspot threshold, the preset cache duration, and the preset cache server configuration.
In the embodiment of the present invention, no matter the target cache hotspot threshold or the preset cache hotspot threshold is a fixed value, or a value may be taken from the input parameter by using a dynamic expression technique, which is not particularly limited in this embodiment. Wherein, the dynamic expression may be a Spring expression (Spring EL), for example:
"#id+'#targetClass:com.test.pojo.TestPojo#'"
in the embodiment of the present invention, whether the target cache server configuration or the preset cache server configuration is configured, the following information needs to be included to specify the location where the data needs to be cached:
a cache type, wherein 1 indicates that the cache type is a local cache; 2, indicating that the cache type is distributed cache;
cache server address, e.g., 127.0.0.1: 6379;
the cache server accesses the username, e.g., test;
the cache server accesses a password, such as csfs234 fsdv.
In a preferred embodiment of the present invention, if a target interface is configured to add a cache according to a target cache server, before adding the cache, validity of a cache server address included in the target cache server configuration needs to be determined first, so as to determine that cache servers corresponding to the cache server address can be connected. In particular, the validity of the cache server address may be judged by ping and/or telnet.
Step S304: and when the front-end page does not return a response aiming at the cache parameter configuration request within the waiting time length, adding a cache for the target interface according to the target class, the target method, the preset cache hotspot threshold value, the preset cache time length and the preset cache server configuration.
In the embodiment of the present invention, an agent class corresponding to a target interface may be generated according to the cache parameter determined in the above embodiment; and writing the proxy class into a code corresponding to the target interface, and reloading the code to configure a cache for the target interface. Specifically, a bytecode augmentation technology may be adopted to generate an agent class corresponding to the target interface, add the agent class to a top line of the target method corresponding to the target interface, and reload the bytecode file in which the target method is located, so as to complete the process of configuring the cache for the target interface.
In this embodiment of the present invention, after configuring the cache for the target interface, a method for using the cache configured for the target interface may be further included, as shown in fig. 4, the method mainly includes the following steps:
step S401: receiving a data acquisition request, wherein the data acquisition request indicates a data identifier of target data;
step S402: determining whether target data corresponding to the data identification exists in the cache; if yes, go to step S403, if no, step S404;
step S403: acquiring target data from a cache;
step S404: and calling a target interface corresponding to the cache to acquire target data, and storing the target data into the cache.
According to the cache configuration method provided by the embodiment of the invention, the calling frequency and/or calling duration corresponding to one or more interfaces of the service system can be respectively determined, and the interface with the calling frequency and/or calling duration meeting the preset conditions is taken as the target interface to configure the cache for the target interface, so that the target interface can be selected in a targeted manner from the one or more interfaces of the service system and the cache can be configured for the target interface, the blind addition of the cache is avoided, the resources are saved, and the utilization rate of the resources is improved.
Fig. 5 is a schematic diagram illustrating major modules of a cache configuration apparatus according to an embodiment of the present invention.
As shown in fig. 5, a cache configuration apparatus 500 according to an embodiment of the present invention includes an interface obtaining module 501, a calculating module 502, a target interface determining module 503, and a configuration module 504; wherein:
an interface obtaining module 501, configured to obtain one or more interfaces in a service system;
a calculating module 502, configured to determine a call frequency and/or a call duration corresponding to one or more interfaces respectively;
a target interface determining module 503, configured to, when the call frequency and/or the call duration satisfy a preset condition, use an interface that satisfies the preset condition as a target interface;
a configuration module 504, configured to configure the cache for the target interface.
In this embodiment of the present invention, the calculation module 502 is further configured to: for each interface, performing: determining the corresponding calling times of the interface within a first preset time length; and determining the calling frequency and/or the calling time length corresponding to the interface according to the first preset time length and the calling times.
In the embodiment of the present invention, the preset conditions include: the number of times that the calling frequency and/or the calling duration exceed a preset threshold in a second preset duration; and the second preset time length is not less than the first preset time length.
In this embodiment of the present invention, the interface obtaining module 501 is further configured to: when the service system is loaded, the class file corresponding to the service system is analyzed to obtain one or more interfaces in the service system.
In an embodiment of the present invention, the configuration module 504 is further configured to: determining cache parameters corresponding to a target interface; and adding a cache for the target interface according to the cache parameter.
In an embodiment of the present invention, the configuration module 504 is further configured to: determining a target class and a target method corresponding to a target interface; sending a cache parameter configuration request to a front-end page, and setting a waiting time length; when the front-end page returns a response aiming at the cache parameter configuration request within the waiting time length, determining whether the response comprises a target cache hotspot threshold, a target cache time length and target cache server configuration; if so, configuring the cache for the target interface according to the target class, the target method, the target cache hotspot threshold, the target cache duration and the target cache server configuration.
In an embodiment of the present invention, the configuration module 504 is further configured to: and when the front-end page does not return a response aiming at the cache parameter configuration request within the waiting time length, adding a cache for the target interface according to the target class, the target method, the preset cache hotspot threshold value, the preset cache time length and the preset cache server configuration.
In an embodiment of the present invention, the configuration module 504 is further configured to: generating an agent class corresponding to the target interface according to the cache parameters; and writing the proxy class into the code corresponding to the target interface, and reloading the code to configure the cache for the target interface.
In an embodiment of the present invention, the configuration module 504 is further configured to: receiving a data acquisition request, wherein the data acquisition request indicates a data identifier of target data; determining whether target data corresponding to the data identification exists in the cache; if yes, acquiring target data from the cache; if not, calling a target interface corresponding to the cache to acquire target data, and storing the target data into the cache.
According to the cache configuration device provided by the embodiment of the invention, the device can respectively determine the calling frequency and/or calling duration corresponding to one or more interfaces of the service system, and the interface with the calling frequency and/or calling duration meeting the preset conditions is used as the target interface to configure the cache for the target interface, so that the target interface can be selected in a targeted manner from the one or more interfaces of the service system and the cache is configured for the target interface, the blind addition of the cache is avoided, the resources are saved, and the utilization rate of the resources is improved.
Fig. 6 shows an exemplary system architecture 600 to which a cache configuration method or a cache configuration apparatus according to an embodiment of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and an electronic device 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and electronic device 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the electronic device 605 via the network 604 to receive or send messages or the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 601, 602, and 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The electronic device 605 may be a server that provides various services, such as a background management server that supports shopping websites browsed by the user using the terminal devices 601, 602, and 603. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., target push information and product information) to the terminal device.
It should be noted that, the cache configuration method provided in the embodiment of the present invention is generally executed by the electronic device 605, and accordingly, a cache configuration apparatus is generally disposed in the electronic device 605.
It should be understood that the number of terminal devices, networks, and electronic devices in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and electronic devices, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes an interface acquisition module, a calculation module, a target interface determination module, and a configuration module. The names of these modules do not in some cases constitute a limitation on the module itself, for example, the interface acquisition module may also be described as a "module for acquiring one or more interfaces in a business system".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: acquiring one or more interfaces in a service system; respectively determining calling frequency and/or calling duration corresponding to one or more interfaces; when the calling frequency and/or the calling duration meet preset conditions, taking the interface meeting the preset conditions as a target interface; a cache is configured for the target interface.
According to the technical scheme of the embodiment of the invention, the calling frequency and/or calling duration corresponding to one or more interfaces of the service system can be respectively determined, the interface with the calling frequency and/or calling duration meeting the preset conditions is taken as the target interface, and the cache is configured for the target interface, so that the target interface can be selected in a targeted manner from the one or more interfaces of the service system and the cache is configured for the target interface, the blind addition of the cache is avoided, the resources are saved, and the utilization rate of the resources is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A cache configuration method, comprising:
acquiring one or more interfaces in a service system;
respectively determining the calling frequency and/or calling duration corresponding to the one or more interfaces;
when the calling frequency and/or the calling duration meet preset conditions, taking the interface meeting the preset conditions as a target interface;
and configuring a cache for the target interface.
2. The method of claim 1, wherein the determining the call frequency and/or the call duration corresponding to the one or more interfaces respectively comprises:
for each of the interfaces, performing:
determining the number of calling times corresponding to the interface within a first preset time length;
and determining the calling frequency and/or the calling time length corresponding to the interface according to the first preset time length and the calling times.
3. The method according to claim 2, wherein the preset conditions include:
the calling frequency and/or the calling duration exceed the number of times of a preset threshold within a second preset duration; and the second preset time length is not less than the first preset time length.
4. The method of claim 1, wherein obtaining one or more interfaces in the business system comprises:
when the service system is loaded, the class file corresponding to the service system is analyzed to obtain one or more interfaces in the service system.
5. The method of claim 1, wherein configuring the cache for the target interface comprises:
determining cache parameters corresponding to the target interface;
and adding a cache for the target interface according to the cache parameter.
6. The method of claim 5,
determining a target class and a target method corresponding to the target interface;
sending a cache parameter configuration request to a front-end page, and setting a waiting time length;
when the front-end page returns a response to the cache parameter configuration request within the waiting time length, determining whether the response comprises a target cache hotspot threshold, a target cache time length and a target cache server configuration;
if so, configuring a cache for the target interface according to the target class, the target method, the target cache hotspot threshold, the target cache duration and the target cache server configuration.
7. The method of claim 6,
and when the front-end page does not return a response aiming at the cache parameter configuration request in the waiting time length, adding a cache for the target interface according to the target class, the target method, a preset cache hotspot threshold value, a preset cache time length and a preset cache server configuration.
8. The method of claim 5, wherein the configuring the cache for the target interface according to the cache parameter comprises:
generating an agent class corresponding to the target interface according to the cache parameter;
and writing the proxy class into a code corresponding to the target interface, and reloading the code to configure a cache for the target interface.
9. The method of claims 1-8, further comprising:
receiving a data acquisition request, wherein the data acquisition request indicates a data identifier of target data;
determining whether target data corresponding to the data identification exists in the cache;
if yes, obtaining the target data from the cache;
if not, calling the target interface corresponding to the cache to acquire the target data, and storing the target data into the cache.
10. A cache configuration device is characterized by comprising an interface acquisition module, a calculation module, a target interface determination module and a configuration module; wherein:
the interface acquisition module is used for acquiring one or more interfaces in a service system;
the calculation module is used for respectively determining the calling frequency and/or the calling duration corresponding to the one or more interfaces;
the target interface determining module is used for taking the interface meeting the preset condition as a target interface when the calling frequency and/or the calling duration meet the preset condition;
the configuration module is used for configuring a cache for the target interface.
11. A cache-configured electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-9.
CN202110321107.6A 2021-03-25 2021-03-25 Cache configuration method and device Pending CN113064678A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110321107.6A CN113064678A (en) 2021-03-25 2021-03-25 Cache configuration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110321107.6A CN113064678A (en) 2021-03-25 2021-03-25 Cache configuration method and device

Publications (1)

Publication Number Publication Date
CN113064678A true CN113064678A (en) 2021-07-02

Family

ID=76563618

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110321107.6A Pending CN113064678A (en) 2021-03-25 2021-03-25 Cache configuration method and device

Country Status (1)

Country Link
CN (1) CN113064678A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103645904A (en) * 2013-12-20 2014-03-19 北京京东尚科信息技术有限公司 Cache realization method of interface calling
US20140152341A1 (en) * 2012-12-05 2014-06-05 Lsi Corporation External component-less pvt compensation scheme for io buffers
CN104202423A (en) * 2014-09-19 2014-12-10 中国人民财产保险股份有限公司 System for extending caches by aid of software architectures
CN108134817A (en) * 2017-11-30 2018-06-08 北京白山耘科技有限公司 A kind of method and device of adjust automatically caching duration
CN108509323A (en) * 2018-01-30 2018-09-07 深圳壹账通智能科技有限公司 Method for processing business, device based on log analysis and computer equipment
CN110083436A (en) * 2019-05-14 2019-08-02 上海理想信息产业(集团)有限公司 A kind of business datum real-time monitoring system and method based on Java bytecode enhancing technology

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140152341A1 (en) * 2012-12-05 2014-06-05 Lsi Corporation External component-less pvt compensation scheme for io buffers
CN103645904A (en) * 2013-12-20 2014-03-19 北京京东尚科信息技术有限公司 Cache realization method of interface calling
CN104202423A (en) * 2014-09-19 2014-12-10 中国人民财产保险股份有限公司 System for extending caches by aid of software architectures
CN108134817A (en) * 2017-11-30 2018-06-08 北京白山耘科技有限公司 A kind of method and device of adjust automatically caching duration
CN108509323A (en) * 2018-01-30 2018-09-07 深圳壹账通智能科技有限公司 Method for processing business, device based on log analysis and computer equipment
CN110083436A (en) * 2019-05-14 2019-08-02 上海理想信息产业(集团)有限公司 A kind of business datum real-time monitoring system and method based on Java bytecode enhancing technology

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
李想;乔木;官巍;王大勇;王森;: "虚拟座舱技术在飞行模拟器中的应用", 系统仿真学报, no. 1 *
李玉峰;邱菡;兰巨龙;汪斌强;: "小缓存下一种基于推送方式的多接口输出缓存设置策略", 通信学报, no. 09 *

Similar Documents

Publication Publication Date Title
CN109388626B (en) Method and apparatus for assigning numbers to services
CN113489772A (en) Network request processing method and device and electronic equipment
CN113076153A (en) Interface calling method and device
CN113742389A (en) Service processing method and device
CN112948138A (en) Method and device for processing message
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN113127335A (en) System testing method and device
CN111953718A (en) Page debugging method and device
CN113722007B (en) Configuration method, device and system of VPN branch equipment
CN113779122B (en) Method and device for exporting data
CN113064678A (en) Cache configuration method and device
CN114374657A (en) Data processing method and device
CN113742617A (en) Cache updating method and device
CN112688982B (en) User request processing method and device
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN110019671B (en) Method and system for processing real-time message
CN113452738A (en) Page loading method and client
CN109087097B (en) Method and device for updating same identifier of chain code
CN113760487A (en) Service processing method and device
CN112163176A (en) Data storage method and device, electronic equipment and computer readable medium
CN113626176A (en) Service request processing method and device
CN113766437B (en) Short message sending method and device
CN113132480B (en) Data transmission method, device and system
CN113778909B (en) Method and device for caching data
CN113760886A (en) Method, apparatus, device and computer readable medium for providing data service

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination