Data access method and device, electronic equipment and storage medium

By deploying the caching service separately from the application on the host pod, the problem of insufficient JVM memory caused by local caching was solved, improving service stability and data access efficiency.

CN118733630APending Publication Date: 2024-10-01BEIJING QIYI CENTURY SCI & TECH CO LTD

Patent Information

Application Number
CN202410845873.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In existing technologies, the deep binding of local caching with applications leads to insufficient JVM memory, affecting the normal operation of services.

Method used

Deploy a main container and a companion container on the host pod. The main container runs the application, and the companion container runs a caching service. The caching service is independent of the application's JVM memory. By combining the caching service with a cloud database, the data query hit rate can be improved.

Benefits of technology

This enables the caching service to be deployed independently from the application, avoiding memory consumption and improving application stability and data access efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733630A_ABST
    Figure CN118733630A_ABST
Patent Text Reader

Abstract

The invention provides a data access method and device, electronic equipment and a storage medium. The data access method is applied to a host pod, a main container and an associated container are deployed on the host pod, the main container runs an application program, and the associated container runs a cache service. And when a data access request of a client is received, querying the cache service based on the data access request to obtain a cache query result. And if the cache query result is that no data is queried, querying a database based on the data access request to obtain a database query result. And if the cache query result or the database query result is that the data is queried, sending the queried data to the client. According to the method, the cache service is deployed on the associated container, the cache service and the application program are operated separately, the jvm memory of the application program is not occupied any more, meanwhile, the hit rate of data query is increased in combination with the cloud database, the data access efficiency can be guaranteed, and the stability of the application program can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for data access. Background Art

[0002] With the development of technology, various applications have emerged, and a large amount of data has also been generated. In order to facilitate data access, the data needs to be saved.

[0003] In the prior art, when data is accessed, it is usually accessed by accessing the local cache. However, since the local cache is deeply bound to the application code and will share the application's jvm (Java Virtual Machine) memory, it is easy to cause the application's jvm memory to be insufficient. When the jvm memory is full, garbage collection will be started. At this time, the entire application will stop working and will not provide services, affecting the normal operation of the service. Summary of the invention

[0004] In view of this, the present application provides a data access method, device, electronic device and storage medium to solve the problem in the prior art that local cache easily leads to insufficient JVM memory of the application, thus affecting the normal operation of the service.

[0005] To achieve the above objectives, this application provides the following technical solutions:

[0006] In a first aspect, the present application discloses a method for data access, which is applied to a host pod, on which a main container and a companion container are deployed, wherein the main container runs an application, and the companion container runs a cache service, wherein the method for data access includes:

[0007] When receiving a data access request from a client, querying the cache service based on the data access request to obtain a cache query result; wherein the cache service is used to store cache data of the application;

[0008] If the cache query result is that no data is found, querying the database based on the data access request to obtain a database query result;

[0009] If the cache query result or the database query result is that data is found, the found data is sent to the client.

[0010] Optionally, in the above method, the deployment process of the cache service includes:

[0011] Extracting the cache code of the application; wherein the cache code is used to define the cache function of the application;

[0012] Creating a configuration file for the cache service; wherein the configuration file is used to define configuration information of the cache service;

[0013] Building an image of the cache service based on the cache code and the configuration file, and uploading the image to an image warehouse; wherein the image warehouse is used to store the built image;

[0014] If a deployment instruction of the image is received, the image is obtained from the image repository and deployed to the companion container.

[0015] Optionally, the above method further includes:

[0016] Based on the historical data query data, a data query hit rate of the cache service is calculated, wherein the data query hit rate is used to characterize the probability that the cache service can query the corresponding data for the historical data access request;

[0017] Comparing the hit rate with a preset first threshold;

[0018] If the hit rate is lower than a preset first threshold, an alarm prompt message is generated.

[0019] Optionally, the above method further includes:

[0020] Monitoring the remaining capacity of the cache service;

[0021] If it is monitored that the remaining capacity is less than a preset second threshold, capacity alarm information is generated, and the capacity of the cache service is optimized according to a pre-configured capacity optimization solution.

[0022] Optionally, the above method further includes:

[0023] If the database query result is that data is found, the found data is saved in the cache service.

[0024] In a second aspect, the present application discloses a data access device, which is applied to a host pod, on which a main container and a companion container are deployed, wherein the main container runs an application, and the companion container runs a cache service, wherein the data access device includes:

