Redis cache management method, device, electronic device and storage medium

By managing the application and delisting process of cache names in the Redis cluster, the problems of key uniqueness and large key-value pairs in the Redis cluster are solved, and the lifecycle management and security of cache data are improved.

CN114756588BActive Publication Date: 2025-09-09SHANGHAI TUHU INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210380204.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-12
Publication Date
2025-09-09
Estimated Expiration
2042-04-12

AI Technical Summary

Technical Problem

In the existing technology, the Redis cluster mode cannot guarantee the uniqueness of keys between different applications, cannot effectively manage the data life cycle, and has difficulty in efficiently managing large key-value pairs.

Method used

By receiving and approving cache name applications, binding to the Redis cluster, setting the cache name status, and performing verification and configuration removal when offline, it combines full table scans and memory snapshots to process large key-value pairs, thus achieving cache name-level key-value pair management and lifecycle management.

Benefits of technology

It ensures the uniqueness of cache names and keys between different applications, improves the group identification management capabilities of cached data, enhances system security, and efficiently manages large key-value pairs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114756588B_ABST
    Figure CN114756588B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device, electronic device and storage medium for Redis cache management, wherein the Redis cache management method includes: receiving a user cache name application, approving the cache name, and verifying whether the cache name is reasonable. If the approval is passed, the cache name is bound to a Redis cluster and the cache name status is set to an online state; receiving a user cache name offline application, performing a cache name offline verification, and if the verification is passed, removing the cache name configuration from a configuration service and setting the cache name status to a data to be cleaned state; if the user cancels the offline request within a specified time, re-uploading the cache name configuration to the configuration service and restoring the cache name status to an online state; if the user does not cancel the offline request within the specified time, deleting the cache name data and setting the cache name status to an offline state.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article involves but is not limited to the database field. Background Art

[0002] Redis (Remote Dictionary Server) is an open source remote memory database.

[0003] Redis is an in-memory database based on dictionaries (a common key-value data structure that quickly retrieves values ​​based on keys). To balance ease of use with excellent read and write performance, a hash table is used as the underlying implementation for dictionaries. Existing caching services are based on the Redis cluster model, allowing multiple applications to share the same cluster. However, Redis does not provide any solutions for managing hash table data by application or data model.

[0004] Therefore, the shortcomings of the prior art mainly include the following three aspects:

[0005] First, the uniqueness of keys between different applications cannot be guaranteed;

[0006] Second, it cannot effectively manage the lifecycle of different application data;

[0007] Third, it cannot efficiently manage Redis large key values ​​(key-value pairs whose value size in the dictionary exceeds a certain threshold). Summary of the Invention

[0008] The following presents an overview of various exemplary technical solutions. Some simplifications and omissions may be made in the following overview, which is intended to highlight and introduce some aspects of the various exemplary technical solutions, but does not limit the scope of the present invention. A detailed description of the exemplary technical solutions sufficient to allow a person of ordinary skill in the art to make and use the concepts of the present invention will be presented in subsequent sections.

[0009] To solve the above technical problems, the technical solution of the present invention provides a Redis cache management method, including: receiving a user cache name application, approving the cache name, and verifying whether the cache name is reasonable. If approved, the cache name is bound to the Redis cluster, and the cache name status is set to the online state; receiving a user cache name offline application, performing a cache name offline verification, and if the verification passes, the cache name configuration is removed from the configuration service, and the cache name status is set to the data to be cleaned state; if the user cancels the offline within the specified time, the cache name configuration is re-uploaded to the configuration service, and the cache name status is restored to the online state; if the user does not cancel the offline within the specified time, the cache name data is deleted, and the cache name status is set to the offline state.

[0010] Optionally, binding the cache name to the Redis cluster includes: binding the cache name to a corresponding Redis cluster according to the type and resource size of the cache name.

[0011] Optionally, the cache name application information includes at least one of the following: user name, application ID, cache name, capacity, expiration time, and whether it is an empty value.

