A method, device, and medium for determining a cache key value

By selecting an appropriate algorithm to calculate the cache key value based on the number of generated strings, the problem of high space consumption and hash collision caused by excessively long key values ​​in the cache is solved, thereby improving data security and query efficiency.

CN116049173BActive Publication Date: 2026-07-03BEIJING TIANDI CHAOYUN TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING TIANDI CHAOYUN TECH CO LTD
Filing Date
2022-12-09
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Excessively long key values ​​in the cache lead to high space consumption and high lookup costs, while shortening the key value length leads to hash collisions and data security issues.

Method used

The length and content of the key value are determined by selecting an appropriate algorithm based on the number of generated strings, including choosing a target algorithm and a hash value superposition algorithm.

Benefits of technology

It solves the problems of high space consumption and hash collision caused by excessively long key values, and improves data security and query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049173B_ABST
    Figure CN116049173B_ABST
Patent Text Reader

Abstract

The application provides a cache key value determination method and device, equipment and medium, wherein the method comprises: obtaining a to-be-cached object; encoding the to-be-cached object to generate a string corresponding to the to-be-cached object, and determining a data collision critical point corresponding to the number of generated strings; selecting a first target algorithm from a plurality of preset algorithms according to the determined data collision critical point; calculating a hash value corresponding to the string according to the first target algorithm; and determining the key value of the to-be-cached object according to the hash value. The length of the key value in the prior art is too long, which results in high space occupation of the key value, and the calculation cost of finding such key value in data is also high. Shortening the length of the key value results in insufficient number of key values, which further causes hash collision (i.e. repetition of key values), thus causing data security and data tampering problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data caching technology, and more specifically, to a method, apparatus, device, and medium for determining cache key values. Background Technology

[0002] Caching is primarily used in high-concurrency scenarios to alleviate the read / write pressure on the database by storing data in a faster medium, such as memory, thereby accelerating data retrieval. Users can first check the cache for the required data; if found, it can be returned directly. This improves user experience, reduces server load, and enhances system performance. In large-scale distributed systems, caching is an indispensable component.

[0003] However, caching mainly uses keys as indexes to implement data storage, modification, and query functions. When storing data in the cache, if the key value is too long, the space occupied by the key value will increase, and the computational cost of searching for such key values ​​in the data will also be very high. On the other hand, shortening the key value length will lead to an insufficient number of key values, which will result in hash collisions (i.e., duplicate key values). This will lead to various problems such as data security and data tampering. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a method, apparatus, device, and medium for determining cache key values, which can select an appropriate algorithm to calculate the string based on the number of generated strings to obtain key values ​​of different lengths. This solves the problems in the prior art where excessively long key values ​​lead to high space usage and high computational cost for searching such key values ​​in the data, while shortening the key value length leads to insufficient key values, resulting in hash collisions (i.e., duplicate key values), which in turn leads to data security and data tampering issues. The application achieves the effect of selecting an appropriate algorithm to calculate the string based on the currently required key value length.

[0005] In a first aspect, embodiments of this application provide a method for determining a cache key value. The method includes: obtaining an object to be cached; encoding the object to be cached to generate a string corresponding to the object to be cached, and determining a data collision threshold corresponding to the number of generated strings; selecting a first target algorithm from a set of preset algorithms based on the determined data collision threshold; calculating a hash value corresponding to the string according to the first target algorithm; and determining the key value of the object to be cached based on the hash value.

[0006] Optionally, the method further includes: identifying the data type corresponding to the string and determining the type value corresponding to the identified data type; wherein, the step of determining the key value of the object to be cached based on the hash value includes: inserting the type value at a preset position in the hash value; and determining the hash value after inserting the type value as the key value of the object to be cached.

[0007] Optionally, the method further includes: determining whether the data value corresponding to the data collision threshold is greater than a preset data threshold; if so, selecting at least two second target algorithms from a preset set of multiple algorithms based on the determined data collision threshold; for each second target algorithm, calculating the intermediate value corresponding to the string based on the second target algorithm; calculating the hash value corresponding to the string based on each intermediate value; and determining the key value of the object to be cached based on the hash value.

