Optimizing distributed caching methods and related products
By obtaining data requests and business rules for secondary cache processing, the problem of high-frequency reading of Redis cache in a distributed cache environment is solved, improving efficiency and reducing the pressure on Redis services.
Patent Information
- Application Number
- CN202011353141.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-26
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2040-11-26
AI Technical Summary
In a distributed cache environment, it is easy to cause connection queues and connection count exceeding the limit when reading Redis cache at high frequency, which affects performance.
By obtaining data requests, obtaining business rules for target data, determining business logic based on these rules, performing secondary cache processing, optimizing the reading process of Redis cache, and reducing the pressure on Redis services.
Improves the efficiency of high-frequency reading of Redis cache, avoids the problem of connection queues and exceeds the limit of connections, and improves system performance.
Smart Images

Figure CN114547185B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for optimizing distributed caching and related products. Background Art
[0002] Redis (Remote Dictionary Server) is an open source key-value database written in ANSI C language of the American National Standards Institute, which supports the network, can be based on memory or persistence, and provides application programming interface (API) in multiple languages.
[0003] Redis is often used to cache data that needs to be reused. Compared with the relational database management system MySQL database, Redis has performance advantages in reading and writing. The connection between Redis and microservices is communicated through the Transmission Control Protocol (TCP) / Internet Protocol (IP), and the Redis service usually sets a maximum upper limit on the number of client connections. In order to solve the connection limit problem, microservice clients often use connection pools to control the maximum number of client connections to prevent the connection from being rejected due to the number of connections exceeding the maximum upper limit set by Redis. After the microservice client introduces the connection pool client, high-frequency requests to Redis within the microservice will be queued. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to provide a method for optimizing distributed caching and related products, which can solve the problem of high-frequency reading of Redis cache in a distributed secondary cache environment.
[0005] In a first aspect, an embodiment of the present application provides a method for optimizing distributed caching, the method comprising:
[0006] Get data request for L2 cache processing operation;
[0007] Obtaining target data of the data request from a primary cache and / or a database in a remote dictionary server (Redis) according to the data request;
[0008] Obtaining business rules corresponding to the target data;
[0009] Determine M business logics corresponding to the business rule, where M is a positive integer;
[0010] The target data is processed by secondary cache through the M business logics.
[0011] In a second aspect, an embodiment of the present application provides a device for optimizing distributed cache, the device comprising:
[0012] A first acquisition unit, used to acquire a data request for a secondary cache processing operation;
[0013] A second acquisition unit is used to acquire the target data of the data request from the first-level cache and / or database in a remote dictionary service (Remote Dictionary Server, Redis) according to the data request;
[0014] A third acquisition unit, used to acquire the business rules corresponding to the target data;
[0015] A determination unit, used to determine M business logics corresponding to the business rule, where M is a positive integer;
[0016] The cache unit is used to perform secondary cache processing on the target data through the M business logics.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps of any method in the first aspect of the embodiment of the present application.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in any method of the first aspect of the embodiment of the present application.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any method of the first aspect of the embodiment of the present application. The computer program product may be a software installation package.
[0020] It can be seen that in the embodiment of the present application, a data request for a secondary cache processing operation is obtained; the target data of the data request is obtained from the primary cache and / or database in the remote dictionary server (Redis) according to the data request; the business rules corresponding to the target data are obtained; M business logics corresponding to the business rules are determined; and the target data is cached at the secondary level through the M business logics. The embodiment of the present application performs secondary cache processing on the target data through business rules, which can solve the problem of high-frequency reading of Redis cache in a distributed secondary cache environment and improve the efficiency of high-frequency reading of Redis cache. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 A schematic diagram of a scenario for optimizing distributed caching provided in an embodiment of the present application;
[0023] Figure 2 A schematic diagram of a flow chart of a method for optimizing distributed caching provided in an embodiment of the present application;
[0024] Figure 3 A schematic diagram of a flow chart of a method for optimizing distributed caching provided in an embodiment of the present application;
[0025] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0026] Figure 5 It is a block diagram of the functional units of an optimized distributed cache device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0028] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0029] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0030] Redis (Remote Dictionary Server) is an open source key-value database written in ANSI C language of the American National Standards Institute, which supports the network, can be based on memory or persistence, and provides application programming interface (API) in multiple languages.
[0031] Redis is often used to cache data that needs to be reused. Compared with the relational database management system MySQL database, Redis has performance advantages in reading and writing. The connection between Redis and microservices is communicated through the Transmission Control Protocol (TCP) / Internet Protocol (IP), and the Redis service usually sets a maximum upper limit on the number of client connections. In order to solve the connection limit problem, microservice clients often use connection pools to control the maximum number of client connections to prevent the connection from being rejected due to the number of connections exceeding the maximum upper limit set by Redis.
[0032] After the microservice client introduces the connection pool client, high-frequency requests to Redis within the microservice will be queued, so the maximum value of the connection pool becomes the key indicator for optimizing connections. If the connection pool is too large, the number of Redis service connections will exceed the limit.
[0033] In order to solve the problem of high-frequency reading of Redis cache in a distributed environment, the business rules obtained from the Redis service are saved in the memory of the local thread, and the local service gives priority to reading the data in the memory of the local thread. The local thread sets a refresh frequency and updates the cached data in the Redis service at a fixed frequency. In this way, for most non-real-time businesses, this secondary cache strategy can greatly improve the performance of the service and reduce the pressure on the Redis service.
[0034] The following is a detailed description of the embodiments of the present application.
[0035] See also Figure 1 , Figure 1 This is a schematic diagram of a scenario for optimizing distributed cache provided by an embodiment of the present application. If the data in the MySQL database changes, the changed data is synchronized to the first-level cache data in Redis, and the first-level cache data of Redis is synchronized to the microservice in the distributed application service according to a certain fixed frequency. According to the memory business rules in the microservice, M business logics are determined, and the M business logics cache the first-level cache data of Redis.
[0036] This application provides a method for optimizing distributed caching, specifically: Figure 2 As shown, the method may include but is not limited to the following steps:
[0037] S201, the electronic device obtains a data request for a secondary cache processing operation;
[0038] In a specific implementation, the electronic device obtains a data request for a secondary cache processing operation, including: when the content of a database changes, the electronic device obtains a data request for a secondary cache processing operation.
[0039] S202, the electronic device obtains target data of the data request from the primary cache and / or database in the remote dictionary server (Redis) according to the data request;
[0040] Among them, the above-mentioned target data may include any of the following data: vehicle positioning data, vehicle fuel level data, vehicle interior temperature data, vehicle speed data, and behavior data of the first user corresponding to the vehicle on the vehicle-related application APP. The target data may also be other types of data, which will not be explained in detail here.
[0041] In a specific implementation, the electronic device obtains the target data of the data request from the first-level cache and / or database in the remote dictionary service (Redis) according to the data request, including but not limited to: the electronic device determines whether the first data in the first-level cache in the Redis exists according to the data request; if so, obtains the first data in the first-level cache, and the first data is the target data.
[0042] The database may be a MySQL database or other databases, and no excessive restrictions are imposed here.
[0043] Among them, the first data in the first-level cache in Redis may include any of the following data: vehicle positioning data, vehicle fuel data, vehicle interior temperature data, vehicle speed data, and behavior data of the first user corresponding to the vehicle on the vehicle-related application APP. The target data may also be other types of data, which will not be explained in detail here.
[0044] It should be explained that the electronic device obtains the first data of the first-level cache by obtaining the first-level cache data of Redis at a third frequency. The third frequency may be a fixed frequency, a frequency determined according to the data type of the target data, or a frequency set by the user.
[0045] It needs to be further explained that when the third frequency is a frequency determined according to the data type of the target data, the third frequency may be determined by the following specific steps:
[0046] If the target data is of the first data type, determining the third frequency to be the first preset frequency;
[0047] If the target data is of the second data type, the third frequency is determined to be the second preset frequency.
[0048] The first data type may be any one of the following: vehicle positioning data, vehicle fuel level data, vehicle interior temperature data, vehicle speed data, and behavior data of the first user corresponding to the vehicle on a vehicle-related application APP. The second data type may be any one of the following: vehicle positioning data, vehicle fuel level data, vehicle interior temperature data, vehicle speed data, and behavior data of the first user corresponding to the vehicle on a vehicle-related application APP. The first data type is different from the second data type.
[0049] The first preset frequency may be the frequency of synchronization of the microservice to Redis measured based on the target data of the first data type, which is an empirical value set by the user. The second preset frequency may be the frequency of synchronization of the microservice to Redis measured based on the target data of the second data type, which is an empirical value set by the user. The first preset frequency may be the same as or different from the second preset frequency.
[0050] In a specific implementation, the electronic device obtains the target data of the data request from the first-level cache and / or database in the remote dictionary service (Redis) according to the data request, including but not limited to: the electronic device determines whether the first data in the first-level cache in the Redis exists according to the data request; if not, obtains the second data in the database, and the second data is the target data.
[0051] Among them, the second data in the database may include any of the following data: vehicle positioning data, vehicle fuel level data, vehicle interior temperature data, vehicle speed data, and behavior data of the first user corresponding to the vehicle on the vehicle-related application APP. The target data may also be other types of data, which will not be explained in detail here.
[0052] It should be explained that if the second data in the database changes, the electronic device clears the third data in the first-level cache corresponding to the second data in the Redis.
[0053] S203, the electronic device obtains the business rules corresponding to the target data;
[0054] In a specific implementation, the obtaining of the business rules corresponding to the target data includes: the electronic device obtaining a second frequency; and the electronic device obtaining the business rules corresponding to the target data according to the second frequency.
[0055] Among them, the business rules may be that the vehicle's interior temperature is greater than or equal to a first temperature, the vehicle's interior temperature is less than a second temperature, the vehicle's positioning is beyond a first positioning area, the vehicle's positioning is within a second positioning area, the vehicle's speed is greater than a first speed, the vehicle's speed is less than a second speed, the vehicle's fuel volume is less than or equal to a first capacity, etc. The business rules may also be rules formulated based on other types of data types. The above business rules are merely examples, and no excessive restrictions are placed on the business rules here.
[0056] The first temperature can be 37 degrees, 38 degrees, 39 degrees, 37.5 degrees, etc., and the first temperature can also be other temperatures, without too many restrictions here. The second temperature can be 37 degrees, 38 degrees, 39 degrees, 37.5 degrees, etc., and the second temperature can also be other temperatures, without too many restrictions here. The first speed can be 80m / s, 60m / s, 70m / s, 65m / s, 90m / s, etc., and the first speed can also be other speeds, without too many restrictions here. The second speed can be 80m / s, 60m / s, 70m / s, 65m / s, 90m / s, etc., and the second speed can also be other speeds, without too many restrictions here. The first capacity can be 0.5L, 0.8L, 1L, 0.1L, 0.3L, etc., and the first capacity can also be other capacities, without too many restrictions here.
[0057] S204, the electronic device determines M business logics corresponding to the business rule;
[0058] Here, M is a positive integer, for example, M is a positive integer such as 1, 2, 3, 4, 6, 7, 8, 9, 10, 20, 25, etc., and no excessive restrictions are given here.
[0059] Among them, the M business logics can be the same business logic or different business logics. Business logic is a description of the process of completing each business feature by combining building block components (SIB) and basic call processing (BCP) modules in the intelligent network. The intelligent network is a network structure system used to generate and provide new telecommunications services. It is mainly composed of service exchange points, service control points, service management points and service creation points. The main goal is to achieve the rapid introduction of new services.
[0060] In a specific implementation, the electronic device determines the M business logics corresponding to the business rules, including: the electronic device determines the M business logics corresponding to the business rules according to a mapping relationship between the business rules and the business logics.
[0061] The mapping relationship between the business rules and the business logics may be determined through the following specific steps: the electronic device obtains the business rules, and determines M business logics according to the data types of the to-be-processed data corresponding to the business rules.
[0062] S205. The electronic device performs secondary cache processing on the target data through M business logics.
[0063] In a specific implementation, before the electronic device performs secondary caching of the target data through the M business logics, it also includes: if the target data meets the business rules, the electronic device caches the target data in a first buffer according to a first frequency.
[0064] It can be seen that in the embodiment of the present application, a data request for a secondary cache processing operation is obtained; the target data of the data request is obtained from the primary cache and / or database in the remote dictionary server (Redis) according to the data request; the business rules corresponding to the target data are obtained; M business logics corresponding to the business rules are determined; and the target data is processed by the secondary cache through the M business logics. The embodiment of the present application performs secondary caching of target data through business rules, which can solve the problem of high-frequency reading of Redis cache in a distributed secondary cache environment and improve the efficiency of high-frequency reading of Redis cache.
[0065] The following is a detailed description of the embodiments of the present application through a specific example.
[0066] With the above Figure 2 The embodiment shown is consistent with that shown in FIG. Figure 3 , Figure 3 : is a flow chart of a method for optimizing distributed caching provided in an embodiment of the present application, the method comprising:
[0067] S301, the electronic device obtains a data request for a secondary cache processing operation;
[0068] S302, the electronic device determines whether the first data in the first-level cache of the remote dictionary service Redis exists according to the data request;
[0069] S303: If yes, the electronic device obtains first data of the first-level cache, where the first data is the target data;
[0070] The target data comes from a first-level cache and / or a database in a remote dictionary server (Remote Dictionary Server, Redis).
[0071] S304, the electronic device acquires a second frequency; and acquires a business rule corresponding to the target data according to the second frequency;
[0072] S305, the electronic device determines M business logics corresponding to the business rule;
[0073] Wherein, M is a positive integer.
[0074] S306. The electronic device performs secondary cache processing on the target data through M business logics.
[0075] It can be seen that in the embodiment of the present application, a data request for a secondary cache processing operation is obtained; based on the data request, it is determined whether the first data of the primary cache in the remote dictionary service Redis exists; if so, the first data of the primary cache is obtained, and the first data is the target data; a second frequency is obtained; based on the second frequency, the business rules corresponding to the target data are obtained; M business logics corresponding to the business rules are determined; and the target data is processed by the secondary cache through the M business logics. The embodiment of the present application processes the target data by performing secondary cache processing on the target data through business rules, which can solve the problem of high-frequency reading of Redis cache in a distributed secondary cache environment and improve the efficiency of high-frequency reading of Redis cache.
[0076] See also Figure 4 , Figure 4 4 is a structural diagram of an electronic device 400 provided in an embodiment of the present application. As shown in the figure, the electronic device 400 includes an application processor 410, a memory 420, a communication interface 430, and one or more programs 421, wherein the one or more programs 421 are stored in the above-mentioned memory 420 and are configured to be executed by the above-mentioned application processor 410, and the one or more programs 421 include for performing the following steps:
[0077] Get data request for L2 cache processing operation;
[0078] Obtaining target data of the data request from a primary cache and / or a database in a remote dictionary server (Redis) according to the data request;
[0079] Obtaining business rules corresponding to the target data;
[0080] Determine M business logics corresponding to the business rule, where M is a positive integer;
[0081] The target data is processed by secondary cache through the M business logics.
[0082] In one possible example, in terms of obtaining the target data of the data request from the first-level cache and / or database in the remote dictionary service (RemoteDictionary Server, Redis) according to the data request, the one or more programs 421 include functions for performing the following steps: determining whether the first data in the first-level cache in the Redis exists according to the data request; if so, obtaining the first data in the first-level cache, the first data being the target data.
[0083] In one possible example, in terms of obtaining the target data of the data request from the first-level cache and / or database in the remote dictionary service (RemoteDictionary Server, Redis) according to the data request, the one or more programs 421 include functions for performing the following steps: determining whether the first data in the first-level cache in the Redis exists according to the data request; if not, obtaining the second data in the database, the second data being the target data.
[0084] In a possible example, the one or more programs 421 also include a program for executing the following steps: if the second data in the database changes, clearing the third data in the first-level cache corresponding to the second data in the Redis.
[0085] In one possible example, before the target data is subjected to secondary caching through the M business logics, the one or more programs 421 also include a process for performing the following steps: if the target data meets the business rules, the target data is cached in a first buffer according to a first frequency.
[0086] In a possible example, in terms of obtaining the business rules corresponding to the target data, the one or more programs 421 include programs for performing the following steps: obtaining a second frequency; and obtaining the business rules corresponding to the target data according to the second frequency.
[0087] It can be seen that in the embodiment of the present application, a data request for a secondary cache processing operation is obtained; the target data of the data request is obtained from the primary cache and / or database in the remote dictionary server (Redis) according to the data request; the business rules corresponding to the target data are obtained; M business logics corresponding to the business rules are determined; and the target data is processed by the secondary cache through the M business logics. The embodiment of the present application processes the target data by performing secondary cache processing on the target data through business rules, which can solve the problem of high-frequency reading of Redis cache in a distributed secondary cache environment and improve the efficiency of high-frequency reading of Redis cache.
[0088] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the execution process on the method side. It is understandable that, in order to realize the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments provided herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware 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 the present application.
[0089] The embodiment of the present application can divide the electronic device into functional units according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0090] Figure 5 1 is a functional unit block diagram of an optimized distributed cache device 500 involved in an embodiment of the present application. The optimized distributed cache device 500 includes:
[0091] A first acquisition unit 501 is used to acquire a data request for a secondary cache processing operation;
[0092] A second acquisition unit 502 is used to acquire the target data of the data request from the first-level cache and / or database in a remote dictionary service (Remote Dictionary Server, Redis) according to the data request;
[0093] The third acquisition unit 503 is used to acquire the business rules corresponding to the target data;
[0094] A determining unit 504 is used to determine M business logics corresponding to the business rule, where M is a positive integer;
[0095] The cache unit 505 is used to perform secondary cache processing on the target data through the M business logics.
[0096] The optimized distributed cache device 500 further includes a storage unit 506. The storage unit may be a memory.
[0097] In a possible example, in terms of obtaining the target data of the data request from the first-level cache and / or database in the remote dictionary service (RemoteDictionary Server, Redis) according to the data request, the second acquisition unit 502 is specifically used to determine whether the first data in the first-level cache in the Redis exists according to the data request; if so, obtain the first data of the first-level cache, and the first data is the target data.
[0098] In a possible example, in terms of obtaining the target data of the data request from the first-level cache and / or database in the remote dictionary service (RemoteDictionary Server, Redis) according to the data request, the second acquisition unit 502 is specifically used to determine whether the first data in the first-level cache in the Redis exists according to the data request; if not, obtaining the second data in the database, the second data being the target data.
[0099] In a possible example, the optimized distributed cache device 500 is further used to clear the third data in the first-level cache corresponding to the second data in the Redis if the second data in the database changes.
[0100] In a possible example, before the target data is subjected to secondary caching through the M business logics, the optimized distributed cache device 500 is further used to cache the target data in a first buffer according to a first frequency if the target data meets the business rules.
[0101] In a possible example, in terms of acquiring the business rules corresponding to the target data, the third acquisition unit 503 is specifically configured to acquire a second frequency; and acquire the business rules corresponding to the target data according to the second frequency.
[0102] It can be seen that in the embodiment of the present application, a data request for a secondary cache processing operation is obtained; the target data of the data request is obtained from the primary cache and / or database in the remote dictionary server (Redis) according to the data request; the business rules corresponding to the target data are obtained; M business logics corresponding to the business rules are determined; and the target data is processed by the secondary cache through the M business logics. The embodiment of the present application processes the target data by performing secondary cache processing on the target data through business rules, which can solve the problem of high-frequency reading of Redis cache in a distributed secondary cache environment and improve the efficiency of high-frequency reading of Redis cache.
[0103] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0104] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.
[0105] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application. In the above embodiments, the description of each embodiment has its own emphasis, and for the parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0106] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which 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, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0107] The units described above 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.
[0108] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0109] If the above-mentioned 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 memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0110] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0111] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for optimizing distributed caching, characterized in that: The method comprises the following steps: Get data request for L2 cache processing operation; Determine whether the first data in the first-level cache in Redis exists according to the data request; if so, obtain the first data in the first-level cache at a third frequency, the first data is the target data, wherein the third frequency is a frequency determined according to the data type of the target data, if the target data is the first data type, determine the third frequency to be the first preset frequency, if the target data is the second data type, determine the third frequency to be the second preset frequency; if not, obtain the second data in the database, the second data is the target data; Acquire a second frequency; acquire a business rule corresponding to the target data according to the second frequency, wherein the business rule is a rule formulated according to a data type of the target data; If the target data satisfies the business rule, caching the target data in a first buffer according to a first frequency; Determine M business logics corresponding to the business rule according to the data type of the target data, where M is a positive integer; The target data is processed by secondary cache through the M business logics.
2. The method according to claim 1, further comprising: If the second data in the database changes, the third data in the first-level cache corresponding to the second data in Redis is cleared.
3. An optimized distributed cache device, characterized in that: The device comprises: A first acquisition unit, used to acquire a data request for a secondary cache processing operation; a second acquisition unit, configured to determine whether the first data of the first-level cache in Redis exists according to the data request; if so, to acquire the first data of the first-level cache at a third frequency, wherein the first data is target data, wherein the third frequency is a frequency determined according to the data type of the target data, and if the target data is the first data type, the third frequency is determined to be the first preset frequency, and if the target data is the second data type, the third frequency is determined to be the second preset frequency; if not, to acquire the second data in the database, wherein the second data is the target data; A third acquisition unit is used to acquire a second frequency; acquire a business rule corresponding to the target data according to the second frequency, wherein the business rule is a rule formulated according to a data type of the target data; A determination unit, configured to determine M business logics corresponding to the business rule according to a data type of the target data, where M is a positive integer; A cache unit is used to cache the target data in a first buffer according to a first frequency if the target data meets the business rules; and to perform secondary cache processing on the target data through the M business logics.
4. The device according to claim 3, wherein the cache unit Used to determine M business logics corresponding to the business rules; And used to perform secondary cache processing on the cache data of the first buffer through the M business logics.
5. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to claim 1 or 2.
6. A computer-readable storage medium, characterized in that: It stores a computer program for electronic data exchange, wherein the computer program causes a computer to execute the method as claimed in claim 1 or 2.
Citation Information
Patent Citations
Service rule matching processing method and device and processing equipment
CN108628947A
Configuration management method, system and device
CN110597739A
Data management method and device, server and storage medium
CN111666265A