[0012] Optionally, approving the cache name includes: using a scheduled task to check whether there is a cache name to be approved.

[0013] Optionally, the execution of the cache name offline check includes: directly rejecting an offline application during non-working hours.

[0014] Optionally, the performing of offline verification of the cache name includes: notifying all members under the cache name of the offline verification to ensure that it is not an erroneous operation.

[0015] Optionally, the method further includes: a scheduled task removing the configuration of the cache name from the configuration service at night.

[0016] Optionally, the method further includes: removing the configuration of the cache name from the configuration service and checking whether there are any clients still using it. If there are any online clients, the client will be refused to go offline until all online clients are disconnected. The configuration will not be removed.

[0017] Optionally, the method further includes: after the cache name configuration is removed, a scheduled task starts to clean up data after a specified time, and sets the cache name to an offline state.

[0018] Optionally, the method further includes: deleting the cache name after removing the cache name configuration and deleting the cache name data.

[0019] Optionally, the method further includes: searching for large key values ​​based on a full table scan or a memory snapshot; if a large key value is found, saving the large key value information, and alerting the cache name person in charge to process the large key value.

[0020] Optionally, the method further includes: a scheduled task performing a full table scan every night.

[0021] Optionally, the method further includes: if there is a Redis cluster skew, performing manual memory analysis.

[0022] Another technical solution of the present invention provides a Redis cache management device, including: a cache name application approval module, configured to receive a user cache name application, approve the cache name, and verify whether the cache name is reasonable. If approved, the cache name is bound to the Redis cluster and the cache name status is set to the online state; a cache name offline approval module, configured to receive a user cache name offline application, perform cache name offline verification, and if the verification is passed, remove the cache name configuration from the configuration service and set the cache name status to the data to be cleaned up state; if the user cancels the offline within the specified time, the cache name configuration is re-uploaded to the configuration service and the cache name status is restored to the online state; if the user does not cancel the offline within the specified time, the cache name data is deleted and the cache name status is set to the offline state.

[0023] Optionally, the cache name application approval module is further configured to bind the cache name to a corresponding Redis cluster according to the type and resource size of the cache name.

[0024] Optionally, the cache name application information includes at least one of the following: user name, application ID, cache name, capacity, expiration time, and whether it is an empty value.

[0025] Optionally, the cache name offline approval module is further configured to: after the cache name configuration is removed, a scheduled task starts to clean up data after a specified time and sets the cache name to an offline state.

[0026] Optionally, the device also includes a large key value processing module, which is configured to: search for large key values ​​based on a full table scan or a memory snapshot, save the large key value information if a large key value is found, and alert the cache name person in charge to process the large key value.

[0027] Another technical solution of the present invention further provides an electronic device, which includes: a processor, a memory, and a computer program stored and running on the memory, and the processor implements the method described in any of the above technical solutions when executing the computer program.

[0028] Another technical solution of the present invention further provides a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method described in any of the above technical solutions are implemented.

[0029] The technical solution of the present invention mainly has the following two beneficial effects of leaving dough:

[0030] First, it can ensure the uniqueness of cache names and keys between different applications;

[0031] Second, the group identifier of the application cache data is stored as a key prefix in the Redis dictionary. This allows operations to be performed on a group of keys with the same cache name, achieving cache name-level key-value pair management capabilities and lifecycle management of the data under the cache name.

[0032] Third, the efficiency of cache name approval has been improved, and the offline security of cache names has been managed and controlled, which has improved the security of the system.

[0033] Fourth, it can efficiently manage large Redis key values. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] For a better understanding of various exemplary embodiments, reference may be made to the accompanying drawings, in which:

[0035] Figure 1 A schematic diagram of a Redis cache management method according to an embodiment is shown;

[0036] Figure 2 An example of a Redis cache management method provided by an embodiment is shown;

[0037] Figure 3 An example of a Redis cache management method provided by an embodiment is shown;