[0008] Optionally, the method further includes: determining a target hash value superposition algorithm from a set of preset hash value superposition algorithms based on the determined data collision threshold; wherein the hash value corresponding to the string is calculated by inputting the intermediate value corresponding to the string into the target hash value superposition algorithm to obtain the hash value corresponding to the string.

[0009] Optionally, each algorithm calculates a different hash value based on the length of the hash value of the string. The step of selecting a first target algorithm from a set of preset algorithms based on the determined data collision threshold includes: determining the required hash value length based on the determined data collision threshold; and determining the algorithm that calculates the required hash value length as the first target algorithm based on the required target hash value length.

[0010] Optionally, each hash value superposition algorithm calculates a different length of hash value based on the intermediate value. The step of determining the target hash value superposition algorithm from a variety of preset hash value superposition methods based on the determined data collision threshold includes: determining the required hash value length based on the determined data collision threshold; and determining the hash value superposition algorithm that calculates the required hash value length as the target hash value superposition algorithm based on the required hash value length.

[0011] Secondly, embodiments of this application also provide a device for determining a cache key value, the device comprising:

[0012] The module for retrieving objects to be cached is used to retrieve objects to be cached.

[0013] The string generation module is used to encode the object to be cached, generate a string corresponding to the object to be cached, and determine the data collision threshold corresponding to the number of generated strings.

[0014] The first target algorithm selection module is used to select the first target algorithm from a variety of preset algorithms based on the determined data collision threshold.

[0015] The hash value calculation module is used to calculate the hash value corresponding to the string according to the first target algorithm;

[0016] The key value determination module is used to determine the key value of the object to be cached based on the hash value.

[0017] Optionally, the device further includes:

[0018] A data type identification module is used to identify the data type corresponding to the string.

[0019] The type value determination module is used to determine the type value corresponding to the identified data type;

[0020] The Key value determination module is further configured to insert the type value at a preset position in the hash value; and determine the hash value after inserting the type value as the key value of the object to be cached.

[0021] Optionally, the device further includes: a data threshold determination module, used to determine whether the data value corresponding to the data collision threshold is greater than a preset data threshold;

[0022] The second target algorithm selection module is used to select at least two second target algorithms from a variety of preset algorithms based on the determined data collision threshold if the condition is met.

[0023] The intermediate value calculation module is used to calculate the intermediate value corresponding to the string for each second target algorithm, based on the second target algorithm.

[0024] The hash value calculation module is used to calculate the hash value corresponding to the string based on each intermediate value;

[0025] The key value determination module is used to determine the key value of the object to be cached based on the hash value.

[0026] Optionally, the device further includes: a target hash value superposition algorithm determination module, used to determine a target hash value superposition algorithm from a set of preset hash value superposition algorithms based on a determined data collision threshold; wherein, the hash value calculation module is further used to input the intermediate value corresponding to the string into the target hash value superposition algorithm to obtain the hash value corresponding to the string.

[0027] Optionally, each algorithm calculates a different hash value based on the length of the hash value calculated from the string. The first target algorithm selection module is further configured to determine the required hash value length based on the determined data collision threshold.

[0028] Based on the required target hash value length, the algorithm that calculates the required hash value length is determined as the first target algorithm.

[0029] Optionally, each hash value superposition algorithm calculates a different length of hash value based on the intermediate value. The target hash value superposition algorithm determination module is further used to determine the required hash value length based on the determined data collision threshold.

[0030] Based on the required hash value length, the hash value superposition algorithm that yields the required hash value length after calculation is determined as the target hash value superposition algorithm.

[0031] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the cache key value determination method described above are performed.

[0032] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the method for determining the cache key value as described above.

