CN115878711B - Redis connection pool realization method, device, equipment and medium - Google Patents

Redis connection pool realization method, device, equipment and medium Download PDF

Info

Publication number
CN115878711B
CN115878711B CN202310171967.5A CN202310171967A CN115878711B CN 115878711 B CN115878711 B CN 115878711B CN 202310171967 A CN202310171967 A CN 202310171967A CN 115878711 B CN115878711 B CN 115878711B
Authority
CN
China
Prior art keywords
redis
storage system
connection
client
connection pool
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310171967.5A
Other languages
Chinese (zh)
Other versions
CN115878711A (en
Inventor
陈娅芳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New Cloud Technology Group Co ltd
Original Assignee
New Cloud Technology Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by New Cloud Technology Group Co ltd filed Critical New Cloud Technology Group Co ltd
Priority to CN202310171967.5A priority Critical patent/CN115878711B/en
Publication of CN115878711A publication Critical patent/CN115878711A/en
Application granted granted Critical
Publication of CN115878711B publication Critical patent/CN115878711B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method, a device, equipment and a medium for realizing a Redis connection pool, which are applied to the field of information processing and comprise the following steps: acquiring a Redis configuration rule based on a Spring open source framework to configure a Redis storage system to obtain a configured Redis storage system; dynamically proxy middleware corresponding to the configured Redis storage system to a highly packaged class; carrying out connection pooling treatment on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients; and injecting all the connection pooling Redis clients into highly-packaged classes, and constructing a Redis unified connection pool. According to the invention, the Redis storage system is configured according to the Spring open source framework, so that the Redis connection pools are unified, the utilization rate of the connection pools is improved, and the pressure of the Redis server for connecting resources is reduced.

Description

Redis connection pool realization method, device, equipment and medium
Technical Field
The present invention relates to the field of information processing, and in particular, to a method, an apparatus, a device, and a medium for implementing a Redis connection pool.
Background
In the practical application scenario, various middleware needs to be cited or packaged for Redis (which is a fully open source, obeys the BSD protocol, is a high-performance key-value database), so that different Redis clients need to be configured for different middleware, and In the Spring open source framework (which is a lightweight open source framework In the Java EE programming field), the Redis clients commonly used In the Spring open source framework have Jedis (which is a Java language-based Redis client), lettuce (which is a high-performance Redis client, the bottom layer is connected based on the netty framework), redison (which is a Java resident Memory Data Grid (In-Memory Data Grid) erected on the Redis) and the like, each client is incompatible, and needs to be independently configured, so that a mutually independent connection pool is generated, and when the service scale is enlarged, a large number of connections are generated with the Redis cache server, so that connection resources of the Redis server are stressed, unnecessary connection resources are generated, and even normal service use is affected.
Disclosure of Invention
In view of the above, the present invention aims to provide a method, an apparatus, a device, and a medium for implementing a Redis connection pool, which solve the technical problem of resource waste of the Redis connection pool in the prior art.
In order to solve the technical problems, the invention provides a method for realizing a Redis connection pool, which comprises the following steps:
obtaining a Redis configuration rule based on a Spring open source framework to configure the Redis to obtain a configured Redis storage system;
dynamically proxy middleware corresponding to the configured Redis storage system to a highly packaged class;
performing connection pooling processing on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients;
and injecting all the connection pooling Redis clients into the highly-packaged class to realize construction of a Redis unified connection pool.
Optionally, the obtaining is based on Redis configuration rule pair Redis in Spring open source framework
The storage system is configured, and before the configured Redis storage system is obtained, the method further comprises the steps of:
the Redis storage system is subjected to the Redis configuration rule in the Spring open source framework
And configuring the corresponding Redis connection string, the Redis client type and the Redis connection pool to obtain the configured Redis storage system.
Optionally, the dynamically brokering the middleware corresponding to the configured Redis storage system to a highly encapsulated class includes:
and dynamically proxy the read-write operation of the Redis client to the highly packaged class by using the middleware corresponding to the Redis client and performing the dynamic proxy by facing to the tangent plane programming.
Optionally, the method connects all Redis clients according to the configured Redis storage system
Pool-receiving treatment, comprising:
performing connection pooling processing on the Jeddis client, the Lettuce client and the Redisson client according to the configured Redis storage system; the Redis client comprises the Jeddis client, the Lettuce client and the Redis client.
Optionally, after injecting all the connection pooling Redis clients into the highly encapsulated class to implement construction of a Redis unified connection pool, the method further includes:
acquiring metadata stored in the Redis storage system;
receiving an access request of any Redis client;
acquiring connection from the Redis unified connection pool according to the access request;
acquiring corresponding target metadata from the metadata through the connection, and operating to obtain the operated target metadata;
and continuously storing the operated target metadata in the Redis storage system, and releasing the connection.
Optionally, after the continuously storing the target metadata after the operation in the dis storage system and releasing the connection, the method further includes:
acquiring the time period of the metadata stored in the Redis storage system;
and judging whether the metadata stored in the Redis storage system is still in the time period, and if not, extracting the metadata from the Redis storage system, returning the metadata to a database and deleting the metadata.
The invention also provides a device for realizing the Redis connection pool, which comprises:
the Redis configuration module is used for acquiring a Redis configuration rule in the Spring open source framework to configure the Redis to obtain a configured Redis storage system;
the agent module is used for dynamically agent the middleware corresponding to the configured Redis storage system to a highly packaged class;
the connection pooling module is used for carrying out connection pooling processing on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients;
a Redis unified connection pool implementation module for injecting all the connection pooled Redis clients into the network
And the highly packaged class realizes the construction of a Redis unified connection pool.
Optionally, the Redis configuration module includes:
the Redis configuration unit is used for configuring a Redis connection string, a Redis client type and a Redis connection pool corresponding to the Redis storage system according to the Redis configuration rule in the Spring open source framework to obtain the configured Redis storage system.
The invention also provides a device for realizing the Redis connection pool, which comprises:
a memory for storing a computer program;
and the processor is used for realizing the steps of the method for realizing the Redis connection pool when executing the computer program.
The invention also provides a computer readable storage medium, on which a computer program is stored, which when being executed by a processor, implements the steps of the implementing method of the Redis connection pool described above.
Therefore, the invention configures the Redis storage system by acquiring the Redis configuration rule based on the Spring open source framework to obtain the configured Redis storage system; dynamically proxy middleware corresponding to the configured Redis storage system to a highly packaged class; performing connection pooling processing on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients; and injecting all the connection pooling Redis clients into the highly-packaged class to realize construction of a Redis unified connection pool. Compared with a connection pool corresponding to a client in the prior art, the implementation of the Redis connection pool provided by the embodiment of the invention can configure a Redis storage system according to the Redis configuration rule in the Spring open source framework, and further perform dynamic proxy and connection pooling processing, so that unification of the Redis client corresponding to the Redis connection pool is realized, the utilization rate of the Redis client connection pool is improved, and the pressure of the Redis cache server for connecting resources is reduced.
In addition, the invention also provides a device, equipment and medium for realizing the Redis connection pool, which have the same beneficial effects.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for implementing Redis connection pool provided by an embodiment of the invention;
FIG. 2 is a flowchart illustrating a method for implementing Redis connection pool according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an implementation device of a Redis connection pool according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an implementation device of a Redis connection pool according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, fig. 1 is a flowchart of a method for implementing a dis connection pool according to an embodiment of the present invention. The method may include:
s100, obtaining a Redis configuration rule in a Spring open source framework to configure a Redis storage system, and obtaining a configured Redis storage system.
This embodiment does not limit the timing of obtaining a configured Redis storage system. For example, before the configured Redis storage system is acquired, the Redis storage system may be configured in advance based on a Redis configuration rule in the Spring open source framework; or, the Redis storage system can be temporarily configured based on the Redis configuration rule in the Spring open source framework when the configured Redis storage system is required.
S101, dynamically proxy the middleware corresponding to the configured Redis storage system to the highly packaged class.
The embodiment is not limited to a specific method of performing dynamic proxy. For example, middleware corresponding to the configured Redis storage system can be dynamically proxied to Spring Redis Template (highly encapsulated class) in a reflection mode, and a reflection mechanism is a basic function provided by Java (static object-oriented programming language) language, so that a program is endowed with an introspection (introspin) capability during running. Simply by reflection, the properties and methods of the object can be acquired, detected and invoked during run-time. Or, dynamically proxy the middleware corresponding to the configured Redis storage system in an interception mode, and proxy to Spring Redis Template. It will be appreciated that Middleware (english: middleware) is software that provides a connection between system software and application software, so as to facilitate communication between components of the software, and in particular, centralized logic of the application software to the system software, which is widely applied in modern information technology application frameworks such as Web services, service oriented architecture, and the like, and that Middleware corresponding to the configured dis storage system may be a module in the configured dis storage system that implements connection to the application software.
S102, carrying out connection pooling processing on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients.
According to the embodiment, connection pooling processing is carried out on all Redis clients according to the configured Redis storage system, and the corresponding number of connection pooling Redis clients is obtained. The embodiment does not limit the acquisition mode of the Redis client, for example, the Redis client can be actively identified and acquired; or the Redis client can be obtained passively according to the identification instruction. This embodiment does not limit the specific number of connection pooling Redis clients. For example, the number of connection pooling Redis clients may be 5; or the number of connection pooling Redis clients can be 10; or the number of connection pooling Redis clients may also be 20. Connection pool in this embodiment refers to a pool (set) of a set of connections, a connection pool being a technique of creating and managing a buffer pool of connections that are ready for use by any thread that needs them. Connection pooling in this embodiment refers to pooling of connection pools. Pooling (Pool) is a very common programming technique, and can obviously optimize application performance when the request amount is large, and reduce the resource overhead of the system for frequently establishing connection. The common database connection pool, thread pool and object pool in daily work are characterized in that expensive and time-consuming resources are maintained in a specific pool, the configuration of the minimum connection number, the maximum connection number, the blocking queue and the like is regulated, unified management and multiplexing are convenient, and a plurality of matching functions such as detection and activation mechanisms, forced recovery and monitoring are usually carried out.
S103, injecting all the connection pooling Redis clients into highly-packaged classes to realize construction of a Redis unified connection pool.
In the embodiment, the construction of the Redis unified connection pool is realized by injecting Spring Redis Template (highly encapsulated class) all the connection pooling Redis clients, and the unified connection pool resource management of various Redis clients is realized.
Further, in order to rapidly implement the configuration of the dis storage system, before the obtaining the configuration of the dis storage system based on the dis configuration rule in the Spring open source framework, the method may further include:
and configuring the Redis connection strings, the Redis client types and the Redis connection pools corresponding to the Redis storage system according to the Redis configuration rules in the Spring open source framework to obtain the configured Redis storage system.
According to the embodiment, a Redis connection string, a Redis client type and a Redis connection pool corresponding to a Redis storage system are configured according to a Redis configuration rule in a Spring open source framework, so that a configured Redis storage system is obtained. In the embodiment, the Redis connection string, the Redis client type and the Redis connection pool are considered to be important configuration parameters in the process of pooling the Redis client connection, so that the Redis connection string, the Redis client type and the Redis connection pool are selected for configuration. The embodiment rapidly realizes the configuration of the Redis storage system by reducing the configuration parameters.
Further, in order to improve the reusability of the program, the foregoing dynamically brokering the middleware corresponding to the configured dis to the highly encapsulated class may include:
and dynamically proxy the read-write operation of the Redis client to the highly packaged class by using the middleware corresponding to the Redis client and performing the dynamic proxy by facing to the tangent plane programming.
AOP (Aspect Oriented Programming, slice-oriented programming) in this embodiment is a technique that enables unified maintenance of program functions through precompiled means and dynamic agents during runtime. AOP is a continuation of OOP (Object Oriented Programming, object-oriented programming), a hotspot in software development, an important content in Spring open source framework, and a derivative model of functional programming. The AOP is utilized to isolate each part of the business logic, so that the coupling degree among the parts of the business logic is reduced, the reusability of the program is improved, and the development efficiency is improved.
Further, in order to implement dynamic proxy of multiple clients, the foregoing connection pooling process for all the Redis clients according to the configured Redis storage system may include:
performing connection pooling processing on the Jeddis client, the Lettuce client and the Redis client according to the configured Redis storage system; the Redis client comprises a Jeddis client, a Lettuce client and a Redis client.
This embodiment considers that three currently mainstream Redis clients (Jedis, lettuce, redisson) are implemented based on two communication modes, one is a Jeddis (Redis client based on java language) implemented based on a Socket (Socket, a contract or a mode of communication between computers), and the other is a Lettuce and Redisson implemented based on Netty (an asynchronous event-driven network application framework for rapidly developing maintainable high-performance protocol servers and clients), and the principle of no duplicate wheel creation is adopted, so that the edis client, the Lettuce client and the Redisson client are selected to perform connection pooling processing, so that dynamic proxy of multiple clients is implemented.
Further, in order to quickly acquire the target metadata, after injecting all the connection pooling Redis clients into the highly encapsulated class and implementing the construction of the Redis unified connection pool, the method may further include:
acquiring metadata stored in a Redis storage system;
receiving an access request of any Redis client;
obtaining connection from the Redis unified connection pool according to the access request;
acquiring corresponding target metadata from the metadata through connection, and performing operation to obtain the operated target metadata;
and continuously storing the operated target metadata in a Redis storage system, and releasing the connection.
In order to extract the target metadata in time and realize the operation of the target metadata, the embodiment stores the metadata in a Redis storage system. The embodiment is not limited to a specific operation performed on the target metadata. For example, the operation on the target metadata may be compiling to generate an executable file; alternatively, the operation on the target metadata may be unifying the data format of the target metadata; alternatively, the operation on the target metadata may be storing the target metadata in a corresponding data set. In the embodiment, after the target metadata after operation is continuously stored in the Redis storage system, the connection can be released in time, so that the influence on the subsequent use is prevented. It can be understood that the common metadata is stored in the Redis storage system, when connection is needed, the target metadata can be timely obtained, the connection can be timely released, and the network load is reduced.
Further, in order to increase the storage space of the database, after the above-mentioned storing the target metadata after the operation in the Redis storage system and releasing the connection, the method may further include:
acquiring the aging period of metadata stored in a Redis storage system;
and judging whether the metadata stored in the Redis storage system is still in the time period, and if not, extracting the metadata from the Redis storage system, returning the metadata to the database and deleting the metadata.
This embodiment obtains the age of metadata stored in the Redis storage system; and judging whether the metadata stored in the Redis storage system is still in the time period, and if not, extracting the metadata from the Redis storage system, returning the metadata to the database and deleting the metadata. Since metadata not in the expiration period can be deleted in time, the storage space of the database can be increased.
According to the implementation method of the Redis connection pool, provided by the embodiment of the invention, the Redis storage system is configured by acquiring the Redis configuration rule based on the Spring open source framework, so that the configured Redis storage system is obtained; dynamically proxy middleware corresponding to the configured Redis storage system to a highly packaged class; carrying out connection pooling treatment on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients; and injecting all the connection pooling Redis clients into highly-packaged classes, and constructing a Redis unified connection pool. Compared with a connection pool corresponding to a client in the prior art, the implementation of the Redis connection pool provided by the embodiment of the invention can configure a Redis storage system according to the Redis configuration rule in the Spring open source framework, and further perform dynamic proxy and connection pooling processing, so that unification of the Redis client corresponding to the Redis connection pool is realized, the utilization rate of the Redis client connection pool is improved, and the pressure of the Redis cache server for connecting resources is reduced. In order to quickly obtain the configured Redis storage system, the embodiment of the invention selectively configures the Redis connection strings, the Redis client types and the Redis connection pools corresponding to the Redis storage system before obtaining the configured Redis storage system, so as to obtain the configured Redis storage system, and as a plurality of important parameters are selected for configuration, the number of configurations is reduced, so that the configuration speed is faster; in addition, the embodiment of the invention carries out dynamic proxy through the AOP, and each part of the service logic can be isolated by utilizing the AOP, so that the coupling degree among the parts of the service logic is reduced, and the reusability of a program is improved; in order to unify various Redis client connection pools, the embodiment of the invention carries out connection pooling processing on the Jeddis client, the Lettuce client and the Redis client according to the configured Redis storage system; in addition, the embodiment of the invention uses the Redis unified connection pool to realize the rapid acquisition of the data, and the metadata is stored in a Redis storage system; in addition, in order to quickly acquire the target metadata, the embodiment of the invention stores the metadata in a Redis storage system.
In order to facilitate understanding of the present invention, referring to fig. 2 specifically, fig. 2 is a flowchart illustrating an implementation method of a Redis connection pool according to an embodiment of the present invention, which may specifically include:
s200, starting Spring;
s201, acquiring a Spring-based Redis configuration rule, configuring a Redis connection string, a Redis client type and connection pool related configuration according to the Redis configuration rule, and obtaining a configured Redis;
s202, dynamically proxy the middleware using the Redis client in a reflection mode, and dynamically proxy the read-write operation of the Redis client to Spring Redis Template;
s203, carrying out connection pooling processing on all Redis client connections based on configured Redis, and injecting the Redis clients subjected to connection pooling into a bottom layer of Spring Redis Template through DI/Ioc characteristics of Spring so as to realize all Redis access unified connection pools;
s204, scanning middleware corresponding to the Redis client to realize access control to the Redis.
The implementation device of the Redis connection pool provided by the embodiment of the invention is introduced below, and the implementation device of the Redis connection pool described below and the implementation method of the Redis connection pool described above can be correspondingly referred to each other.
Referring to fig. 3 specifically, fig. 3 is a schematic structural diagram of an implementation apparatus of a dis connection pool according to an embodiment of the present invention, which may include:
the Redis configuration module 100 is configured to obtain a configured Redis storage system by configuring the Redis storage system based on a Redis configuration rule in a Spring open source framework;
the proxy module 200 is configured to dynamically proxy the middleware corresponding to the configured Redis storage system to a highly encapsulated class;
the connection pooling module 300 is configured to perform connection pooling processing on all the Redis clients according to the configured Redis storage system, so as to obtain a corresponding number of connection pooling Redis clients;
and the Redis unified connection pool implementation module 400 is used for injecting all the connection pooled Redis clients into the highly packaged class to implement construction of the Redis unified connection pool.
Further, based on the above embodiment, the above Redis configuration module 100 may include:
the Redis configuration unit is used for configuring a Redis connection string, a Redis client type and a Redis connection pool corresponding to the Redis storage system according to the Redis configuration rule in the Spring open source framework to obtain the configured Redis storage system.
Further, based on any of the above embodiments, the proxy module 200 may include:
and the proxy unit is used for dynamically proxy the read-write operation of the Redis client to the highly packaged class by utilizing the middleware corresponding to the Redis client and programming the Redis client by means of a tangent plane.
Further, based on any of the above embodiments, the connection pooling module 300 may include:
the connection pooling processing unit is used for carrying out connection pooling processing on the Jeddis client, the Lettuce client and the Redis client according to the configured Redis storage system; the Redis client comprises the Jeddis client, the Lettuce client and the Redis client.
Further, based on any embodiment, the implementation apparatus of the Redis connection pool may further include:
a metadata acquisition module for acquiring metadata stored in the Redis storage system;
an access request receiving module, configured to receive an access request of any one of the Redis clients;
the access request is used for accessing the Redis unified connection pool;
the target metadata acquisition module is used for acquiring corresponding target metadata from the metadata through the connection and operating the corresponding target metadata to obtain the operated target metadata;
and the connection releasing module is used for continuously storing the operated target metadata in the Redis storage system and releasing the connection.
Further, based on the above embodiment, the implementation apparatus of the Redis connection pool may further include:
the expiration date acquisition module is used for acquiring the expiration date of the metadata stored in the Redis storage system;
and the metadata deleting module is used for judging whether the metadata stored in the Redis storage system is still in the time period, and if not, extracting the metadata from the Redis storage system, returning the metadata to the database and deleting the metadata.
It should be noted that, the modules and units in the implementation device of the Redis connection pool can change the order of the modules and units before and after the modules and units do not affect the logic.
The implementation device of the Redis connection pool provided by the embodiment of the invention is used for obtaining a Redis configuration rule in a Spring open source framework to configure a Redis storage system through a Redis configuration module 100 so as to obtain a configured Redis storage system; the proxy module 200 is configured to dynamically proxy the middleware corresponding to the configured Redis storage system to a highly encapsulated class; the connection pooling module 300 is configured to perform connection pooling processing on all the Redis clients according to the configured Redis storage system, so as to obtain a corresponding number of connection pooling Redis clients; and the Redis unified connection pool implementation module 400 is used for injecting all the connection pooled Redis clients into the highly packaged class to implement construction of the Redis unified connection pool. Compared with a connection pool corresponding to a client in the prior art, the implementation of the Redis connection pool provided by the embodiment of the invention can configure a Redis storage system according to the Redis configuration rule in the Spring open source framework, and further perform dynamic proxy and connection pooling processing, so that unification of the Redis client corresponding to the Redis connection pool is realized, the utilization rate of the Redis client connection pool is improved, and the pressure of the Redis cache server for connecting resources is reduced. In order to quickly obtain the configured Redis storage system, the embodiment of the invention selectively configures the Redis connection strings, the Redis client types and the Redis connection pools corresponding to the Redis storage system before obtaining the configured Redis storage system, so as to obtain the configured Redis storage system, and as a plurality of important parameters are selected for configuration, the number of configurations is reduced, so that the configuration speed is faster; in addition, the embodiment of the invention carries out dynamic proxy through the AOP, and each part of the service logic can be isolated by utilizing the AOP, so that the coupling degree among the parts of the service logic is reduced, and the reusability of a program is improved; in order to unify various Redis client connection pools, the embodiment of the invention carries out connection pooling processing on the Jeddis client, the Lettuce client and the Redis client according to the configured Redis storage system; in addition, the embodiment of the invention uses the Redis unified connection pool to realize the rapid acquisition of the data, and the metadata is stored in a Redis storage system; in addition, in order to quickly acquire the target metadata, the embodiment of the invention stores the metadata in a Redis storage system.
The implementation device of the Redis connection pool provided by the embodiment of the invention is introduced below, and the implementation device of the Redis connection pool described below and the implementation method of the Redis connection pool described above can be referred to correspondingly.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an implementation device of a dis connection pool according to an embodiment of the present invention, which may include:
a memory 10 for storing a computer program;
a processor 20 for executing a computer program for implementing the steps of the implementation method of the Redis connection pool described above.
The memory 10, the processor 20, and the communication interface 30 all communicate with each other via a communication bus 40.
In the embodiment of the present invention, the memory 10 is used to store one or more programs, and the programs may include program codes, where the program codes include computer operation instructions, and in the embodiment of the present application, the memory 10 may store programs for implementing the following functions:
acquiring a Redis configuration rule based on a Spring open source framework to configure a Redis storage system to obtain a configured Redis storage system;
dynamically proxy middleware corresponding to the configured Redis storage system to a highly packaged class;
carrying out connection pooling treatment on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients;
and injecting all the connection pooling Redis clients into highly-packaged classes, and constructing a Redis unified connection pool.
In one possible implementation, the memory 10 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, and at least one application program required for functions, etc.; the storage data area may store data created during use.
In addition, memory 10 may include read only memory and random access memory and provide instructions and data to the processor. A portion of the memory may also include NVRAM. The memory stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, where the operating instructions may include various operating instructions for performing various operations. The operating system may include various system programs for implementing various basic tasks as well as handling hardware-based tasks.
The processor 20 may be a central processing unit (Central Processing Unit, CPU), an asic, a dsp, a fpga or other programmable logic device, and the processor 20 may be a microprocessor or any conventional processor. The processor 20 may call a program stored in the memory 10.
The communication interface 30 may be an interface of a communication module for connecting with other devices or systems.
Of course, it should be noted that the structure shown in fig. 4 does not limit the implementation device of the Redis connection pool in the embodiment of the present application, and in practical application, the implementation device of the Redis connection pool may include more or fewer components than those shown in fig. 4, or some components may be combined.
The medium provided by the embodiment of the present invention is a computer readable storage medium, and the computer readable storage medium provided by the embodiment of the present invention is described below, and the computer readable storage medium described below and the implementation method of the dis connection pool described above may be referred to correspondingly.
The invention also provides a computer readable storage medium, on which a computer program is stored, which when being executed by a processor, implements the steps of the implementing method of the Redis connection pool described above.
The computer readable storage medium may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
Finally, it is further noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The above describes in detail the implementation method, device, equipment and medium of the Redis connection pool provided by the present invention, and specific examples are applied to illustrate the principles and embodiments of the present invention, and the above description of the examples is only used to help understand the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (7)

1. The implementation method of the Redis connection pool is characterized by comprising the following steps:
acquiring a Redis configuration rule based on a Spring open source framework to configure a Redis storage system to obtain a configured Redis storage system;
dynamically proxy middleware corresponding to the configured Redis storage system to a highly packaged class;
performing connection pooling processing on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients;
injecting all the connection pooling Redis clients into the highly packaged class to realize construction of a Redis unified connection pool;
the obtaining configures the Redis storage system based on the Redis configuration rule in the Spring open source framework to obtain a configured Redis storage system, which comprises the following steps:
configuring a Redis connection string, a Redis client type and a Redis connection pool corresponding to the Redis storage system according to the Redis configuration rule in the Spring open source framework to obtain the configured Redis storage system;
wherein dynamically brokering middleware corresponding to the configured Redis storage system to a highly encapsulated class, comprises:
and dynamically proxy the read-write operation of the Redis client to the highly packaged class by using the middleware corresponding to the Redis client and performing the dynamic proxy by facing to the tangent plane programming.
2. The implementation method of the dis connection pool according to claim 1, wherein the performing connection pooling processing on all dis clients according to the configured dis storage system includes:
performing connection pooling processing on the Jeddis client, the Lettuce client and the Redisson client according to the configured Redis storage system; the Redis client comprises the Jeddis client, the Lettuce client and the Redis client.
3. The implementation method of a Redis connection pool according to any one of claims 1 to 2, wherein after said injecting all the connection-pooling Redis clients into the highly encapsulated class, implementing the construction of a Redis unified connection pool, further comprises:
acquiring metadata stored in the Redis storage system;
receiving an access request of any Redis client;
acquiring connection from the Redis unified connection pool according to the access request;
acquiring corresponding target metadata from the metadata through the connection, and operating to obtain the operated target metadata;
and continuously storing the operated target metadata in the Redis storage system, and releasing the connection.
4. The implementation method of the Redis connection pool according to claim 3, further comprising, after the storing the operated target metadata in the Redis storage system and releasing the connection:
acquiring the time period of the metadata stored in the Redis storage system;
and judging whether the metadata stored in the Redis storage system is still in the time period, and if not, extracting the metadata from the Redis storage system, returning the metadata to a database and deleting the metadata.
5. An implementation apparatus for a Redis connection pool, comprising:
the Redis configuration module is used for acquiring a Redis configuration rule in the Spring open source framework to configure the Redis storage system to obtain a configured Redis storage system;
the agent module is used for dynamically agent the middleware corresponding to the configured Redis storage system to a highly packaged class;
the connection pooling module is used for carrying out connection pooling processing on all Redis clients according to the configured Redis storage system to obtain a corresponding number of connection pooling Redis clients;
the Redis unified connection pool implementation module is used for injecting all the connection pooled Redis clients into the highly packaged class to realize construction of the Redis unified connection pool;
wherein, the Redis configuration module comprises:
a Redis configuration unit, configured to configure a Redis connection string, a Redis client type and a Redis connection pool corresponding to the Redis storage system according to the Redis configuration rule in the Spring open source framework, so as to obtain the configured Redis storage system;
wherein, the proxy module includes:
and the proxy unit is used for dynamically proxy the read-write operation of the Redis client to the highly packaged class by utilizing the middleware corresponding to the Redis client and programming the Redis client by means of a tangent plane.
6. An implementation device of a Redis connection pool, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the implementation method of the Redis connection pool according to any one of claims 1 to 4 when executing the computer program.
7. A computer readable storage medium, characterized in that it has stored thereon a computer program which, when executed by a processor, implements the steps of the method for implementing the Redis connection pool according to any of claims 1 to 4.
CN202310171967.5A 2023-02-28 2023-02-28 Redis connection pool realization method, device, equipment and medium Active CN115878711B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310171967.5A CN115878711B (en) 2023-02-28 2023-02-28 Redis connection pool realization method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310171967.5A CN115878711B (en) 2023-02-28 2023-02-28 Redis connection pool realization method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN115878711A CN115878711A (en) 2023-03-31
CN115878711B true CN115878711B (en) 2023-07-21

Family

ID=85761686

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310171967.5A Active CN115878711B (en) 2023-02-28 2023-02-28 Redis connection pool realization method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115878711B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105608207A (en) * 2015-12-25 2016-05-25 广州华多网络科技有限公司 Data statistics system based on Redis database and statistics method of data statistics system
CN108011768A (en) * 2017-12-26 2018-05-08 杭州电子科技大学 A kind of aop intercept types HBase data store micro services framework construction method
CN109347936A (en) * 2018-09-30 2019-02-15 江苏满运软件科技有限公司 Implementation method, system, storage medium and the electronic equipment of Redis agent client
CN110515616A (en) * 2019-08-30 2019-11-29 广州开发区信息工程有限公司 Journal function management method, device, computer equipment and storage medium
CN111431735A (en) * 2020-02-28 2020-07-17 平安科技(深圳)有限公司 Method, device and apparatus for managing connection pool and storage medium
CN111538605A (en) * 2020-04-24 2020-08-14 北京思特奇信息技术股份有限公司 Distributed data access layer middleware and command execution method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9456046B2 (en) * 2014-05-08 2016-09-27 Honeywell International Inc. Dynamic generation of proxy connections
US11200081B2 (en) * 2019-10-21 2021-12-14 ForgeRock, Inc. Systems and methods for tuning containers in a high availability environment
US11146534B1 (en) * 2020-04-07 2021-10-12 Microsoft Technology Licensing, Llc Implementing a client-side policy on client-side logic
US11546307B2 (en) * 2021-04-20 2023-01-03 Sap Se Method to implement multi-tenant/shared Redis cluster using envoy

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105608207A (en) * 2015-12-25 2016-05-25 广州华多网络科技有限公司 Data statistics system based on Redis database and statistics method of data statistics system
CN108011768A (en) * 2017-12-26 2018-05-08 杭州电子科技大学 A kind of aop intercept types HBase data store micro services framework construction method
CN109347936A (en) * 2018-09-30 2019-02-15 江苏满运软件科技有限公司 Implementation method, system, storage medium and the electronic equipment of Redis agent client
CN110515616A (en) * 2019-08-30 2019-11-29 广州开发区信息工程有限公司 Journal function management method, device, computer equipment and storage medium
CN111431735A (en) * 2020-02-28 2020-07-17 平安科技(深圳)有限公司 Method, device and apparatus for managing connection pool and storage medium
CN111538605A (en) * 2020-04-24 2020-08-14 北京思特奇信息技术股份有限公司 Distributed data access layer middleware and command execution method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
云平台下RESTful Web Service架构的研究与实现;宋玉峰;中国硕士学位论文全文数据库 信息科技辑;全文 *

Also Published As

Publication number Publication date
CN115878711A (en) 2023-03-31

Similar Documents

Publication Publication Date Title
Li et al. Serverless computing: state-of-the-art, challenges and opportunities
US7530081B2 (en) System for creating a dynamic OGSI service proxy framework using runtime introspection of an OGSI service
US7607128B2 (en) Method and system for enabling a server application to be executed in the same virtual machine as a client application using direct object oriented programming method calls
US10970277B2 (en) System and method for dynamic conversion of database accessing scripts during runtime in a mainframe rehosting platform
US9176772B2 (en) Suspending and resuming of sessions
US8146096B2 (en) Method and system for implementing built-in web services endpoints
US8010695B2 (en) Web services archive
US8024425B2 (en) Web services deployment
US8065690B2 (en) Method and system for event-based remote procedure call implementation in a distributed computing system
US20060112398A1 (en) System and Methodology Providing Service Invocation for Occasionally Connected Computing Devices
US20070174288A1 (en) Apparatus and method for web service client deployment
US20060129512A1 (en) Socket-like communication API for C
US7593930B2 (en) Fast channel architecture
US20100115046A1 (en) Method and server cluster for map reducing flow services and large documents
US8549474B2 (en) Method and system for implementing WS-policy
US10977007B2 (en) Apparatus and method for executing function
US11321090B2 (en) Serializing and/or deserializing programs with serializable state
Otte et al. Efficient and deterministic application deployment in component-based enterprise distributed real-time and embedded systems
Warren et al. A model for dynamic configuration which preserves application integrity
CN115878711B (en) Redis connection pool realization method, device, equipment and medium
Warren A model for dynamic configuration which preserves application integrity
CN113835904A (en) Remote procedure call control method, device, equipment and storage medium
Chen et al. An Innovative Self-Configuration Approach for Networked Systems and Applications.
Xu et al. Migration of Enterprise JavaBeans with ProActive interposition objects
Le Goc et al. Prototype of a simple ZeroMQ-based RPC in replacement of CORBA in NOMAD

Legal Events

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