[0038] Figure 4 A schematic structural diagram of a Redis cache management device provided in an embodiment is shown.

[0039] To facilitate understanding, the same reference numerals have been used to designate elements having substantially the same or similar structure and / or substantially the same or similar function. DETAILED DESCRIPTION

[0040] Description and drawings illustrate the principle of the present invention. Therefore, it will be appreciated that those skilled in the art will be able to design various arrangements, and although the arrangement is not explicitly described or shown herein, the arrangement embodies the principle of the present invention and is included within the scope of the present invention. In addition, all examples cited herein are primarily intended to be explicitly used for teaching purposes, to help the reader understand the principle of the present invention and the concepts provided by the inventors in order to deepen this area, and all examples should be considered as not being limited to the examples and conditions of such specific quotations. In addition, as used herein, unless otherwise indicated (e.g., "or in addition" or "or in an alternative"), the term "or" refers to non-exclusive or (i.e., and / or). Furthermore, the various embodiments described herein are not necessarily mutually exclusive, because some embodiments can be combined with one or more other embodiments to form new embodiments.

[0041] Explanation of terms:

[0042] Redis (Remote Dictionary Server): An open source and popular remote memory database.

[0043] Dictionary: A common key-value pair data structure that quickly retrieves the value based on the key.

[0044] Large Key: A key-value pair whose value in the dictionary exceeds a certain threshold.

[0045] Application (App Id): can be understood as each backend service program.

[0046] RenaultSDK: A development kit that encapsulates various interfaces for accessing Redis data. Accessing Redis requires this development kit.

[0047] Cache name: The grouping identifier of the application cache data, which is stored in the Redis dictionary as a key prefix.

[0048] The first embodiment provides a Redis cache management method, see Figure 1 and Figure 2 , the method comprising:

[0049] Create the concept of cache name and its life cycle management, the flow chart is as follows

[0050] Step S101: Receive a user cache name application, approve the cache name, and verify whether the cache name is reasonable. If approved, bind the cache name to the Redis cluster and set the cache name status to online.

[0051] To request a user cache name, you must fill in the following information: user name, application ID, cache name, capacity, expiration time, and whether or not the value is null. This information is generated into a form and stored in the database. You can specify the application ID (App ID) and the estimated cache resource usage. Users can request a unique cache name, which should be as concise and understandable as possible. The system will verify global uniqueness.

[0052] The Redis cache management device handles the approval process, which can be automated. A background scheduler can check for cache names awaiting approval at specified intervals (e.g., every three minutes). The name is verified for validity and uniqueness during the review process. Once the cache name is approved, it can be bound to the appropriate Redis cluster based on the App ID type and resource size. For example, cache names with the same App ID type can be bound to the same cluster, or evenly distributed across clusters based on resource size. The App ID can be used to identify the business department to which the cache belongs. For example, names containing the characters "-cl-," "-arch-," "-md-," "-yw-," or "-mkt-" can represent different business departments, allowing larger departments to be assigned separate clusters. For cache names with particularly large capacity requirements, a separate cluster can be created, such as "-mkt-mlp-." The cache name's configuration and cluster configuration can also be synchronized with the service (e.g., ZooKeeper, as used in the following example), and the cache name's status is updated to "Online." RenaultSDK can be provided to access Redis clusters. The various interfaces provided by RenaultSDK will prefix the cache name to the dictionary key passed by the application and save it in Redis as the final dictionary key. Upon startup, the client can directly connect to the Redis cluster based on the cache name configuration and perform relevant cache read and write operations. Cache names that fail automatic approval can be manually reviewed. For example, if the name does not meet the specifications or the estimated capacity is unreasonable, the application will be rejected and approved again after the user makes adjustments. The user may abandon the application or directly delete the cache name. If the manual review does not object, the application can be manually bound to the cluster to complete the approval.

[0053] Step S102: Receive the user's cache name offline application, perform cache name offline verification, if the verification passes, remove the cache name configuration from the configuration service, and set the cache name status to the data to be cleared state.