[0033] The method, apparatus, device, and medium for determining cache key values ​​provided in this application can select an appropriate algorithm to calculate the string based on the number of generated strings to obtain key values ​​of different lengths. This solves the problems in the prior art where excessively long key values ​​lead to high space usage and high computational costs for searching such key values ​​in the data, while shortening the key value length leads to insufficient key values, resulting in hash collisions (i.e., duplicate key values), which in turn cause data security and data tampering issues. The method achieves the effect of selecting an appropriate algorithm to calculate the string based on the currently required key value length.

[0034] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0035] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 A flowchart illustrating a method for determining a cache key value provided in an embodiment of this application;

[0037] Figure 2 A flowchart illustrating another method for determining a cache key value provided in an embodiment of this application;

[0038] Figure 3 This is a schematic diagram of the structure of a device for determining a cache key value provided in an embodiment of this application;

[0039] Figure 4 This application provides a schematic diagram of the structure of an electronic device. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.

[0041] First, the applicable scenarios for this application will be introduced. This application can be applied to the field of data caching technology.

[0042] Research has shown that caching is primarily used in high-concurrency scenarios to alleviate database read / write pressure by storing data in a faster medium, such as memory, thereby accelerating data retrieval. Users can first check the cache for the required data; if found, it can be returned directly. This improves user experience, reduces server load, and enhances system performance. In large-scale distributed systems, caching is an indispensable component.

[0043] However, caching mainly uses keys as indexes to implement data storage, modification, and query functions. When storing data in the cache, if the key value is too long, the space occupied by the key value will increase, and the computational cost of searching for such key values ​​in the data will also be very high. On the other hand, shortening the key value length will lead to an insufficient number of key values, which will result in hash collisions (i.e., duplicate key values). This will lead to various problems such as data security and data tampering.

[0044] Based on this, embodiments of this application provide a method, apparatus, device, and medium for determining cached key values. This method can select an appropriate algorithm to calculate the string based on the number of generated strings to obtain key values ​​of different lengths. This solves the problems in the prior art where excessively long key values ​​lead to high space usage and high computational costs for searching such keys in data, while shortening the key length results in insufficient key values, leading to hash collisions (i.e., duplicate key values). This, in turn, causes data security and data tampering issues. The method achieves the effect of selecting an appropriate algorithm to calculate the string based on the currently required key value length.

[0045] Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for determining a cache key value provided in an embodiment of this application. Figure 1 As shown in the embodiments of this application, the method for determining the cache key value includes:

[0046] S101. Obtain the object to be cached.

[0047] Here, objects to be stored can be obtained through various means such as networks and data transmission interfaces.

[0048] S102. Encode the object to be cached to generate a string corresponding to the object to be cached, and determine the data collision threshold corresponding to the number of generated strings.

[0049] Here, you can choose serialization tools such as JOSN to encode the object to be cached as a string. For example, for a student whose name is A and age is 18, it can be serialized as {"name":"A","age":18}.

[0050] It should be noted that the probability of hash collisions varies depending on the number of strings and the length of the key value. For example, with 250,000 data entries, the probability of a hash collision is close to 100%.

[0051] The data collision threshold can be divided into different thresholds such as 50,000, 100,000, 150,000, and 250,000.

[0052] S103. Based on the determined data collision threshold, select the first target algorithm from a variety of preset algorithms;

[0053] Here, each algorithm calculates a different hash value based on the length of the string.

[0054] The step of selecting a first target algorithm from a set of preset algorithms based on the determined data collision threshold includes: determining the required hash value length based on the determined data collision threshold; and determining the algorithm that calculates the required hash value length as the first target algorithm based on the required target hash value length.

[0055] For example, three algorithms, A, B, and C, are preset. Inputting a string into algorithm A yields a 10-bit hash value; inputting it into algorithm B yields a 12-bit hash value; and inputting it into algorithm C yields a 15-bit hash value. The collision rate of a 10-bit hash value is less than 30% when storing 50,000 data points, the collision rate of a 12-bit hash value is less than 30% when storing 100,000 data points, and the collision rate of a 15-bit hash value is less than 30% when storing 150,000 data points. When the number of generated strings is less than 50,000, the data collision threshold is 50,000. At this point, a 10-bit hash value is required. Therefore, algorithm A, which can calculate a 10-bit hash value for the string, is selected as the first target algorithm.