[0025] A first query unit is used to query the cache service based on the data access request when receiving a data access request from the client to obtain a cache query result; wherein the cache service is used to store cache data of the application;

[0026] A second query unit, configured to query a database based on the data access request to obtain a database query result if the cache query result indicates that no data is found;

[0027] A sending unit is used to send the queried data to the client if the cache query result or the database query result is that the data is queried.

[0028] Optionally, in the above device, the first query unit includes:

[0029] An extraction subunit, used to extract the cache code of the application; wherein the cache code is used to define the cache function of the application;

[0030] A creation subunit is used to create a configuration file of the cache service; wherein the configuration file is used to define configuration information of the cache service;

[0031] An image building subunit, used to build an image of the cache service based on the cache code and the configuration file, and upload the image to an image warehouse; wherein the image warehouse is used to store the built image;

[0032] The deployment subunit is configured to obtain the image from the image repository and deploy the image into the companion container if a deployment instruction of the image is received.

[0033] Optionally, the above device further includes:

[0034] A calculation unit, configured to calculate a data query hit rate of the cache service based on historical data query data, wherein the data query hit rate is used to characterize the probability that the cache service can query corresponding data for historical data access requests;

[0035] A comparing unit, used for comparing the hit rate with a preset first threshold;

[0036] An alarm unit is used to generate an alarm prompt message if the hit rate is lower than a preset first threshold; wherein the alarm prompt message is used to prompt that the amount of data stored in the cache service is too small and data expansion is required.

[0037] Optionally, the above device further includes:

[0038] A monitoring unit, configured to monitor the remaining capacity of the cache service; wherein the remaining capacity is calculated based on the total capacity and the used capacity of the cache service;

[0039] The optimization unit is used to generate capacity warning information if it is monitored that the remaining capacity is less than a preset second threshold, and to optimize the capacity of the cache service according to a pre-configured capacity optimization solution.

[0040] Optionally, the above device further includes:

[0041] The storage unit is used to store the data queried from the database in the cache service.

[0042] The third aspect of the present application discloses an electronic device, comprising:

[0043] one or more processors;

[0044] a storage device having one or more programs stored thereon;

[0045] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of the first aspects of the present application.

[0046] A fourth aspect of the present application discloses a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method described in any one of the first aspects of the present application is implemented.

[0047] It can be seen from the above technical scheme that a data access method provided by the present application is applied to a host pod, on which a main container and a companion container are deployed, the main container runs an application, and the companion container runs a cache service. When a data access request from a client is received, the cache service is queried based on the data access request to obtain a cache query result; wherein the cache service is used to save the cache data of the application. If the cache query result is that no data is found, the database is queried based on the data access request to obtain a database query result. If the cache query result or the database query result is that the data is found, the queried data is sent to the client. It can be seen that by using the method of the present application, by deploying the cache service to the companion container, the cache service is run separately from the application, and the jvm memory of the application is no longer occupied. At the same time, the hit rate of data query is improved by combining with the cloud database, which can not only ensure the efficiency of data access, but also improve the stability of the application. It solves the problem in the prior art that local cache easily leads to insufficient jvm memory of the application, affecting the normal operation of the service. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] 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 embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0049] Figure 1 A flowchart of a data access method disclosed in an embodiment of the present application;

[0050] Figure 2 A schematic diagram of an application framework for data access disclosed in another embodiment of the present application;

[0051] Figure 3 A flowchart of an implementation of a deployment process of a cache service disclosed in another embodiment of the present application;

[0052] Figure 4 A schematic diagram of a data access device disclosed in another embodiment of the present application;

[0053] Figure 5 A schematic diagram of an electronic device disclosed in another embodiment of the present application. DETAILED DESCRIPTION

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

[0055] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0056] Furthermore, in this document, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0057] In the prior art, when data is accessed, it is usually accessed by accessing the local cache. However, since the local cache is deeply bound to the application code and will share the application's JVM memory, it is easy to cause the application's JVM memory to be insufficient. When the JVM memory is full, garbage collection will be started. At this time, the entire application will stop working and will not provide services, affecting the normal operation of the service.

[0058] In view of this, the present application provides a method, device, electronic device and storage medium for data access to solve the problem in the prior art that local cache easily leads to insufficient JVM memory of the application, thus affecting the normal operation of the service.