[0054] Deleting a service in production is extremely risky, so a deleting request must be submitted to ensure data security. Optionally, a deleting verification process is performed first. If the deleting request is made during non-business hours, the system can directly reject the request. The deleting request can be notified (e.g., via SMS or WeChat) to all members of the App ID to prevent any errors. If an error is detected, the deleting request can be revoked on the management platform, resetting the cache name's status to "online."

[0055] The operation of deleting the configuration may include: if it is normal operation, the system scheduled task can be operated offline at night (for example, from 7 pm to 7 am, or other night time) (the cache name configuration is removed from ZooKeeper). Before removal, it can be checked whether there are clients still using it (online clients can report the client status to the management platform). If there are online clients, the offline can be refused and the offline can be executed only after all online clients are disconnected. After the configuration is removed from ZooKeeper, the cache name is in the data to be cleaned up state.

[0056] Step S103: If the user cancels the offline state within the specified time, the cache name configuration will be re-uploaded to the configuration service, and the cache name status will be restored to the online state; if the user does not cancel the offline state within the specified time, the cache name data will be deleted and the cache name status will be set to the offline state.

[0057] Data deletion operations include: After the cache name configuration is removed from ZooKeeper, the client can be used, but is now in the data purge state. A scheduled task can start data purge after a specified time (for example, 24 hours) and set the cache name to offline. Before the cache data is purged, the application user can still cancel the offline request. Canceling the offline request allows the configuration to be re-uploaded to ZooKeeper. At this point, the cache name configuration and data are still present, and the cache name can continue to function normally.

[0058] Optionally, a step of deleting the cache name may also be included. When the cache name configuration has been deleted and the cache data has also been deleted, the cache name can be deleted and the cache name status can be set to be irrecoverable.

[0059] All key-value data in Redis are in the hash table structure, and the key values ​​do not have the function of grouping. However, in actual applications, the key-value data of multiple applications are usually shared in the same Redis cluster. However, Redis does not have the function of grouping and managing key values. In this embodiment, the cache name, that is, the group identifier of the application cache data, is used as the prefix of the key in the Redis dictionary. Operations can be performed on a group of keys with the same prefix (or cache name) to achieve the key-value pair management capability at the cache name level.