[0056] In this way, based on the number of strings that have been generated so far, a suitable algorithm is determined from a variety of algorithms.

[0057] S104. Calculate the hash value corresponding to the string according to the first target algorithm.

[0058] Optionally, the method further includes: determining whether the data value corresponding to the data collision threshold is greater than a preset data threshold; if so, selecting at least two second target algorithms from a preset set of multiple algorithms based on the determined data collision threshold; for each second target algorithm, calculating the intermediate value corresponding to the string based on the second target algorithm; calculating the hash value corresponding to the string based on each intermediate value; and determining the key value of the object to be cached based on the hash value.

[0059] Optionally, the method further includes: determining a target hash value superposition algorithm from a set of preset hash value superposition algorithms based on the determined data collision threshold; wherein the hash value corresponding to the string is calculated by inputting the intermediate value corresponding to the string into the target hash value superposition algorithm to obtain the hash value corresponding to the string.

[0060] The hash value superposition algorithm calculates different hash values ​​based on the intermediate value. The step of determining the target hash value superposition algorithm from a variety of preset hash value superposition methods based on the determined data collision threshold includes: determining the required hash value length based on the determined data collision threshold; and determining the hash value superposition algorithm that calculates the required hash value length as the target hash value superposition algorithm.

[0061] For example, three algorithms, A, B, and C, are preset. Inputting a string into algorithm A yields a 10-bit hash value; inputting the string into algorithm B yields a 12-bit hash value; and inputting the string into algorithm C yields a 15-bit hash value. The collision rate of the 10-bit hash value is less than 30% when storing 50,000 data points, the collision rate of the 12-bit hash value is less than 30% when storing 100,000 data points, and the collision rate of the 15-bit hash value is less than 30% when storing 150,000 data points. When the generated string data value reaches 180,000, which exceeds 150,000 data points, algorithms A and B can be identified as the second target algorithm. The next data collision threshold after the 150,000 data points and the 200,000 data points are then used to determine the target hash value concatenation algorithm. This target hash value concatenation algorithm can calculate the 10-bit and 12-bit hash values ​​obtained by algorithms A and B to obtain a 20-bit hash value. The second target algorithm then obtains two intermediate values, which are then used to calculate the 20-bit hash value using the target hash superposition algorithm.

[0062] S105. Determine the key value of the object to be cached based on the hash value.

[0063] In this way, the calculated hash value can be inserted into the data to be stored as the key value.

[0064] The method for determining cache keys provided in this application can select an appropriate algorithm to calculate the string based on the number of generated strings to obtain key values ​​of different lengths. This solves the problem in the prior art where excessively long key values ​​lead to high space usage and high computational cost in searching for such key values ​​in the data, while shortening the key value length leads to insufficient key values, resulting in hash collisions (i.e., duplicate key values), which in turn leads to data security and data tampering issues. The method achieves the effect of selecting an appropriate algorithm to calculate the string based on the currently required key value length.

[0065] Please see Figure 2 , Figure 2 A flowchart illustrating a method for determining a cache key value according to another embodiment of this application. Figure 2 As shown in the embodiments of this application, the method for determining the cache key value includes:

[0066] S201. Identify the data type corresponding to the string.

[0067] S202. Determine the type value corresponding to the identified data type;

[0068] For example, the string {"name":"A","age":18} can be identified. This string includes a name and an age, indicating that the type of the string is basic information type. Therefore, the type value corresponding to the basic information type can be determined to be 0101.

[0069] Optionally, the step of determining the key value of the object to be cached based on the hash value includes: inserting the type value at a preset position in the hash value; and determining the hash value after inserting the type value as the key value of the object to be cached.