[0059] The embodiment of the present application provides a method for data access, which is applied to a host pod, on which a main container and a companion container are deployed, the main container runs an application, and the companion container runs a cache service, wherein the method for data access is as follows: Figure 1 As shown, specifically including:

[0060] S101. When receiving a data access request from a client, query a cache service based on the data access request to obtain a cache query result; wherein the cache service is used to store cache data of an application.

[0061] It should be noted that since most applications are now containerized and are orchestrated and deployed based on Kubernetes (an open source container orchestration platform), in the sidecar mode of Kubernetes (a sidecar mode of Kubernetes), a companion container can be deployed for the main container, and the main container and the companion container are in the same host. The main container and the companion container are equivalent to two running programs in a host. The main container and the companion container are related, and the companion container can be automatically deployed or destroyed with the main container.

[0062] It should also be noted that this embodiment combines Figure 2The system architecture shown in the figure is described. The main container and the companion container are deployed on the host pod (the smallest deployable and scalable computing unit in Kubernetes, which can contain one or more containers, share the same network and storage, and work together). The application runs on the main container, and the cache service runs on the companion container. The application can interact with the client, the cache service, and the DB database. The cache monitoring management service is used to monitor the cache service. The cache service is used to save the cache data of the application. The cache service is deployed on the companion container and runs independently of the application jvm memory. The application and the cache service are deployed separately to ensure that the memory usage is independent of each other. The cache service no longer occupies the jvm memory of the application, avoiding frequent garbage collection of the application due to the memory cleanup of the cache service, and improving the stability of the application. At the same time, the cache service and the application run in the same host pod, realizing local access to the cache, without network delay, and improving the access speed. When receiving a data access request from the client, it first queries the cache service based on the data access request whether it has saved the data requested by the data access request, and obtains the cache query result.

[0063] S102: If the cache query result is that no data is found, query the database based on the data access request to obtain a database query result.

[0064] It should be noted that if the cache query result is that no data is found, it means that the cache service does not have the data that the data access request needs to access. Therefore, the cloud DB database will be queried based on the data access request to check whether the DB database contains the data that the data access request needs to access, and obtain the database query result.

[0065] S103: If the cache query result or the database query result is that data is found, the found data is sent to the client.

[0066] It should be noted that if the cache query result is that data is found, or the database query result is that data is found, then the queried data can be sent to the client.

[0067] S104: If both the cache query result and the database query result indicate that no data is found, information indicating that no data is found is sent to the client.

[0068] A data access method provided in an embodiment of the present application is applied to a host pod, on which a main container and a companion container are deployed, the main container runs an application, and the companion container runs a cache service. When a data access request from a client is received, the cache service is queried based on the data access request to obtain a cache query result; wherein the cache service is used to save the cache data of the application. If the cache query result is that no data is found, the database is queried based on the data access request to obtain a database query result. If the cache query result or the database query result is that the data is found, the queried data is sent to the client. It can be seen that by using the method of the present application, by deploying the cache service on a companion container, the cache service is run separately from the application, and the jvm memory of the application is no longer occupied. At the same time, the hit rate of data query is improved by combining with the cloud database, which can not only ensure the efficiency of data access, but also improve the stability of the application. It solves the problem in the prior art that local cache easily leads to insufficient jvm memory of the application, affecting the normal operation of the service.

[0069] Optionally, in another embodiment of the present application, the deployment process of the cache service is as follows: Figure 3 As shown, it may include:

[0070] S301. Extract the cache code of the application; wherein the cache code is used to define the cache function of the application.

[0071] It should be noted that in order to deploy the application and the cache service separately, it is necessary to logically decouple the cache access code in the application so as to extract the cache code of the application.

[0072] S302: Create a configuration file for the cache service; wherein the configuration file is used to define configuration information of the cache service.

[0073] It should be noted that you should select a cache storage technology that suits your application requirements, such as LinkedHashMapCacheCache, Redis, or Memcached, and then write a configuration file for the cache service based on actual requirements. The configuration file includes a Dockerfile file and a YAML file. The Dockerfile file is used to describe how to build an image of the cache storage service, which contains the relevant configuration and startup commands for the cache storage service. The YAML file is a human-readable data serialization format, usually used for configuration files and data exchange formats. In Kubernetes, YAML is used to define resource objects, such as Pod, Service, Deployment, etc.