[0060] Optionally, the Redis cache management platform maintains the current version number of the cache name. Each time a logical deletion is performed, the version number can be incremented by 1. Before storing data in Redis, the Renault SDK can be used to prefix the business key with the cache name and version number, using a format such as {cache name}:{version number}:{user's actual key value}. This configuration updates the cache version number, preventing reads and writes to the original cached data, effectively deleting it. The original data is then automatically expired or cleared after discovery. This feature, which deletes data by updating the cache name version number, makes data deletion very fast.

[0061] Optionally, as the amount of application data grows and the cluster's usage capacity reaches its upper limit, the application can be split according to certain rules, allowing the application to be migrated from a Redis cluster to another Redis cluster. Data migration from the source cluster to the target cluster can be divided into three steps. First, use the RedisShake tool to synchronize all data under the source cluster cache name to the target cluster offline. Use the redis-full-check tool to check whether the source and target cluster data are consistent. Second, the management platform switches the cluster for the current cache name. During the switching process, the keys synchronized in real time by the RedisShake tool will be recorded and deleted to prevent the source cluster synchronization delay from overwriting the latest data written to the target cluster. Third, after the migration is complete, all traffic from the clients of the current cache name flows to the target cluster, and asynchronous cleanup of the data of the current cache name on the source cluster is performed.

[0062] Optionally, sharing caches between applications is a very common feature. To ensure the security of application data, other applications need to be authorized on the management platform before accessing the current application's cached data. When applying for a cache name, you must fill in the App Id to which it belongs, that is, the cache name only belongs to a specific application. When the application starts, it can go to ZooKeeper to find the cache name under the current App Id and create a connection. If the application needs to read and write cache names under other App Ids, it can add authorization to the current App Id under the target cache name on the management platform. This authorization relationship can be synchronized to ZooKeeper. In this way, when the current App Id starts, in addition to accessing its own cache name data, it can also access the authorized cache name data.

[0063] Optionally, cache deletion: provides a SCAN-based method for matching cache name prefixes to delete scanned key-value pairs one by one; logical clearing: provides a version number as a prefix component, and by incrementing the version number, old data automatically expires and cannot be read or written, thereby achieving the effect of logical clearing; cache offline: the cache name configuration information is removed from Zookeeper, and the client will not be able to start because it cannot obtain the configuration.

[0064] Optionally, the Redis cache management method also includes a function for handling large key values. Large key values ​​are very harmful to Redis, and applications are generally strictly prohibited from reading and writing large key-value pairs. When writing to the RenaultSDK interface, the key value length is checked. The key length cannot exceed 256 bytes, and the value length cannot exceed 1Mb. If the length exceeds the limit, an exception will be thrown.

[0065] like Figure 3 As shown in the figure, a dual-pronged approach can be used to manage large key values ​​(for example, large key value thresholds: String type size exceeds 800KB, non-String type size exceeds 10MB). A full table scan performs a full table scan of key values ​​in the Redis database by calling the Redis API. A memory snapshot uses the backend to analyze suspicious key values ​​based on memory size using a memory snapshot. Key value memory usage statistics can be aggregated by cache name.

[0066] Optionally, you can perform a full table analysis or a cache name-level memory analysis. The former analyzes all keys, while the latter analyzes the keys under a specific cache name to see which ones exceed the threshold.

[0067] Full table scans and snapshots can impact the overall performance of the cluster, making frequent in-memory analysis operations unsuitable. To minimize this impact, a scheduled task performs a full table scan at night using an underestimated time. Any key-value pairs found to exceed the threshold are recorded. Large keys are generally not tolerated, but optimizing and managing large keys takes time. To avoid non-emergency alarms at night, a task can be scheduled during work hours the next day to notify the App ID owner of large key alarms, who can then apply optimizations for the large keys.

[0068] During nightly scans, some large keys may be expired and deleted before scheduled scans, thus evading memory analysis. Manual intervention is required to address these situations. For example, if routine inspections reveal cluster skew, after initially identifying suspicious cache names based on client monitoring, you can specify the cache name for memory analysis. If a large number of cache names are found and the cluster capacity is not high, you can perform a memory snapshot analysis.

[0069] Executing memory snapshots poses a risk of downtime when capacity is high and should be avoided. SCAN-based full table scans have little impact on cluster read and write performance, increasing read accesses only. However, SCAN full table scans take longer to execute. Using SCAN and snapshots together in different scenarios can minimize cluster risks and improve efficiency.

[0070] Optionally, the user interface may use VUE, the cache management device may use JAVA, and the database may use MYSQL.

[0071] The second embodiment provides a Redis cache management device 200, such as Figure 4 As shown, it includes: a cache name application approval module 201, which is configured to receive user cache name applications, approve cache names, and verify whether the cache names are reasonable and unique. If approved, the cache name is bound to the Redis cluster and the cache name status is set to the online state; a cache name offline approval module 203, which is configured to receive user cache name offline applications, perform cache name offline verification, and if the verification is passed, the cache name configuration is removed from the configuration service and the cache name status is set to the data to be cleaned up state; if the user cancels the offline within the specified time, the cache name configuration is re-uploaded to the configuration service and the cache name status is restored to the online state; if the user does not cancel the offline within the specified time, the cache name data is deleted and the cache name status is set to the offline state.

[0072] To request a user cache name, you must fill in the following information: user name, application ID, cache name, capacity, expiration time, and whether or not the value is null. This information is generated into a form and stored in the database. You can specify the application ID (App ID) and the estimated cache resource usage. Users can request a unique cache name, which should be as concise and understandable as possible. The system will verify global uniqueness.

[0073] The cache name application approval module 201 is responsible for approval. The approval can be automatic. The background timer task can check whether there are cache names to be approved at specified intervals (for example, 3 minutes). During the review, it is necessary to verify whether the name is reasonable and unique. After the cache name is reviewed and there is no objection, the cache name can be bound to the appropriate Redis cluster based on the App Id type and resource size. For example, cache names of the same App Id type can be bound to the same cluster, or evenly distributed to different clusters according to resource size. Based on the App Id, the business department to which the current cache belongs can be parsed. For example, different business departments can be represented by characters including "-cl-", "-arch-", "-md-", "-yw-", and "-mkt-". Larger departments can be set as separate clusters. For cache names with extremely large capacity requirements, an independent cluster can be built, such as "-mkt-mlp-". At the same time, the cache name cache configuration and cluster configuration relationship can be synchronized to the service (for example, ZooKeeper, which will be used as an example later), and the cache name status is updated to "online". RenaultSDK can be provided to access Redis clusters. The various interfaces provided by RenaultSDK will prefix the cache name to the dictionary key passed by the application and save it in Redis as the final dictionary key. Upon startup, the client can directly connect to the Redis cluster based on the cache name configuration and perform relevant cache read and write operations. Cache names that fail automatic approval can be manually reviewed. For example, if the name does not meet the specifications or the estimated capacity is unreasonable, the application will be rejected and approved again after the user makes adjustments. The user may abandon the application or directly delete the cache name. If the manual review does not object, the application can be manually bound to the cluster to complete the approval.

[0074] It is a very dangerous operation to apply for the offline operation of a service in use in a production environment. Therefore, the offline operation also needs to go through the application process to ensure data security. Optionally, the cache name offline approval module 202 first performs an offline verification. If the offline operation is performed during non-working hours, the system can directly reject the request; the offline operation can be notified (for example, through SMS, WeChat, etc.) to all members under the App Id to ensure that there is no wrong operation. If it is found to be a wrong operation, the offline application can be revoked on the management platform, and the cache name will be back online.

[0075] The operation of deleting the configuration may include: if it is normal operation, the system scheduled task can be operated offline at night (for example, from 7 pm to 7 am, or other night time) (the cache name configuration is removed from ZooKeeper). Before removal, it can be checked whether there are clients still using it (online clients can report the client status to the management platform). If there are online clients, the offline can be refused and the offline can be executed only after all online clients are disconnected. After the configuration is removed from ZooKeeper, the cache name is in the data to be cleaned up state.

[0076] Data deletion operations include: After the cache name configuration is removed from ZooKeeper, the client can be used, but is now in the data purge state. A scheduled task can start data purge after a specified time (for example, 24 hours) and set the cache name to offline. Before the cache data is purged, the application user can still cancel the offline request. Canceling the offline request allows the configuration to be re-uploaded to ZooKeeper. At this point, the cache name configuration and data are still present, and the cache name can continue to function normally.

[0077] Optionally, a step of deleting the cache name may also be included. When the cache name configuration has been deleted and the cache data has also been deleted, the cache name can be deleted and the cache name status can be set to be irrecoverable.

[0078] Optionally, a large key value processing module is also included, which is configured to: search for large key values ​​based on full table scan or memory snapshot, save the large key value information if a large key value is found, and alert the cache name person in charge to process the large key value.

[0079] Optionally, a dual-pronged approach of full table scans and memory snapshots can be used to manage large key values ​​(for example, the large key value threshold is: String type size exceeds 800KB, non-String type size exceeds 10MB). Full table scans perform a full table scan of key values ​​in the Redis database table by calling the Redis API. Memory snapshots analyze suspicious key values ​​based on memory size using a backend snapshot. Key value memory usage statistics can be aggregated by cache name.

[0080] Optionally, you can perform a full table analysis or a cache name-level memory analysis. The former analyzes all keys, while the latter analyzes the keys under a specific cache name to see which ones exceed the threshold.

[0081] Full table scans and snapshots can impact the overall performance of the cluster, making frequent in-memory analysis unsuitable. To minimize this impact, a scheduled task performs a full table scan at an infrequent time every night. Key-value pairs found during the scan that exceed a threshold are recorded. Large keys are generally not tolerated, but optimizing and managing large keys takes time. To avoid non-emergency alarms at night, a scheduled task can be scheduled during business hours the next day to push large key information to App ID members.

[0082] During nightly scans, some large keys may be deleted due to expiration before scheduled scans, thus evading memory analysis. Manual intervention is required to address these situations. For example, if routine inspections reveal cluster skew (cluster distribution imbalance), after initially identifying suspicious cache names through client monitoring, you can specify the cache name for memory analysis. If a large number of cache names are found and the cluster capacity is not high, you can perform a memory snapshot analysis.

[0083] Taking in-memory snapshots poses a risk of downtime when capacity is high, so their use can be reduced. SCAN-based full table scans have little impact on cluster read and write performance, increasing read accesses only. However, SCAN full table scans take longer to execute. Using SCAN and snapshots together in different scenarios can minimize cluster risks and improve efficiency.

[0084] Optionally, the user interface may use VUE, the cache management device may use JAVA, and the database may use MYSQL.

[0085] A third embodiment further provides an electronic device, comprising: a processor, a memory, and a computer program stored and running on the memory, wherein when the processor executes the computer program, the steps of the method of any of the above embodiments are implemented, such as steps S101 to S103, or when the processor executes the computer program, the functions of each module / unit in each of the above embodiments are implemented, such as the functions of units 201 to 202. The computer program can be divided into one or more modules / units, and the one or more modules / units are stored in the memory and executed by the processor. The one or more modules / units can be a series of computer program instruction segments that can perform specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.

[0086] The electronic device may be a mobile terminal such as a smartphone, or a computing device such as a desktop computer, notebook, PDA, or cloud server. The electronic device may include, but is not limited to, a processor and a memory, and may include more or fewer components, or a combination of certain components. For example, the electronic device may also include input and output devices, network access devices, buses, etc. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc. The memory may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory may also be an external storage device of the electronic device, such as a plug-in hard disk equipped on the electronic device, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Furthermore, the memory may include both an internal storage unit of the electronic device and an external storage device.

[0087] The fourth embodiment further provides a computer-readable storage medium, wherein when the computer program is executed by a processor, the steps of the method of any of the above embodiments are implemented.

[0088] The functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit. If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and may also instruct the relevant hardware to complete it through a computer program. The computer program may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, it may implement the steps of the above-mentioned various method embodiments. Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form. The computer-readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunications signal, and a software distribution medium. It should be noted that the content of the computer-readable medium may be appropriately increased or decreased based on the requirements of legislation and patent practice within a jurisdiction. For example, in some jurisdictions, based on legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunications signals.

[0089] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0090] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, please refer to the relevant description of other embodiments. Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0091] In the embodiments provided in this application, it should be understood that the disclosed systems, electronic devices and methods can be implemented in other ways. For example, the system and electronic device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of the system or unit, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0092] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.