[0070] The method for determining cache keys provided in this application can select an appropriate algorithm to calculate the string based on the number of generated strings to obtain key values ​​of different lengths. This solves the problem in the prior art where excessively long key values ​​lead to high space usage and high computational cost in searching for such key values ​​in the data, while shortening the key value length leads to insufficient key values, resulting in hash collisions (i.e., duplicate key values), which in turn leads to data security and data tampering issues. The method achieves the effect of selecting an appropriate algorithm to calculate the string based on the currently required key value length.

[0071] Based on the same inventive concept, this application also provides a device for determining a cache key value corresponding to the method for determining a cache key value. Since the principle of the device in this application is similar to the method for determining a cache key value described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0072] Please see Figure 3 , Figure 3 This is a schematic diagram of a cache key value determination device provided in an embodiment of this application. The cache key value determination device 300 includes:

[0073] The module 301 for obtaining objects to be cached is used to obtain objects to be cached.

[0074] The string generation module 302 is used to encode the object to be cached, generate a string corresponding to the object to be cached, and determine the data collision threshold corresponding to the number of generated strings.

[0075] The first target algorithm selection module 303 is used to select a first target algorithm from a variety of preset algorithms based on the determined data collision threshold.

[0076] The hash value calculation module 304 is used to calculate the hash value corresponding to the string according to the first target algorithm;

[0077] Key value determination module 305 is used to determine the key value of the object to be cached based on the hash value.

[0078] Optionally, the device further includes:

[0079] A data type identification module is used to identify the data type corresponding to the string.

[0080] The type value determination module is used to determine the type value corresponding to the identified data type;

[0081] The Key value determination module is further configured to insert the type value at a preset position in the hash value; and determine the hash value after inserting the type value as the key value of the object to be cached.

[0082] Optionally, the device further includes: a data threshold determination module, used to determine whether the data value corresponding to the data collision threshold is greater than a preset data threshold;

[0083] The second target algorithm selection module is used to select at least two second target algorithms from a variety of preset algorithms based on the determined data collision threshold if the condition is met.

[0084] The intermediate value calculation module is used to calculate the intermediate value corresponding to the string for each second target algorithm, based on the second target algorithm.

[0085] The hash value calculation module is used to calculate the hash value corresponding to the string based on each intermediate value;

[0086] The key value determination module is used to determine the key value of the object to be cached based on the hash value.

[0087] Optionally, the device further includes: a target hash value superposition algorithm determination module, used to determine a target hash value superposition algorithm from a set of preset hash value superposition algorithms based on a determined data collision threshold; wherein, the hash value calculation module is further used to input the intermediate value corresponding to the string into the target hash value superposition algorithm to obtain the hash value corresponding to the string.

[0088] Optionally, each algorithm calculates a different hash value based on the length of the hash value calculated from the string. The first target algorithm selection module is further configured to determine the required hash value length based on the determined data collision threshold.

[0089] Based on the required target hash value length, the algorithm that calculates the required hash value length is determined as the first target algorithm.

[0090] Optionally, each hash value superposition algorithm calculates a different length of hash value based on the intermediate value. The target hash value superposition algorithm determination module is further used to determine the required hash value length based on the determined data collision threshold.

[0091] Based on the required hash value length, the hash value superposition algorithm that yields the required hash value length after calculation is determined as the target hash value superposition algorithm.

[0092] The cache key value determination device provided in this application embodiment can select an appropriate algorithm to calculate the string based on the number of generated strings to obtain key values ​​of different lengths. This solves the problem in the prior art where excessively long key values ​​lead to high space occupation and high computational cost in searching for such key values ​​in the data, while shortening the key value length leads to insufficient key values, resulting in hash collisions (i.e., duplicate key values), which in turn leads to data security and data tampering issues. The device achieves the effect of selecting an appropriate algorithm to calculate the string based on the currently required key value length.

[0093] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 4 As shown, the electronic device 400 includes a processor 410, a memory 420, and a bus 430.