[0074] S303: Build an image of the cache service based on the cache code and configuration file, and upload the image to an image repository; wherein the image repository is used to store the built image.

[0075] It should be noted that based on the cache code and configuration files, an image of the cache service is built, and the built image is uploaded to the container warehouse. The image warehouse is used to save the built image so that the built image can be obtained at any time when the image needs to be deployed.

[0076] S304: If a deployment instruction for an image is received, the image is obtained from the image repository and deployed into a companion container.

[0077] It should be noted that if the deployment instruction of the image is received, the image is obtained from the image repository, and then the image of the cache service is deployed to the companion container through Kubernetes. By using the Sidecar mode, the cache service runs separately from the application, providing better isolation, ensuring independence and non-interference with each other, and the container where the cache service is located can be managed and upgraded independently without interfering with the application container, realizing the convenience of quickly deploying new versions or patching the cache service. At the same time, each application can have an independent cache service, which is convenient for flexibly increasing or decreasing the number of instances of the cache container according to application requirements, and realizing scalability management.

[0078] Optionally, in another embodiment of the present application, the above data access method may further include:

[0079] Based on the historical data query data, the data query hit rate of the cache service is calculated, wherein the data query hit rate is used to characterize the probability that the cache service can query the corresponding data for the historical data access request.

[0080] The hit rate is compared with a preset first threshold.

[0081] If the hit rate is lower than a preset first threshold, an alarm prompt message is generated; wherein the alarm prompt message is used to prompt that the amount of data stored in the cache service is too small and data expansion is required.

[0082] It should be noted that the historical data query data is obtained, the number of times the cache service successfully reads data and the total number of times data access requests are initiated are obtained, and then the ratio of the two is calculated, and the ratio is used as the data query hit rate of the cache service. The data query hit rate is used to characterize the probability that the cache service can query the corresponding data for the historical data access request. The higher the hit rate, the greater the probability that the cache service can meet the user's data query needs. After calculating the hit rate, the hit rate is compared with the preset first threshold, and the first threshold can be set according to the actual situation, for example, 90%. If the hit rate is lower than the preset first threshold, it means that the cache service may store too little data and it is difficult to meet the user's data query needs. Therefore, an alarm prompt message is generated to prompt the management-related personnel to expand the data. In this embodiment, the management-related personnel can be promptly prompted by the alarm prompt message that the query hit rate of the cache service is too low, and the data in the cache service needs to be further expanded to enrich the data volume of the cache service to improve the query hit rate, thereby improving the query efficiency and user experience.

[0083] Optionally, in another embodiment of the present application, the above data access method may further include:

[0084] The remaining capacity of the cache service is monitored; wherein the remaining capacity is calculated based on the total capacity and the used capacity of the cache service.

[0085] If it is monitored that the remaining capacity is less than a preset second threshold, a capacity alarm message is generated, and the capacity of the cache service is optimized according to a pre-configured capacity optimization plan.

[0086] It should be noted that in order to facilitate the control of the capacity of the cache service, the remaining capacity of the cache service is monitored. If the remaining capacity is less than the preset second threshold, a capacity alarm message is generated to remind the user that the current remaining capacity is insufficient. The second threshold can be set according to the actual situation, for example, 80%. If the data is more important, different alarm thresholds can be set, and the general range can be 30%-90%. Then, the capacity of the cache service is optimized according to the pre-configured capacity optimization plan, such as expanding the cache space, or querying and deleting known cache content.

[0087] In this embodiment, the remaining capacity of the cache service is monitored, and when the remaining capacity is insufficient, the cache space is expanded, or known cache contents are queried and deleted to optimize the capacity of the cache service, so as to avoid the situation where new data cannot be added to the cache service. At the same time, since the cache service is independently deployed in the companion container, the cache capacity can be flexibly adjusted without worrying about affecting the application memory.

[0088] Optionally, in another embodiment of the present application, the above data access method may further include:

[0089] The data queried from the database is saved in the cache service.

[0090] It should be noted that if the database query result is data found, the data may be data that the user needs to query frequently. Therefore, the data found in the database query is saved in the cache service to expand the data of the cache service. The next time the user queries the same data, it can be directly queried from the cache service, so as to improve query efficiency and better meet the user's data query needs.