Claims

1. A Redis cache management method, characterized in that: include: Receive user cache name applications, approve cache names, and verify whether the cache name is reasonable. If approved, bind the cache name to the Redis cluster, synchronize the cache name cache configuration and cluster configuration relationship to the configuration service, and set the cache name status to online. The cache name is the group identifier of the application cache data and is stored in Redis as the prefix of the key; Receive the user's cache name offline application, perform cache name offline verification, and if the verification passes, remove the cache name configuration from the configuration service and set the cache name status to the data to be cleared state; If the user cancels the offline state within the specified time, the cache name configuration will be re-uploaded to the configuration service and the cache name status will be restored to the online state; If the user does not cancel the offline within the specified time, the data of the cache name will be deleted and the cache name status will be set to offline.

2. The Redis cache management method according to claim 1, characterized in that: Binding the cache name to the Redis cluster includes: binding the cache name to the corresponding Redis cluster according to the type and resource size of the cache name.

3. The Redis cache management method according to claim 1, wherein: The cache name application information includes at least one of the following: user name, application ID, cache name, capacity, expiration time, and whether it is empty.

4. The Redis cache management method according to claim 1, wherein: The approving cache name includes: using a scheduled task to check whether there is a cache name to be approved.

5. The Redis cache management method according to claim 1, characterized in that: The execution cache name offline verification includes: directly rejecting offline applications during non-working hours.