[0094] The memory 420 stores machine-readable instructions executable by the processor 410. When the electronic device 400 is running, the processor 410 communicates with the memory 420 via the bus 430. When the machine-readable instructions are executed by the processor 410, they can perform the operations described above. Figure 1 as well as Figure 2The steps of the method for determining the cache key value in the method embodiment shown are described in detail in the method embodiment, and will not be repeated here.

[0095] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can perform the above-described actions. Figure 1 as well as Figure 2 The steps of the method for determining the cache key value in the method embodiment shown are described in detail in the method embodiment, and will not be repeated here.

[0096] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0097] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0098] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0099] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0100] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0101] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for determining a cache key value, characterized in that, include: Get the object to be cached; The object to be cached is encoded to generate a string corresponding to the object to be cached, and the data collision threshold corresponding to the number of generated strings is determined. Determine the required hash value length based on the identified data collision threshold; Based on the required target hash value length, the algorithm that calculates the required hash value length is determined as the first target algorithm. Each algorithm calculates a different hash value length based on the string. The data collision threshold is associated with a hash value length, and the hash collision probability of the hash value length is lower than a preset threshold for the amount of data corresponding to the data collision threshold. The hash value corresponding to the string is calculated according to the first target algorithm; The key value of the object to be cached is determined based on the hash value.

2. The method according to claim 1, characterized in that, The method further includes: Identify the data type corresponding to the string; Determine the type value corresponding to the identified data type; The step of determining the key value of the object to be cached based on the hash value includes: Insert the type value at a predetermined position in the hash value; The hash value after inserting the type value is determined as the key value of the object to be cached.

3. The method according to claim 1, characterized in that, The method further includes: Determine whether the data value corresponding to the data collision threshold is greater than a preset data threshold; If so, then based on the determined data collision threshold, at least two second target algorithms are selected from a set of preset algorithms; For each second objective algorithm, calculate the intermediate value corresponding to the string according to the second objective algorithm; Calculate the hash value corresponding to the string based on each intermediate value; The key value of the object to be cached is determined based on the hash value.

4. The method according to claim 3, characterized in that, The method further includes: Based on the determined data collision threshold, the target hash value superposition algorithm is determined from a variety of preset hash value superposition algorithms; The hash value corresponding to the string is calculated in the following way: The intermediate value corresponding to the string is input into the target hash value superposition algorithm to obtain the hash value corresponding to the string.

5. The method according to claim 4, characterized in that, Each hash value aggregation algorithm produces a different length of hash value based on the intermediate value. The step of determining the target hash value superposition algorithm from a variety of preset hash value superposition methods based on the determined data collision threshold includes: Determine the required hash value length based on the identified data collision threshold; Based on the required hash value length, the hash value superposition algorithm that yields the required hash value length after calculation is determined as the target hash value superposition algorithm.

6. A device for determining a cache key value, characterized in that, include: The module for retrieving objects to be cached is used to retrieve objects to be cached. The string generation module is used to encode the object to be cached, generate a string corresponding to the object to be cached, and determine the data collision threshold corresponding to the number of generated strings. The first target algorithm selection module is used to determine the required hash value length based on the determined data collision threshold; and to determine the algorithm that calculates the required hash value length as the first target algorithm based on the required target hash value length, wherein each algorithm calculates a different hash value length based on the string; the data collision threshold is associated with a hash value length, and the hash collision probability of the hash value length is lower than a preset threshold for the amount of data corresponding to the data collision threshold; The hash value calculation module is used to calculate the hash value corresponding to the string according to the first target algorithm; The key value determination module is used to determine the key value of the object to be cached based on the hash value.

7. The apparatus according to claim 6, characterized in that, The device further includes: A data type identification module is used to identify the data type corresponding to the string. The type value determination module is used to determine the type value corresponding to the identified data type; The Key value determination module is further configured to insert the type value at a preset position in the hash value; and determine the hash value after inserting the type value as the key value of the object to be cached.

8. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the method as described in any one of claims 1 to 5.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method as described in any one of claims 1 to 5.