[0091] In another embodiment of the present application, a data access device is also disclosed, which is applied to a host pod, on which a main container and a companion container are deployed, the main container runs an application, and the companion container runs a cache service, wherein the data access device, such as Figure 4 As shown, specifically including:

[0092] The first query unit 401 is used to query the cache service based on the data access request when receiving a data access request from the client, and obtain a cache query result; wherein the cache service is used to store cache data of the application.

[0093] The second query unit 402 is configured to query the database based on the data access request to obtain a database query result if the cache query result indicates that no data is found.

[0094] The sending unit 403 is configured to send the queried data to the client if the cache query result or the database query result is that the data is found.

[0095] In this embodiment, the specific execution process of the first query unit 401, the second query unit 402, and the sending unit 403 can be found in the corresponding Figure 1 The content of the method embodiment will not be repeated here.

[0096] A data access device provided in an embodiment of the present application is applied to a host pod, on which a main container and a companion container are deployed, the main container runs an application, and the companion container runs a cache service. When receiving a data access request from a client, the first query unit 401 queries the cache service based on the data access request to obtain a cache query result; wherein the cache service is used to save the cache data of the application. If the cache query result is that no data is found, the second query unit 402 queries the database based on the data access request to obtain a database query result. If the cache query result or the database query result is that the data is found, the sending unit 403 sends the queried data to the client. It can be seen that by using the method of the present application, by deploying the cache service on the companion container, the cache service is run separately from the application, and the jvm memory of the application is no longer occupied. At the same time, the hit rate of data query is improved in combination with the cloud database, which can not only ensure the efficiency of data access, but also improve the stability of the application. It solves the problem in the prior art that the local cache easily leads to insufficient jvm memory of the application, affecting the normal operation of the service.

[0097] Optionally, in another embodiment of the present application, an implementation of the first query unit 401 may include:

[0098] The extraction subunit is used to extract the cache code of the application; wherein the cache code is used to define the cache function of the application.

[0099] A subunit is created to create a configuration file for the cache service; wherein the configuration file is used to define configuration information of the cache service.

[0100] The image building subunit is used to build an image of the cache service based on the cache code and configuration file, and upload the image to the image warehouse; the image warehouse is used to store the built image.

[0101] The deployment subunit is used to obtain the image from the image repository and deploy the image into the companion container if a deployment instruction of the image is received.

[0102] In this embodiment, the specific execution process of extracting subunits, creating subunits, mirroring subunits, and deploying subunits can be found in the corresponding Figure 3 The content of the method embodiment will not be repeated here.

[0103] Optionally, in another embodiment of the present application, the above-mentioned data access device may further include:

[0104] The calculation unit is used to query data based on historical data and calculate the data query hit rate of the cache service, wherein the data query hit rate is used to represent the probability that the cache service can query the corresponding data for the historical data access request.

[0105] The comparison unit is used to compare the hit rate with a preset first threshold.

[0106] The alarm unit is used to generate an alarm prompt message if the hit rate is lower than a preset first threshold; wherein the alarm prompt message is used to prompt that the amount of data stored in the cache service is too small and data expansion is required.

[0107] In this embodiment, the specific execution process of the calculation unit, the comparison unit, and the alarm unit can refer to the corresponding method embodiment content above, which will not be repeated here.

[0108] Optionally, in another embodiment of the present application, the above-mentioned data access device may further include:

[0109] The monitoring unit is used to monitor the remaining capacity of the cache service; wherein the remaining capacity is calculated based on the total capacity and the used capacity of the cache service.

[0110] The optimization unit is used to generate capacity alarm information if it is monitored that the remaining capacity is less than a preset second threshold, and optimize the capacity of the cache service according to a pre-configured capacity optimization plan.

[0111] In this embodiment, the specific execution process of the monitoring unit and the optimization unit can refer to the corresponding method embodiment content above, which will not be repeated here.

[0112] Optionally, in another embodiment of the present application, the above-mentioned data access device may further include:

[0113] The storage unit is used to store the data queried from the database in a cache service.

[0114] In this embodiment, the specific execution process of the storage unit can refer to the corresponding method embodiment content above, which will not be repeated here.

[0115] Another embodiment of the present application further provides an electronic device, such as Figure 5 As shown, specifically including:

[0116] One or more processors 501 .

[0117] The storage device 502 stores one or more programs.