6. The Redis cache management method according to claim 1, characterized in that: The offline verification of the cache name is performed, including: the offline verification will be notified to all members under the cache name to ensure that it is not a wrong operation.

7. The Redis cache management method according to claim 1, characterized in that: Also includes: The scheduled task removes the cache name configuration from the configuration service at night.

8. The Redis cache management method according to claim 1, characterized in that: Also includes: Removing the cache name configuration from the configuration service will check whether there are still clients using it. If there are online clients, it will refuse to go offline until all online clients are disconnected.

9. The Redis cache management method according to claim 1, characterized in that: Also includes: After the cache name configuration is removed, the scheduled task starts to clean up the data after the specified time and sets the cache name to the offline state.

10. The Redis cache management method according to claim 1, wherein: Also includes: After removing the cache name configuration and deleting the cache name data, delete the cache name.

11. The Redis cache management method according to claim 1, wherein: Also includes: Based on a full table scan or memory snapshot, search for large key values. If a large key value is found, save the large key value information, and notify the cache name owner to process the large key value.

12. The Redis cache management method according to claim 1, wherein: Also includes: The scheduled task performs a full table scan every night.

13. The Redis cache management method according to claim 12, characterized in that: Also includes: If the Redis cluster is skewed, perform manual memory analysis.

14. A Redis cache management device, characterized in that: include: The cache name application approval module is configured to receive user cache name applications, approve cache names, and verify whether the cache name is reasonable. If approved, the cache name is bound to the Redis cluster, and the cache name cache configuration and cluster configuration relationship are synchronized to the configuration service, and the cache name status is set to online. The cache name is the group identifier of the application cache data and is stored in Redis as a prefix of the key; The cache name offline approval module is configured to receive a user's cache name offline application, perform cache name offline verification, and if the verification passes, remove the cache name configuration from the configuration service and set the cache name status to a data to be cleaned state; If the user cancels the offline state within the specified time, the cache name configuration will be re-uploaded to the configuration service and the cache name status will be restored to the online state; If the user does not cancel the offline within the specified time, the data of the cache name will be deleted and the cache name status will be set to offline.

15. The Redis cache management device according to claim 14, characterized in that: The cache name application approval module is further configured to bind the cache name to a corresponding Redis cluster according to the type and resource size of the cache name.

16. The Redis cache management device according to claim 14, characterized in that: The cache name application information includes at least one of the following: user name, application ID, cache name, capacity, expiration time, and whether it is empty.

17. The Redis cache management device according to claim 14, characterized in that: The cache name offline approval module is further configured to: after the cache name configuration is removed, the scheduled task starts to clean up data after the specified time and sets the cache name to an offline state.

18. The Redis cache management device according to claim 14, characterized in that: It also includes a large key value processing module, which is configured to: search for large key values ​​based on full table scan or memory snapshot, save the large key value information if a large key value is found, and alert the cache name person in charge to process the large key value.

19. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored and running on the memory, wherein the processor implements the method according to any one of claims 1 to 13 when executing the computer program.

20. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 13 is implemented.

Citation Information

Patent Citations

  • Terminal state cache method and device under http protocol

    CN103856562A

  • Page display method and device and electronic equipment

    CN108089894A

  • Key value pair management verification method and device, equipment and storage medium

    CN112579559A

  • Large key detection method, system and device based on Redis and storage medium

    CN113051319A