Parameter configuration method, server and readable storage medium
By using high-speed storage media as cache on the server side, the access delay problem caused by the interaction between the client and the database is solved, and the cache parameters are centrally managed through cache declaration files, improving the system's performance and configuration efficiency.
Patent Information
- Application Number
- CN202311435572.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-30
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2043-10-30
AI Technical Summary
When the client performs business, it frequently interacts with the database in the server, resulting in low performance of low-speed storage media and delays in access.
Using high-speed storage media as a cache, it replaces low-speed storage media for storage and reading, reducing data interaction between clients and servers. It also provides a parameter configuration method to centrally manage cache-related parameters through cache declaration files to improve management efficiency.
It reduces data interaction between the client and the server, improves the performance of the program, and centrally manages cache parameters, improves configuration efficiency and reduces operational errors.
Smart Images

Figure CN119960844A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a parameter configuration method, a server, and a readable storage medium. Background Art
[0002] When the client performs some business, each of its requests needs to interact with the database in the server. Since the data in the database is usually stored on the disk, each request needs to interact with the disk, and the disk is a low-speed storage medium with low access performance, thus causing access delays.
[0003] In view of this, when designing high-performance interfaces on the server side, technicians usually use high-speed storage media as cache instead of low-speed storage media for storage and reading. That is to say, if the data corresponding to a certain business is stored in the cache, then the client can directly read the data corresponding to the business from the high-speed storage medium when processing the business, thereby reducing the data interaction between the client and the server and greatly improving the performance of the program. Summary of the invention
[0004] The embodiments of the present application provide a parameter configuration method, a server, and a readable storage medium, which can centrally manage cache-related parameters and improve management efficiency.
[0005] In a first aspect, a parameter configuration method is provided, which can be applied to a server processing a cache service, and the method includes: obtaining a first cache declaration file, and then loading first cache configuration information corresponding to a first service based on the first cache declaration file, and triggering a cache operation for cache data of the first service based on the first cache configuration information, such as querying cache data of the first service, or adding cache data of the first service, or deleting cache data of the first service, or modifying cache data of the first service. The first cache declaration file is used to centrally declare parameters in the first cache configuration information.
[0006] Therefore, in the above scheme, the cache-related parameters corresponding to the first business are centrally managed through the first cache declaration file. Since the cache-related parameters are usually written (coded) based on the respective business characteristic codes, and the relevant codes are usually scattered in various business codes, configuring the cache-related parameters is a relatively complicated task. Based on the scheme provided in the embodiment of the present application, the cache-related parameters corresponding to the first business can be centrally managed, so that the cache configuration can be loaded conveniently and quickly based on the first cache declaration file, which can not only improve efficiency, but also reduce some operational errors caused by the configuration process.
[0007] Furthermore, based on the first cache configuration information, a "add, delete, check and modify" operation can be performed on the cache data of the first service, thereby completing the cache service, replacing the low-speed cache with the high-speed cache, and improving data access efficiency.
[0008] Optionally, the first cache configuration information includes one or more of the following parameters: cache type, cache memory, cache description information, cache key, cache key description information, cache key example, cache value, cache value description information, cache value example, cache monitoring prompt, cache configuration information expiration time, and business custom data loading path information.
[0009] Optionally, after obtaining the first cache declaration file, the method also includes: upon receiving change reminder information, obtaining a second cache declaration file, and loading second cache configuration information corresponding to the second business based on the second cache declaration file, wherein the change reminder information is used to indicate that the first cache configuration information is updated to the second cache configuration information, the second business is the first business or a business after an update iteration of the first business, and the second cache declaration file is used to centrally declare the parameters in the second cache configuration information; and triggering a cache operation on the cache data of the second business based on the second cache configuration information.
[0010] Based on the above solution, during the process of business iteration and update, it is only necessary to modify the cache declaration file corresponding to the business and trigger the server to reload the new cache declaration file, without having to modify the cache feature-related codes scattered in each business code one by one, thereby improving the efficiency of configuration updates and reducing the situation of missing modifications to cache configuration parameters.
[0011] Optionally, triggering a cache operation for cache data of a first business based on first cache configuration information includes: determining a node type of a server according to the first cache configuration information; when the server is a monitoring node, obtaining a working node list, the working node list including Internet Protocol (IP) addresses of one or more working nodes, the monitoring node corresponding to the one or more working nodes, the monitoring node being used to control the one or more working nodes to perform a cache operation; triggering an i-th working node among the one or more working nodes to perform a cache operation for cache data of the first business, where i is a positive integer greater than or equal to 1.
[0012] Based on the above solution, the server node type can be configured as a monitoring node through cache configuration information, and the working node can be controlled by the monitoring node to perform cache operations. In other words, the working nodes can be uniformly monitored and managed by the monitoring node, thereby improving the efficiency and reliability of the cache system execution.
[0013] Optionally, the method further includes: detecting the reachability of the i-th working node; and sending an alarm message when the i-th working node is unreachable, wherein the alarm message is used to indicate that the i-th working node is unreachable.
[0014] In the above scheme, the monitoring node can detect the offline working node through reachability detection and issue an alarm, thereby alleviating the problem of communication effectiveness between the monitoring node and the working node, and reducing the inconsistency of cached data caused by the failure to send control instructions successfully.
[0015] Optionally, detecting the reachability of the i-th working node includes: receiving a notification message from the i-th working node, the notification message being used to indicate that the i-th working node is offline; and in response to the notification message, stopping detecting the reachability of the i-th working node. In other words, the monitoring node periodically sends a heartbeat detection message to the i-th working node; if no response message to the heartbeat detection message is received within a preset reach period, it is determined that the i-th working node is unreachable.
[0016] Based on the above solution, the monitoring node can periodically detect the reachability of the working node through the heartbeat detection process, so that the unreachable working node can be discovered more timely, thereby improving the efficiency of monitoring.
[0017] Optionally, the method further includes: receiving a notification message from the i-th working node, the notification message being used to indicate that the i-th working node is offline; and in response to the notification message, stopping detecting the reachability of the i-th working node.
[0018] Therefore, in the solution of the embodiment of the present application, if a working node goes offline, the working node can notify the monitoring node, and the monitoring node can stop detecting whether the working node is reachable, thereby saving resources.
[0019] Optionally, trigger the i-th working node among one or more working nodes to perform a cache operation on the cache data of the first business, including: when it is monitored that the cache data of the first business stored on the i-th working node is inconsistent with the cache data in the persistent database of the first business, trigger the i-th working node to clear the locally stored cache data of the first business and re-download the cache data of the first business from the persistent database.
[0020] Based on the above solution, the monitoring node can monitor whether the cache data of the working node is consistent with the data in the database. If the cache data is inconsistent, the working node is triggered to update the cache data in time, thereby improving the consistency of the cache data and reducing system errors or business execution errors caused by data inconsistency.
[0021] Optionally, triggering the i-th working node among one or more working nodes to perform a cache operation on cache data of the first business includes: receiving a cache operation request message, the cache operation request message is used to request to perform a cache operation on the cache data of the first business; in response to the cache operation request message, triggering the i-th working node to perform the cache operation.
[0022] Optionally, a cache operation for cache data of a first business is triggered based on the first cache configuration information, including: determining a node type of the server according to the first cache configuration information; when the server is a working node, determining a monitoring node according to the first cache configuration information, the monitoring node corresponding to the working node, and the monitoring node being used to control the working node to perform a cache operation; receiving a cache operation request message from the monitoring node; and performing a cache operation on the cache data of the first business in response to the cache operation request message.
[0023] Therefore, in the above solution, the monitoring node can trigger the working node to perform the cache operation according to the cache request message of the business system, thereby meeting the business needs of the related business.
[0024] Optionally, the method further includes: regularly reporting the service identifier of the first service and the IP address of the working node to the monitoring node.
[0025] Through this solution, the monitoring node can obtain the information of active (i.e., not offline) working nodes, so as to perform corresponding operations (such as detecting reachability or triggering cache operations) on these active working nodes without triggering inactive (i.e., offline) working nodes to perform corresponding operations, thereby saving resources.
[0026] Optionally, the method also includes: when the first cache configuration information indicates that the cache type corresponding to the first business is JVM, and the cache operation includes deleting the cache data of the first business, sending a cache synchronization message to other nodes, the cache synchronization message is used to instruct other nodes to delete the cache data of the first business, the working node and the other nodes belong to the same cluster, and the other nodes correspond to the monitoring node.
[0027] Therefore, in the above solution, the cache operation can be performed based on the pre-loaded first cache configuration information to improve the data usage efficiency. At the same time, for the jvm cache type, when performing the cache deletion operation, other servers in the cluster can be notified to perform the same operation to ensure the consistency of cache data in different servers in the cluster.
[0028] Optionally, the method further includes: in the case of determining that the working node is offline, sending a notification message to the monitoring node, where the notification message is used to indicate that the working node is offline.
[0029] Therefore, in the solution of the embodiment of the present application, if a working node goes offline, the working node can notify the monitoring node, and the monitoring node can stop detecting whether the working node is reachable, thereby saving resources.
[0030] Optionally, loading the first cache configuration information corresponding to the first business based on the first cache declaration file includes: parsing the first cache declaration file to obtain the first cache configuration information, and storing the first cache configuration information in the memory; generating a session factory according to the file type of the first cache declaration file; using the session factory to create a cache session object, the cache session object is used to perform cache operations; determining the cache storage type according to the first cache configuration information; determining the cache execution object according to the cache storage type and generating a corresponding synchronization listener.
[0031] In a second aspect, a server is provided, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the electronic device implements the steps of the facial feature detection method as described in any one of the first aspect or the second aspect above.
[0032] In a third aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the facial feature detection method as described in any one of the first aspect or the second aspect are implemented.
[0033] In a fourth aspect, a computer program product is provided. When the computer program product is run on an electronic device, the electronic device executes the facial feature detection method described in any one of the first aspect or the second aspect.
[0034] In a fifth aspect, a chip system is provided, which includes a processor coupled to a memory, and the processor executes a computer program stored in the memory to implement the facial feature detection method described in any one of the first aspect or the second aspect.
[0035] The chip system may be a single chip or a chip module composed of multiple chips.
[0036] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a cache architecture provided by an embodiment of the present application is shown;
[0038] Figure 2 A schematic block diagram of a parameter configuration method provided in an embodiment of the present application is shown;
[0039] Figure 3 A schematic flow chart for loading cache configuration information provided by an embodiment of the present application is shown;
[0040] Figure 4 A flowchart of an execution of a cache operation provided by an embodiment of the present application is shown;
[0041] Figure 5 A schematic diagram of a service cluster architecture provided by an embodiment of the present application is shown;
[0042] Figure 6 A node startup flow chart provided in an embodiment of the present application is shown;
[0043] Figure 7 A heartbeat detection flow chart provided in an embodiment of the present application is shown;
[0044] Figure 8 A service destruction flow chart provided in an embodiment of the present application is shown;
[0045] Fig. 9 A schematic structural diagram of a cache framework provided in an embodiment of the present application is shown;
[0046] Fig.10 A schematic diagram showing various cache operations provided by an embodiment of the present application is shown;
[0047] Fig.11 A schematic flow chart of generating a policy object provided by an embodiment of the present application is shown;
[0048] Fig.12 A structural diagram of a server provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0050] Cache is a high-speed storage medium that temporarily stores data. It can store frequently accessed or calculated data so that it can be quickly obtained in subsequent accesses, reducing the number of accesses to the underlying data source (such as databases, network interfaces), thereby improving the system's response speed and throughput. Figure 1For example, suppose data A is frequently accessed by the application in the client, while data B is rarely accessed by the application. Therefore, data A can be obtained from the disk (where a persistent database is stored) and stored in the cache, while data B is only retained in the disk. When the application accesses data A, it can directly access the memory to get the corresponding value without going to the disk. Since the cache is a high-speed storage medium, the access speed is fast; on the contrary, when the application accesses data B, since data B is not cached in advance, the application needs to obtain the corresponding value from the disk, which is slower.
[0051] In other words, frequently accessed data can be stored in the cache. In this way, for requests from clients, if the corresponding data is matched in the cache, the result in the cache can be directly returned; if the corresponding data is not matched in the cache, it will be queried through the database. In this way, the number of interactions between the client and the database can be reduced, the efficiency of data access can be improved, and the traffic bottleneck between the client and the database can be alleviated.
[0052] In order to implement the above cache technology, it is usually necessary to configure cache-related parameters, such as cache type, cache storage, cache key, cache value, etc. However, the configuration process of related parameters is relatively complicated and prone to errors, resulting in the server not meeting business characteristics when performing cache operations.
[0053] In view of this, an embodiment of the present application provides a parameter configuration method, in which the server directly loads cache-related configuration information through a cache declaration file, and the cache declaration file is used to centrally declare cache-related parameters. In other words, the user only needs to adjust the parameters in the cache declaration file to complete the configuration of cache-related parameters, without having to search and modify the code corresponding to each parameter in the business code one by one, which not only improves the efficiency of parameter configuration, but also reduces the situation of parameter configuration errors or omissions.
[0054] At the same time, since the cache-related configuration information is designed based on business characteristics, configuring relevant parameters based on the above cache declaration file and performing cache operations for the corresponding business based on the relevant parameters can improve the operating efficiency of the business. Figure 2 Method 100 in the embodiment of the present application provides an exemplary implementation of the parameter configuration method.
[0055] Before introducing method 100, it should be noted that the method provided in the embodiment of the present application can be applied to a server, or to an execution module in a server, or to other devices for executing cache services, and the present application does not limit this. For convenience, the following description will be made by taking a server executing the method in the present application as an example.
[0056] It should also be noted that the method provided in the embodiment of the present application can be applied to a distributed cache architecture, which includes multiple servers. The scheme executed by each server is similar. Therefore, for convenience, the method in the present application is described using one of the servers as an example.
[0057] S110: Obtain a first cache declaration file, and load first cache configuration information corresponding to a first service based on the first cache declaration file.
[0058] Exemplarily, the server first obtains the first cache declaration file. The first cache declaration file is used to centrally declare the parameters in the first cache configuration information corresponding to the first business, that is, the parameters in the first cache configuration information can be centrally managed through the first cache declaration file. Therefore, the first cache declaration file can be understood as a configuration file customized for the first business. The first business can be, for example, a shopping mall business or a promotion business.
[0059] For example, the first cache declaration file marks and declares the cache type, cache data set and other parameters corresponding to the first business through annotations or other means. Through this declaration, the cache framework or library can be told which data needs to be cached and how to perform cache operations.
[0060] As an example, the first cache declaration file can be managed by a distributed configuration center (such as nacos), and the first cache declaration file can be associated with the identification information of the first business. Among them, the distributed configuration center is a tool for managing business configuration information. In a distributed system, due to the large number of nodes and the scattered configuration information, it is difficult to manage. The distributed configuration center can allow the server to dynamically obtain and update the configuration information by providing a centralized configuration management service, thereby realizing unified management and dynamic update of configuration information.
[0061] That is to say, the cache declaration file corresponding to the business can be managed and maintained through the distributed configuration center. In a specific implementation, the server and the distributed configuration center establish a network connection in advance. When the server needs to obtain the first cache declaration file, it can use the pre-established network connection to apply for the first cache declaration file from the distributed configuration center. Specifically, the server can obtain (for example, by downloading) the first cache declaration file from the distributed configuration center (specifically, it can be a configuration server) through the identification information of the first business.
[0062] It is understandable that the present application does not limit the specific time when the server obtains the first cache declaration file. As an example, the server can directly obtain the first cache declaration file after startup.
[0063] It can also be understood that the present application does not limit the file type of the first cache declaration file. As an example, the first cache declaration file can be a file in yaml format or a file in xml format.
[0064] After obtaining the first cache declaration file, the server loads the first cache configuration information corresponding to the first service based on the first cache declaration file. As an example, the server loading the first cache configuration information may refer to the server parsing and storing the first cache configuration information, and creating a session object and / or a synchronization listener based on the cache configuration information.
[0065] It is understandable that the first cache configuration information includes parameters for configuring the cache characteristics of the first business. The specific content may be determined according to the needs of the first business, and this application does not limit it. As an example, the first cache configuration information includes but is not limited to one or more of the following parameters: cache type, cache memory, cache description information, cache key key, key description information, key example, cache value value, value description information, value example, cache monitoring prompt, cache configuration information expiration time, business custom data loading path information, and cache strategy. Correspondingly, the file format example of the first cache declaration file is as follows (taking yaml format as an example):
[0066] Desc: Cache description information
[0067] Type: Cache type
[0068] CacheStorage: Cache storage
[0069] KeyDesc: cache key description information
[0070] keyExam: Example of caching key
[0071] ValueDesc: Description of the cache value
[0072] ValueExam: Example of cached value
[0073] Hint: Prompt message during monitoring
[0074] SurvieTimeDesc: Cache survival period description information
[0075] ExpireTime: expiration time
[0076] loadData: business custom data loading path information
[0077] The cache description information (Desc) is a text description used to describe some relevant information and characteristics of the cache, for example, it may include information such as the name, function, storage strategy, cache capacity, etc. of the cache.
[0078] The cache type (Type) is used to describe the different data structures or storage methods used when storing data in the cache system. The cache type can be, for example, a string (String) or a hash (Hash). Among them, the string cache type means that the data is stored in the cache in the form of a string, which is suitable for storing a single value or a simple key-value pair data. The hash cache type means that the data is stored in the cache in the form of a hash table, which is suitable for storing complex data structures, such as objects or data containing multiple fields.
[0079] Cache Storage refers to the actual storage device or storage medium used to store cache data, such as JVM or redis.
[0080] The cache key is an identifier used to uniquely identify cached data. In a cache, a key is usually a string used to quickly find and access the corresponding cached data. Different cache systems may have certain restrictions on the length and character set of the key.
[0081] The cache value is the actual data stored in the cache. The value can be any type of data, such as a string, number, object, etc., depending on the needs of the application. The cache key and value are stored in pairs, and the corresponding value can be quickly found by the key.
[0082] The monitoring hint (Hint) is the text or logo displayed when monitoring cache data. For example, when the cache data is inconsistent with the data in the database, the system uses the text or logo to prompt the user or operation and maintenance personnel. The specific content can be freely set according to needs.
[0083] Expiration time (ExpireTime) refers to the length of time that cached data remains valid in the cache memory. When the expiration time of cached data is reached, the cache system will mark the data as expired, and the latest data will need to be retrieved again the next time it is accessed. The expiration time can be set according to specific needs. Generally speaking, the expiration time should be determined based on the update frequency and importance of the data.
[0084] The business-defined data loading path information (loadData) is used to indicate the data loading path customized by the business party. For example, when the required data is not found in the cache, the search can continue through this path. Therefore, this path usually points to the database.
[0085] It can be understood that some fields in the above examples (such as Type, CacheStorage, ExpireTime, loadData) can be considered as mandatory fields, that is, necessary fields for performing cache operations; the remaining fields can be considered as fill-in fields for cache monitoring, and the built-in monitoring station will fill in the monitoring interface according to the description information in the cache declaration file.
[0086] Combine the following Figure 3 An exemplary implementation of step S110 is given below. It is understandable that: Figure 3 The process shown is only a specific example. In a specific implementation, it is not necessary to execute Figure 3 All the steps shown are not necessarily followed. Figure 3 The steps are executed in the order shown. Other methods may also be used to execute the process of obtaining and loading the first cache configuration file, which is not limited in this application.
[0087] A1, server starts.
[0088] Exemplarily, after the server is started, a monitoring system can be started synchronously, and the monitoring system is used to monitor cache operation instructions, and the cache operation instructions are used to instruct cache operations to be performed on cache data, such as deleting cache data. The cache instructions come from other servers in the same cluster, for example, when the cache data in other servers is changed, in order to maintain the consistency of the cache data, other servers can send cache operation instructions to the server in this embodiment to instruct the server to perform the same change on the cache data. The server can obtain the cache operation instruction through the monitoring system, and the specific process is not limited in this application.
[0089] A2, obtaining a first cache declaration file.
[0090] Exemplarily, after the monitoring system is started, the server obtains the cache declaration file, for example, obtains the first cache declaration file from the distributed configuration center.
[0091] A3: Load the first cache configuration information.
[0092] Exemplarily, the first cache declaration file is parsed to obtain the first cache configuration information, and the first cache configuration information is stored in the memory. For example, after obtaining the first cache declaration file, the first cache configuration information can be obtained by performing file parsing according to the file type of the first cache declaration file. Specifically, assuming that the first cache declaration file is a file in yaml format, the first cache configuration information is obtained by parsing the first cache declaration file using a yaml format file parsing method.
[0093] Furthermore, the first cache configuration information obtained by parsing can be stored in the memory, and the specific storage method is not limited in this application. As an example, the first cache configuration information can be stored in the memory in the form of key-value.
[0094] A4, build a session factory.
[0095] Exemplarily, a session factory (SessionFactory) is generated according to the file type of the first cache declaration file. For example, if the file format of the first cache declaration file is yaml, a yaml session factory is generated; if the file format of the first cache declaration file is xml, an xml session factory is generated.
[0096] Among them, the session factory is a factory class used to create and manage sessions.
[0097] A5, create a cache session object.
[0098] Exemplarily, after the session factory is generated, a cache session object (CacheSession) is created using the session factory. The cache session object is a top-level interface design for cache operations, which is used to perform cache operations. The cache operations in the embodiment of the present application include add, delete, modify, and query operations on cache data.
[0099] A6, determine the cache memory type.
[0100] Exemplarily, the cache memory type (such as jvm or redis) is determined according to the first cache configuration information.
[0101] It is understandable that step A6 can be executed at any time after step A3, that is, A6 can be executed after A3, or after A4 or A5, and this application does not limit this.
[0102] A7, create a storage executor.
[0103] Exemplarily, a cache execution object (executor) is determined according to the cache memory type. For example, when the cache memory is redis, a redis link client executor object is generated; when the cache memory is jvm, a caffeine client executor object is generated.
[0104] A8: Generate a cache synchronization listener.
[0105] Exemplarily, a corresponding synchronization listener listen is generated according to the cache storage type. For example, if the storage type is jvm, a synchronization listener corresponding to jvm is generated; if the synchronization type is redis, a listener for redis is generated; if the synchronization type is kafka, a listener for kafka is generated.
[0106] In summary, the above scheme centrally manages the cache-related parameters corresponding to the first business through the first cache declaration file. Since the cache-related parameters are usually written (coded) based on the respective business characteristic codes, and the relevant codes are usually scattered in various business codes, configuring the cache-related parameters is a relatively complicated task. Based on the scheme provided in the embodiment of the present application, the cache-related parameters corresponding to the first business can be centrally managed, so that the cache configuration can be loaded conveniently and quickly based on the first cache declaration file, which can not only improve efficiency, but also reduce some operational errors caused by the configuration process.
[0107] S120: triggering a cache operation for cache data of a first service based on first cache configuration information.
[0108] Exemplarily, after parsing and obtaining the first cache configuration information, the server triggers a cache operation for the cache data of the first service based on the first cache configuration information. The server triggering the cache operation may refer to the server triggering other servers to perform the cache operation, or the server performing the cache operation by itself. The cache operation may include, for example, one or more of the following: querying the cache data of the first service, adding the cache data of the first service, deleting the cache data of the first service, and modifying the cache data of the first service.
[0109] Combine the following Figure 4 , taking the server to perform a cache operation as an example, the execution process of a cache operation is described. It can be understood that Figure 4 The cache operations include query and delete operations as an example.
[0110] B1: The business party triggers the cache operation.
[0111] Exemplarily, the business party triggers the server to perform a cache operation. For example, an application in the client sends a cache operation request message to the server through an external interface of the server to trigger the server to perform a cache operation.
[0112] B2, obtain the cache session object.
[0113] For example, after receiving the cache operation request message from the business party, the server obtains the pre-established cache session object (CacheSession). The creation process of the cache session object can refer to Figure 3 Step A5 in the above description will not be repeated here.
[0114] B3, obtain the cache storage object according to the key; B4, obtain the corresponding cache strategy.
[0115] Exemplarily, the server obtains the key from the first cache configuration information, and obtains the corresponding cache storage object (i.e., the value corresponding to the key) and the corresponding cache strategy according to the key. The cache strategy here can be obtained from the first cache configuration information. The cache strategy, for example, refers to a strategy for determining storage and management of cache data in the cache system. The selection and configuration of the cache strategy can be adjusted according to specific business needs and system performance requirements, and is not specifically limited here.
[0116] B5, determine the cache memory type.
[0117] Exemplarily, the type of cache memory is determined according to the preloaded first cache configuration information. If the cache memory is redis, steps B6 to B10 are executed; if the cache memory is jvm, steps B11 to B19 are executed. Each of these is described below.
[0118] B6, obtain the redis storage executor.
[0119] For example, if the cache storage is redis, a pre-generated redis storage executor (i.e., a redis link client executor object) is obtained. The specific generation process can be referred to Figure 3 Step A7 in the above description will not be repeated here.
[0120] It can be understood that the redis storage executor is used to execute cache operations triggered by the business side.
[0121] B7, determine the cache operation.
[0122] Exemplarily, the server further determines the type of cache operation and determines the operation to be performed according to the type of cache operation. If the cache operation triggered by the business party is a delete operation (i.e., deleting the cache data of the first business), execute step B8. If the cache operation triggered by the business party is a query operation (i.e., querying the cache data of the first business), execute B9.
[0123] B8, execute cache deletion.
[0124] Exemplarily, if the cache operation triggered by the business party is a delete operation, the redis storage executor is used to delete the cache data of the first business.
[0125] B9, execute cache query.
[0126] Exemplarily, if the cache operation triggered by the business party is a query operation, the redis storage executor is used to query the cache data of the first business.
[0127] B10, optionally, obtain the corresponding loadData class.
[0128] Exemplarily, when a query operation is performed but there is no cache data of the first business in the cache, the loadData method of the business party can be called to load the business data, and the specific process is not limited in this application.
[0129] B11, obtain the caffeine storage executor.
[0130] For example, if the cache memory is a jvm, a pre-generated caffeine storage executor (i.e., a caffeine client executor object) is obtained. The specific generation process can be referred to Figure 3 Step A7 in the above description will not be repeated here.
[0131] It can be understood that the jvm storage executor is used to execute cache operations triggered by the business side.
[0132] B12. Determine cache operation.
[0133] Exemplarily, the server further determines the type of cache operation and determines the operation to be performed according to the type of cache operation. If the cache operation triggered by the business party is a delete operation (i.e., deleting the cache data of the first business), execute steps B13 to B17. If the cache operation triggered by the business party is a query operation (i.e., querying the cache data of the first business), execute B18 to B19.
[0134] B13, execute cache deletion.
[0135] Exemplarily, if the cache operation triggered by the business party is a delete operation, the cache data of the first business is deleted by using the caffeine storage executor.
[0136] B14, determine the message component.
[0137] For example, unlike redis cache, the biggest feature of jvm cache is its decentralized cache storage. Therefore, when performing cache deletion operations, it is also necessary to notify other servers in the cluster to perform the same operation to ensure the consistency of cache data between different servers. For example, cache synchronization messages can be pushed according to the configured message component to achieve cache consistency. If the type of the message component is kafka, execute B15; if the type of the message component is http, execute B16; if the type of the message component is redis, execute B17.
[0138] B15, send Kafka message.
[0139] Exemplarily, if the type of the message component is Kafka, the server sends a Kafka message to other servers in the cluster to instruct the other servers to perform a deletion operation on the cached data of the first service.
[0140] B16, polling http request call execution.
[0141] Exemplarily, if the type of the message component is http, the server calls other servers in the cluster through polling http requests to perform a deletion operation on the cached data of the first service.
[0142] B17, send redis message.
[0143] Exemplarily, if the type of the message component is redis, the server sends a redis message to other servers in the cluster to instruct the other servers to perform a deletion operation on the cached data of the first service.
[0144] B18, execute cache query.
[0145] Exemplarily, if the cache operation triggered by the business party is a query operation, the caffeine storage executor is used to query the cache data of the first business.
[0146] B19, obtain the corresponding loadData class.
[0147] Exemplarily, when a query operation is performed but there is no cache data of the first business in the cache, the loadData method of the business party can be called to load the business data, and the specific process is not limited in this application.
[0148] Therefore, in the above scheme, the cache operation can be performed based on the pre-loaded first cache configuration information to improve the data usage efficiency. At the same time, for the jvm cache type, when performing the cache deletion operation, the message component can be used to notify other servers in the cluster to perform the same operation to ensure the consistency of the cached data.
[0149] In summary, in the above method 100, through steps S110 and S120, the first cache configuration information can be loaded based on the first cache declaration file, and the cache operation can be triggered based on the storage configuration information. However, the first cache configuration information is written according to the business characteristic code of the first business, so in the iterative development process of the first business, the corresponding first cache configuration information also needs to be updated.
[0150] As an example, when the first cache declaration file is maintained by the distributed configuration center, if the user or developer needs to modify the first cache declaration file, the first cache declaration file maintained in the distributed configuration center can be modified directly. When the first cache declaration file is modified, the distributed configuration center can notify the corresponding server so that the server downloads the modified cache declaration file from the distributed configuration center.
[0151] For example, when the server receives the change reminder information, it obtains the second cache declaration file. The change reminder information is used to indicate that the first cache configuration information is updated to the second cache configuration information, or the change reminder is used to indicate that the first cache declaration file has changed, or the change reminder is used to indicate that the configuration information related to the first business has changed, or the change reminder is used to instruct the server to update the first cache declaration file, or the change reminder is used to instruct the server to re-download the cache declaration file from the distributed configuration center. The change reminder is, for example, sent to the server by the distributed configuration center.
[0152] After obtaining the second cache declaration file, the server loads the second cache configuration information corresponding to the second service based on the second cache declaration file, and then triggers the cache operation for the cache data of the second service based on the second cache configuration information. The second service is the first service or the service after the update iteration of the first service, and the second cache declaration file is used to centrally declare the parameters in the second cache configuration information. The specific implementation process is similar to the scheme introduced in the above S110 and S120 parts, and will not be repeated here for the sake of brevity.
[0153] In summary, by centrally declaring cache-related configuration parameters through cache declaration files, it is more convenient to manage the configuration parameters. During the process of business iteration and update, you only need to modify the cache declaration file corresponding to the business and trigger the server to reload the new cache declaration file, without having to modify the cache feature-related codes scattered in each business code one by one, thereby improving the efficiency of configuration updates and reducing the situation of missing modifications to cache configuration parameters.
[0154] From the above solutions, we can see that caching is a solution that uses high-speed storage to replace low-speed storage. However, during the use of caching, various cache operations (such as deletion and modification of cached data) may cause inconsistency in data in different storage media, which may cause system function abnormalities, data errors or business logic errors.
[0155] In view of this, the embodiment of the present application provides a parameter configuration method, which can control the working node to perform cache operations through the monitoring node, and when the cache data maintained by the working node is inconsistent with the data in the database in the source database, the working node can be triggered to update the cache data in time, thereby improving the consistency of the cache data. On the other hand, by maintaining the effectiveness of the communication between the monitoring node and the working node, it is ensured that the control instructions of the cache operation can accurately reach the working node, reducing the situation where the cache data is inconsistent due to the failure of the control instruction to be sent successfully.
[0156] The parameter configuration method provided in the embodiment of the present application is further described below in conjunction with step S120 in method 100. Specifically, the server triggers a cache operation for cache data of the first service based on the first storage configuration information, which may include the following two possible implementations.
[0157] In a first possible implementation, if the current server is a monitoring node, the working node is triggered to perform a cache operation based on a comparison between the working node and cached data in the database or an external request.
[0158] Exemplarily, after the server obtains the first cache declaration file and loads the cache configuration information corresponding to the first business based on the first cache declaration file (the specific implementation method can refer to the description of the above S110 step), the node type of the server is determined according to the first cache configuration information. The node types here include, for example, monitoring nodes and / or working nodes, wherein the monitoring node is used to control the working point to perform cache operations, and the working node is used to perform cache operations based on control instructions from the monitoring node. A monitoring node corresponds to one or more working nodes, and a server can be either a monitoring node or a working node, or both a monitoring node and a working node. It can be understood that the monitoring node and the working node are merely names used to identify two different types of nodes in the embodiments of the present application. In different application scenarios, these two types of nodes can also be called other names.
[0159] In one example, the first cache configuration information includes the IP addresses of the monitoring node and the working node, such as the following parameters included in the first cache configuration information: masterip: IP1; workip: IP2, IP3, IP4... where "masterip" indicates the IP address of the monitoring node, and "workip" indicates the IP address of the working node. If the IP address of the current server is IP1, it indicates that the current server is a monitoring node; if the IP address of the current server is one of IP2, IP3, IP4..., it indicates that the current server is a working node.
[0160] In the case where the server is a monitoring node, a list of working nodes is obtained. The list of working nodes includes the Internet Protocol IP addresses of one or more working nodes, and the monitoring node (i.e., the current server) corresponds to the one or more working nodes, and the monitoring node is used to control the one or more working nodes to perform cache operations. In one possible implementation, the monitoring node can obtain the list of working nodes according to the first cache configuration information; in another possible implementation, the working node will actively register with the monitoring node after startup, for example, the working node will actively report its own IP address and the identifier of the corresponding business to the monitoring node. In this case, the monitoring node can obtain the list of working nodes by sorting out the information of the registered working nodes.
[0161] After obtaining the list of working nodes, the monitoring node may trigger one or more working nodes in the list of working nodes to perform a cache operation. Taking the i-th working node among the one or more working nodes as an example (i is a positive integer greater than or equal to 1): the monitoring node triggers the i-th working node to perform a cache operation for cache data of the first service.
[0162] For example, in one scenario, when the monitoring node detects that the cache data of the first business stored on the i-th working node is inconsistent with the cache data in the persistent database of the first business, the i-th working node is triggered to clear the locally stored cache data of the first business and re-download the cache data of the first business from the persistent database. That is to say, in this scenario, the cache operation for the cache data of the first business includes clearing the local cache data and re-acquiring the cache data of the first business. Among them, the persistent database of the first business refers to a database system used for long-term storage and management of the first business data, which is usually stored in a hard disk. Therefore, it can be ensured that the data is still reliably saved after the system is shut down or powered off, and can be read and modified when needed. For convenience, the persistent database is referred to as the database in this application. Through this solution, when the cache data inconsistency is detected, the cache data of the working node can be updated in time to reduce the situation of system abnormalities caused by cache data errors.
[0163] For example, in another scenario, after receiving the cache operation request message, the monitoring node triggers the i-th working node to perform the cache operation in response to the cache operation request message. For example, the monitoring node receives an operation request message from a client, and the operation request message is used to request to perform a cache operation on the cache data of the first service. In response to the operation request message, the i-th working node is triggered to perform the cache operation on the cache data of the first service.
[0164] Optionally, the monitoring node may also detect the reachability of one or more working nodes in the working node list. Detecting the reachability of the working node refers to detecting whether the communication between the monitoring node and the working node is effective. The following is an example of the i-th working node.
[0165] Detect the reachability of the i-th working node. For example, the monitoring node periodically sends a heartbeat detection message to the i-th working node. If no response message to the heartbeat detection message is received within a preset reach period, it is determined that the i-th working node is unreachable.
[0166] When the i-th working node is unreachable, the monitoring node sends an alarm message, which is used to indicate that the i-th working node is unreachable. When the i-th working node is reachable, the monitoring node does not perform other operations.
[0167] Optionally, if the monitoring node learns that the i-th working node is offline, the monitoring node may stop detecting the reachability of the i-th working node. For example, the monitoring node receives a notification message from the i-th working node, the notification message being used to indicate that the i-th working node is offline; in response to the notification message, the monitoring node stops detecting the reachability of the i-th working node.
[0168] Therefore, in the solution of the embodiment of the present application, if a working node goes offline, the working node can notify the monitoring node, and the monitoring node can stop detecting whether the working node is reachable, thereby saving resources.
[0169] In a second possible implementation, if the current server is a working node, a cache operation is performed based on an instruction of a monitoring node.
[0170] Exemplarily, after the server obtains the first cache declaration file and loads the cache configuration information corresponding to the first business based on the first cache declaration file (the specific implementation method can refer to the description of the above S110 step), the node type of the server is determined according to the first cache configuration information. The specific implementation method can refer to the above first possible implementation method.
[0171] When the server is a working node, a monitoring node is determined, and a cache operation is performed according to an instruction of the monitoring node.
[0172] For example, the working node determines the monitoring node according to the first cache configuration information (such as obtaining the IP address of the working node), the monitoring node corresponds to the working node, and the monitoring node is used to control the working node to perform a cache operation. Further, the working node receives a cache operation request message from the monitoring node, and the cache operation request message is used to request to perform a cache operation on the cache data of the first service. In response to the cache operation request message, the working node performs a cache operation on the cache data of the first service.
[0173] Optionally, the working node periodically reports the service identifier of the first service and the IP address of the working node to the monitoring node. Through this solution, the monitoring node can obtain the information of active (i.e., not offline) working nodes, so as to perform corresponding operations (such as detecting reachability or triggering cache operations) on these active working nodes without triggering inactive (i.e., offline) working nodes to perform corresponding operations, thereby saving resources.
[0174] Optionally, when the working node is determined to be offline, the working node sends a notification message to the monitoring node, and the notification message is used to indicate that the working node is offline. In other words, the working node can actively report that it is going offline, so that the monitoring node does not need to actively discover the offline of the working node through the reachability detection process, which can save resources and improve the efficiency of system operation.
[0175] To sum up, based on the above scheme, the monitoring node can be used to monitor whether the cache data of the working node is consistent with the data in the database. When the cache data is inconsistent, the working node is triggered to update the cache data in time, thereby improving the consistency of the cache data and reducing system errors or business execution errors caused by data inconsistency.
[0176] At the same time, through reachability detection, offline working nodes can be discovered in time and alarms can be issued, thereby alleviating the problem of communication effectiveness between monitoring nodes and working nodes, and reducing the inconsistency of cached data due to failure to send control instructions successfully.
[0177] Corresponding to the parameter configuration method given in the above embodiment, the embodiment of the present application also provides a server cluster architecture, in which multiple servers are deployed in a cluster manner, and the multiple servers include at least one monitoring node and one or more working nodes. Figure 5 An example of the server cluster architecture is shown. It can be understood that Figure 5 Only one monitoring node and two working nodes are shown, but Figure 5 The architecture shown is only an example. According to actual needs, the architecture may also include two or more monitoring nodes, three or more working nodes, or only one working node, which is not limited in this application. Figure 5 The architecture shown takes the cache storage type as redis cache as an example.
[0178] It is understandable that in Figure 5 In the architecture shown, any node may correspond to the server in the above method 100, for example, Figure 5 The monitoring node in can be used to execute the solution executed when the server in method 100 is a monitoring node; Figure 5 Any working node in can be used to execute the solution executed when the server in method 100 is a working node. Figure 5 For the parts that are not described in detail in the corresponding solution, please refer to the description in method 100.
[0179] Combine the following Figure 5 The architecture in the figure provides an illustrative example of the execution steps of each node.
[0180] C1, the working node loads the first cache configuration information and determines the monitoring node.
[0181] C2, the monitoring node loads the first cache configuration information, opens the monitoring management capability, and detects the reachability of the working node.
[0182] C3, regularly reports the service ID and IP to the monitoring node.
[0183] Exemplarily, after the server (working node or monitoring node) is started, the first cache configuration information is loaded. For example, the server loads the first cache configuration information through the first cache declaration file. The specific implementation method can refer to the description of S110 in method 100, which will not be repeated here.
[0184] Then, the server determines whether its node type is a monitoring node or a working node based on the first cache configuration information, and then executes a corresponding solution according to its node type. Figure 6 The specific implementation process is illustrated by way of example.
[0185] D1, server starts.
[0186] D2, obtaining the first cache declaration file.
[0187] For example, after the server is started, the monitoring system can be started, and the first cache declaration file can be obtained, and then the first cache configuration information can be loaded based on the first cache declaration file. Figure 3 Steps A1 and A2 are similar and will not be repeated here for brevity.
[0188] D3, determine whether it is a monitoring node.
[0189] Exemplarily, whether it is a monitoring node is determined based on the first cache configuration information.
[0190] In one example, the first cache configuration information includes the IP address of the monitoring node. If the IP address of the current server matches the IP address of the monitoring node, it means that the current server is the monitoring node, and step D4 is directly executed at this time, otherwise step D5 is executed.
[0191] D4, open the monitoring interface, obtain the list of working nodes, and detect the reachability of working nodes.
[0192] Exemplarily, when the server determines its own monitoring node, it opens a monitoring interface (ie, opens monitoring management capabilities) to the working node to provide monitoring management services for the working node. At the same time, it obtains a working node list and detects the reachability of one or more working nodes in the working node list.
[0193] In a possible implementation, the reachability of the working node can be detected through the heartbeat detection process. Figure 7 Take this as an example: In step E1, the server starts the heartbeat detection task, and then in step E2, it is determined whether it is a monitoring node. If the current server is a monitoring node, step E3 is triggered, that is, a list of working nodes is obtained, and then in step E4, the reach of one or more working nodes in the working node list is detected. For example, the monitoring node sends a heartbeat detection message to the working node. If the working node receives the heartbeat detection message from the monitoring node, it returns a response message. In this case, the monitoring node determines in step E5 whether the return time of the response message exceeds the reach cycle, that is, the monitoring node determines whether the response message is received within the reach cycle. If the response message is not received within the reach cycle, then in step E6, the working node determines that the working node is offline; if the current server is a working node, if the working node is about to go offline, the monitoring node can be notified. For example, in step E7, the working node obtains the address of the monitoring node, and then triggers the monitoring node to stop heartbeat detection.
[0194] D5, determine whether it is a working node.
[0195] Exemplarily, if the current server is not a monitoring node, it is further determined whether it is a working node based on the first cache configuration information.
[0196] In one example, the first cache configuration information includes the IP address of the working node. If the IP address of the current server matches the IP address of the working node, it means that the current server is the working node, and step D6 is directly executed at this time, otherwise the current process ends.
[0197] D6, obtain the monitoring node address.
[0198] D7, report the service ID and IP, and enable message monitoring.
[0199] Exemplarily, when the server determines that it is a working node, it obtains the address of the monitoring node and reports the service identifier of the first service and its own IP to the monitoring node. For example, the server obtains the IP of the monitoring node according to the first cache configuration information, and then reports the identifier of the first service and its own IP regularly (such as every 10 minutes).
[0200] C4, the monitoring node sends monitoring commands to the working node.
[0201] Exemplarily, the monitoring node may trigger the working node to perform a cache operation based on a comparison between the working node and cached data in a database or an external request.
[0202] For example, when the monitoring node detects that the cache data of the first business stored on a working node is inconsistent with the cache data in the persistent database of the first business, it triggers the working node to clear the locally stored cache data of the first business and download the cache data of the first business again from the persistent database.
[0203] For another example, after receiving a cache operation request message from a business system, the monitoring node triggers the working node to perform a cache operation in response to the cache operation request message.
[0204] As an example, the monitoring node can send a command to a specific working node based on the hypertext transfer protocol (http) protocol to trigger a cache operation. It is understandable that the monitoring node can specify an IP (i.e., specify a working node) or specify a cluster (i.e., specify multiple working nodes in a cluster) to perform a cache operation.
[0205] C5: Optionally, after the service is destroyed, a notification of offline operation is proactively sent.
[0206] For example, when the service of the server is destroyed, the corresponding node (corresponding monitoring node or working node) can be actively notified to go offline. Figure 8 The specific process is described as follows:
[0207] F1, after the service is destroyed (or about to be destroyed), trigger step F2; F2, the current server determines whether it is a monitoring node; F3, if the current server is a monitoring node, obtain the working node list; F4, after obtaining the working node list, the monitoring node sends an offline notification to one or more working nodes in the working node list to instruct the working node to no longer actively trigger heartbeat detection to the monitoring node; F5, if the current server is a working node, obtain the address information of the monitoring node; F6, after the working node obtains the address of the monitoring node, it cancels the working node information to the monitoring node, for example, cancels the identifier of the first service and its own IP address, so that the monitoring node stops the heartbeat detection for the working node.
[0208] In summary, in the server cluster architecture provided by the embodiment of the present application, multiple servers are deployed in a cluster. In order to achieve the purpose of cache monitoring, at least one server in the cluster is set as a monitoring node to monitor the cache consistency of other servers and control other servers to perform cache operations. At the same time, in the server cluster architecture, the problem of communication reliability between the monitoring node and the working node is also solved, and the reliability of the cache monitoring solution is improved.
[0209] Corresponding to the parameter configuration method and server cluster architecture given in the above embodiment, the embodiment of the present application also provides a cache framework. The cache framework can be a class library (Library) deployed in the server so that the server can execute the method provided by the method embodiment of the present application. Among them, the class library is a reusable code collection that contains functions, objects, and tools that are frequently used in programming. It provides a way to abstract common code and encapsulate it into a reusable module, allowing developers to develop applications more efficiently.
[0210] See also Fig. 9 A cache framework provided in an embodiment of the present application includes five modules: an interface facade module, a parsing & execution module, a node management module, a strategy selection module, and a message management module.
[0211] Among them, the interface facade module provides external capabilities, that is, external devices or programs can trigger the server to perform cache operations such as cache query, cache cleaning, JVM cluster cleaning, etc. through the interface facade module.
[0212] The parsing & execution module is used to provide the call logic for executing the cache declaration file, that is, the parsing & execution module can be used to parse and load the cache declaration file. At the same time, the parsing & execution module can also be used to perform operations such as link management, command execution, and synchronous monitoring. Among them, link management refers to the management of the communication links established between different servers. For example, when cache cleanup is required across servers, the parsing & execution module can be used to find the link of the corresponding target server so as to trigger the target server to perform cache cleanup based on the connection; command execution refers to executing corresponding cache operations based on the cache execution command, such as cache query, cache cleanup, etc.; synchronous monitoring refers to monitoring whether the data in the current server is consistent with that in the database.
[0213] The node management module is used to provide service nodes using the framework with capabilities such as startup monitoring, deregistration monitoring, and heartbeat detection between services. The node management module supports different message types, such as http, kafka, redis, etc. The parsing & execution module can select different message components based on policies.
[0214] Storage is used to implement the cache function. The storage can support different types of storage, such as redis or jvm. The parsing & execution module can select different storage based on the strategy.
[0215] The message management module is used to provide message communication and synchronization functions between service nodes using the framework.
[0216] The following example illustrates the process of the server executing the method embodiment provided in this application through the cache framework. For steps that are not described in detail, please refer to the description of the method embodiment section.
[0217] For example, after the server is started, the node management module starts monitoring. For specific solutions, please refer to Figure 3 The description of step A1 in . At the same time, the node management module loads the parsing & execution module. Then, the parsing & execution module loads the first cache declaration file corresponding to the first business (assuming that the first cache declaration file is a file in yaml format), parses the corresponding file format to obtain the first cache configuration information, and stores it in the memory in the form of key-value.
[0218] On the other hand, the parsing & execution module can load the corresponding memory module and message management module according to the business policy.
[0219] When the business system calls the parsing & execution module through the interface facade module to perform a cache operation, the parsing execution module can select the corresponding storage based on the policy to perform the corresponding cache operation. In addition, in some scenarios, the parsing & execution module can also call the message management module to notify other servers to perform the corresponding cache operation. Fig.10 Lists some cache operations.
[0220] In the first example, the business system executes an IP query to the jvm cache. The cache framework can first query the IP information corresponding to the business, and then obtain the jvm cache interface according to the IP, so that the jvm cache can be queried based on the jvm cache interface.
[0221] In the second example, the business system specifies an IP address to clean up the JVM cache. The cache framework can first query the IP address information corresponding to the business, and then clean up the JVM cache based on the IP address.
[0222] In the third example, the business system instructs to clean up all jvm caches. Since jvm is a decentralized cache storage, the cache framework can distribute messages through the message component to instruct other servers in the cluster to clean up the jvm cache. Correspondingly, other servers monitor messages through the cache framework and clean up the jvm cache according to the monitored messages.
[0223] In the fourth example, the business system specifies an IP to query the redis cache. The cache framework can first query the IP information corresponding to the business, and then obtain the redis cache interface based on the IP, so that the redis cache can be queried based on the redis cache interface.
[0224] In the fifth example, the business system specifies an IP address to clear the redis cache. Since redis is a centralized cache storage, the servers in the cluster can perform redis cache operations synchronously. Therefore, in this case, the cache framework can first query the redis configuration information corresponding to the business, and then clear the redis cache based on the configuration information.
[0225] It is understandable that if Figure 5 The server cluster architecture shown executes Fig.10 If the cache operation flow is shown, Fig.10 In the table shown, the cache operation process in the second column is executed by the working node through the built-in cache framework, and the cache operation process is triggered and executed by the monitoring node.
[0226] As can be seen from the above scheme, the cache framework provided in the embodiment of the present application provides a complete set of centrally managed cache mechanisms, which can effectively monitor and process the cache. At the same time, the cache framework provided by the present application provides a set of lightweight integration solutions that can be flexibly tailored. When minimizing the integration, there is no need to deploy other components or servers. Therefore, it can be applied to various scenarios and reduce the difficulty of integrating the solution. Specifically, the storage and message components in this application support a variety of different types of objects, which can be freely selected or expanded according to specific strategies. The following is combined with Fig.11Brief introduction: In step G1, the processor obtains the first cache configuration information. For the specific process, please refer to Figure 3 The corresponding description of steps A2 and A3 in ; then in step G2, based on the first cache configuration information, the policy context is called to obtain all policies; finally, in step G3, the corresponding policy object is generated according to the policy. Specifically, the storage and message components can be uniformly obtained through the policy context, and the corresponding policy object is generated according to the policy code of the business configuration. The policy pattern is used in the code for decoupling. By providing a unified application programming interface (application programming interface, api) for storage and a unified api for message communication (see Fig. 9 The storage API in the memory and the message API in the message management module) can be used to implement new memory and message components by extending the unified API. Therefore, flexible expansion can be achieved, so that the cache framework provided in the embodiment of the present application can adapt to more scenarios.
[0227] Corresponding to the methods provided in the above-mentioned method embodiments, the embodiments of the present application also provide a corresponding server. Fig.12 A server 1200 provided in an embodiment of the present application is shown, and the server 1200 includes: at least one processor 1210, a memory 1220, and a computer program 1221 stored in the memory and executable on the at least one processor, and the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.
[0228] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0229] An embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, a mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0230] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0231] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0232] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0233] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0234] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0235] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
[0236] In addition, it should be noted that the various numerical numbers involved in this application (such as the terms "first", "second", "third", "fourth" and other various terminology labels (if any) in the specification and claims and the above-mentioned drawings) are only distinguished for the convenience of description and are not used to limit the scope of this application. The size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic.
[0237] The terms "including" and "having" and any variations thereof mean "including but not limited to" unless specifically emphasized otherwise. For example, a process, method, system, product or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed but may include other steps or units not explicitly listed or inherent to such process, method, product or apparatus.
[0238] In the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0239] In the various embodiments of the present application, if there is no special explanation and logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships. The specific operating methods in the method embodiments of the present application can also be applied to device embodiments or system embodiments.
[0240] The "storage" or "saving" involved in the embodiments of the present application may refer to saving in one or more memories. The one or more memories may be set separately or integrated in an encoder or decoder, a processor, or an electronic device. The one or more memories may also be partially set separately and partially integrated in a decoder, a processor, or an electronic device. The type of memory may be any form of storage medium, which is not limited by the present application.
[0241] In the schematic diagrams of the drawings in the specification of this application, the dashed lines or boxes represent optional steps or optional modules, and the dotted lines or boxes represent the contents of the annotations.
Claims
1. A parameter configuration method, applied to a server, characterized in that: The method comprises: Obtaining a first cache declaration file, and loading first cache configuration information corresponding to the first service based on the first cache declaration file, wherein the first cache declaration file is used to centrally declare parameters in the first cache configuration information; triggering a cache operation for cache data of the first service based on the first cache configuration information; The cache operation includes one or more of the following: querying cache data of the first service, adding cache data of the first service, deleting cache data of the first service, and modifying cache data of the first service.
2. The method according to claim 1, characterized in that The first cache configuration information includes one or more of the following parameters: Cache type, cache storage, cache description information, cache key, description information of the cache key, example of the cache key, cache value, description information of the cache value, example of the cache value, cache monitoring prompt, expiration time of the cache configuration information, and business custom data loading path information.
3. The method according to claim 1 or 2, characterized in that: After obtaining the first cache declaration file, the method further includes: Upon receiving the change reminder information, obtaining a second cache declaration file, and loading the second cache configuration information corresponding to the second service based on the second cache declaration file, wherein the change reminder information is used to indicate that the first cache configuration information is updated to the second cache configuration information, the second service is the first service or a service after the update iteration of the first service, and the second cache declaration file is used to centrally declare the parameters in the second cache configuration information; A cache operation for the cache data of the second service is triggered based on the second cache configuration information.
4. The method according to claim 1 or 2, characterized in that: Triggering a cache operation for cache data of the first service based on the first cache configuration information includes: Determining a node type of the server according to the first cache configuration information; In the case where the server is a monitoring node, obtaining a working node list, the working node list including Internet Protocol addresses of one or more working nodes, the monitoring node corresponding to the one or more working nodes, and the monitoring node being used to control the one or more working nodes to perform the cache operation; Trigger an i-th working node among the one or more working nodes to perform a cache operation on the cache data of the first service, where i is a positive integer greater than or equal to 1.
5. The method according to claim 4, characterized in that The method further comprises: Detecting the reachability of the i-th working node; When the i-th working node is unreachable, an alarm message is sent, where the alarm message is used to indicate that the i-th working node is unreachable.
6. The method according to claim 5, characterized in that The detecting the reachability of the i-th working node includes: Receiving a response message periodically sent by the i-th working node, wherein the response message is used to respond to the heartbeat detection message sent by the server; If the response message is not received within the preset reach period, it is determined that the i-th working node is unreachable.
7. The method according to claim 5 or 6, characterized in that: The method further comprises: Receiving a notification message from the i-th working node, where the notification message is used to indicate that the i-th working node is offline; In response to the notification message, stop detecting the reachability of the i-th working node.
8. The method according to claim 4, characterized in that The triggering the i-th working node among the one or more working nodes to perform a cache operation on the cache data of the first service includes: When it is monitored that the cache data of the first business stored on the i-th working node is inconsistent with the cache data in the persistent database of the first business, the i-th working node is triggered to clear the locally stored cache data of the first business and re-download the cache data of the first business from the persistent database.
9. The method according to claim 4, characterized in that The triggering the i-th working node among the one or more working nodes to perform a cache operation on the cache data of the first service includes: receiving a cache operation request message, where the cache operation request message is used to request to perform the cache operation on the cache data of the first service; In response to the cache operation request message, trigger the i-th working node to perform the cache operation.
10. The method according to claim 1 or 2, characterized in that: Triggering a cache operation for cache data of the first service based on the first cache configuration information includes: Determining a node type of the server according to the first cache configuration information; In the case where the server is a working node, a monitoring node is determined according to the first cache configuration information, the monitoring node corresponds to the working node, and the monitoring node is used to control the working node to perform the cache operation; Receiving a cache operation request message from the monitoring node; In response to the cache operation request message, the cache operation is performed on the cache data of the first service.
11. The method according to claim 10, characterized in that The method further comprises: The service identifier of the first service and the IP address of the working node are reported to the monitoring node at a regular interval.
12. The method according to claim 10, characterized in that The method further comprises: When the first cache configuration information indicates that the cache type corresponding to the first business is JVM, and the cache operation includes deleting the cache data of the first business, a cache synchronization message is sent to other nodes, and the cache synchronization message is used to instruct the other nodes to delete the cache data of the first business. The working node and the other nodes belong to the same cluster, and the other nodes correspond to the monitoring node.
13. The method according to claim 10, characterized in that The method further comprises: When it is determined that the working node is offline, a notification message is sent to the monitoring node, where the notification message is used to indicate that the working node is offline.
14. The method according to claim 1 or 2, characterized in that: The loading of the first cache configuration information corresponding to the first service based on the first cache declaration file includes: Parsing the first cache declaration file to obtain the first cache configuration information, and storing the first cache configuration information in a memory; Generate a session factory according to the file type of the first cache declaration file; Using the session factory to create a cache session object, the cache session object is used to perform the cache operation; Determine a cache memory type according to the first cache configuration information; A cache execution object is determined according to the cache memory type and a corresponding synchronization listener is generated.
15. A server, characterized in that: The structure of the electronic device includes a processor and a memory; The memory is used to store a program that supports the electronic device to execute the method provided by any one of claims 1 to 14, and to store data involved in implementing the method according to any one of claims 1 to 14; The processor is configured to execute the program stored in the memory.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Information processing method and system, computer system and computer readable medium
CN110221829A
Event server using caching
US20090292877A1
Work management with claims / priority assignment and dynamic work allocation
US20170076242A1
Work management with claims caching and dynamic work allocation
US20170076247A1