[0118] When one or more programs are executed by one or more processors 501 , the one or more processors 501 implement any one of the methods in the above embodiments.

[0119] Another embodiment of the present application further provides a computer storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, any one of the methods in the above embodiments is implemented.

[0120] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0121] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may 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 invention.

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

Claims

1. A method of data access, It is characterized in that Applied to a host pod, a main container and a companion container are deployed on the host pod, the main container runs an application, and the companion container runs a cache service, wherein the data access method includes: When receiving a data access request from a client, querying the cache service based on the data access request to obtain a cache query result; wherein the cache service is used to store cache data of the application; If the cache query result is that no data is found, querying the database based on the data access request to obtain a database query result; If the cache query result or the database query result is that data is found, the found data is sent to the client.

2. The method according to claim 1, It is characterized in that The deployment process of the cache service includes: Extracting the cache code of the application; wherein the cache code is used to define the cache function of the application; Creating a configuration file for the cache service; wherein the configuration file is used to define configuration information of the cache service; Building an image of the cache service based on the cache code and the configuration file, and uploading the image to an image warehouse; wherein the image warehouse is used to store the built image; If a deployment instruction of the image is received, the image is obtained from the image repository and deployed to the companion container.

3. The method according to claim 1, It is characterized in that Also includes: Based on the historical data query data, a data query hit rate of the cache service is calculated, wherein the data query hit rate is used to characterize the probability that the cache service can query the corresponding data for the historical data access request; Comparing the hit rate with a preset first threshold; If the hit rate is lower than a preset first threshold, an alarm prompt message is generated; wherein the alarm prompt message is used to prompt that the amount of data stored in the cache service needs to be expanded.

4. The method according to claim 1, It is characterized in that Also includes: Monitoring the remaining capacity of the cache service; wherein the remaining capacity is calculated based on the total capacity and the used capacity of the cache service; If it is monitored that the remaining capacity is less than a preset second threshold, capacity alarm information is generated, and the capacity of the cache service is optimized according to a pre-configured capacity optimization solution.

5. The method according to claim 1, It is characterized in that Also includes: The data queried from the database is saved in the cache service.

6. A device for accessing data, It is characterized in that Applied to a host pod, a main container and a companion container are deployed on the host pod, the main container runs an application, and the companion container runs a cache service, wherein the data access device includes: A first query unit is used to query the cache service based on the data access request when receiving a data access request from the client to obtain a cache query result; wherein the cache service is used to store cache data of the application; A second query unit, configured to query a database based on the data access request to obtain a database query result if the cache query result indicates that no data is found; A sending unit is used to send the queried data to the client if the cache query result or the database query result is that the data is queried.

7. The device according to claim 6, It is characterized in that The first query unit includes: An extraction subunit, used to extract the cache code of the application; wherein the cache code is used to define the cache function of the application; A creation subunit is used to create a configuration file of the cache service; wherein the configuration file is used to define the image and resource objects of the cache service; An image building subunit, used to build an image of the cache service based on the cache code and the configuration file, and upload the image to an image warehouse; wherein the image warehouse is used to store the built image; The deployment subunit is configured to obtain the image from the image repository and deploy the image into the companion container if a deployment instruction of the image is received.

8. The device according to claim 6, It is characterized in that Also includes: A calculation unit, configured to calculate a data query hit rate of the cache service based on historical data query data, wherein the data query hit rate is used to characterize the probability that the cache service can query corresponding data for historical data access requests; A comparing unit, used for comparing the hit rate with a preset first threshold; An alarm unit is used to generate an alarm prompt message if the hit rate is lower than a preset first threshold; wherein the alarm prompt message is used to prompt that the amount of data stored in the cache service is too small and data expansion is required.

9. An electronic device, It is characterized in that include: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 5.

10. A computer storage medium, It is characterized in that A computer program is stored thereon, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Method and apparatus for implementing data cache

    CN107169047A

  • Information inquiry method, slave server, client, and computer readable storage medium

    CN109145020A

  • Application availability monitoring method and device, electronic equipment and medium

    CN112596987A

  • Application program license management system and method

    CN113742660A

  • Service route updating method and device, storage medium and electronic equipment

    CN117873535A

Cited By

  • High-speed interaction system and method for data in container

    CN119248731A

  • Method and system for realizing medical image data access in Kubernetes cluster environment

    CN122091110A