Data processing method, device, electronic device and storage medium

By generating hash values ​​in Redis and obtaining numbers from the set number pool, combining TreeMap and custom parameters to generate traceable keys, the problem of Redis server downtime and inaccurate data statistics is solved, and data dereloading is achieved and accurate statistics.

CN113392110BActive Publication Date: 2025-01-14BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110654382.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-11
Publication Date
2025-01-14
Estimated Expiration
2041-06-11

AI Technical Summary

Technical Problem

Redis servers are prone to downtime when accessing large traffic, and the keys generated by random number combinations are not traceable, resulting in inaccurate data statistics results.

Method used

By generating a hash value to get the corresponding number from the set number pool, use TreeMap's tailMap method to obtain the number, and generate a traceable key in combination with custom parameters.

Benefits of technology

Ensure that the same data request always corresponds to the same key, avoid duplicate statistics, and ensure the accuracy of data statistics results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113392110B_ABST
    Figure CN113392110B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention are applicable to the field of data processing technology, and provide a data processing method, device, electronic device and storage medium, wherein the data processing method includes: when a data request is received, generating a corresponding first hash value based on the data request; obtaining a first number corresponding to the data request from a set number pool based on the first hash value; setting the number pool to store at least two different numbers; and generating a key corresponding to the data request based on the first number.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Redis is a key-value storage system. When a large amount of traffic accesses Redis, such as millions of requests accessing a key on Redis, the traffic will be too concentrated, causing the Redis server to crash. The related technology increases the number of corresponding keys on the Redis side, and the access pressure of the original key is shared by the increased keys. The related technology generates a new key through a random number combination, but the random number combination method is not traceable, and another key will be generated based on the request next time. Summary of the invention

[0003] In order to solve the above problems, the embodiments of the present invention provide a data processing method, device, electronic device and storage medium, so as to at least solve the problem that the key generated by random number combination in the related art is not traceable.

[0004] The technical solution of the present invention is achieved in this way:

[0005] In a first aspect, an embodiment of the present invention provides a data processing method, the method comprising:

[0006] In case of receiving a data request, generating a corresponding first hash value based on the data request;

[0007] Obtaining a first number corresponding to the data request from a set number pool based on the first hash value; the set number pool stores at least two different numbers;

[0008] A key corresponding to the data request is generated based on the first number.

[0009] In the above scheme, when generating at least two numbers in the set number pool based on set parameters, the method includes:

[0010] Based on a double-layer nested for loop traversing the set parameters, the at least two different numbers are generated; each number in the at least two different numbers is distributed in the set number pool in order from small to large; the difference between all adjacent numbers in the at least two different numbers is equal.

[0011] In the above solution, the method further includes:

[0012] Set the input custom parameters as the set parameters.

[0013] In the above solution, obtaining the first number corresponding to the data request from a set number pool based on the first hash value includes:

[0014] Based on the first hash value, a tailMap method of TreeMap is used to obtain a first number corresponding to the data request from the set number pool.

[0015] In the above solution, the step of generating a key corresponding to the data request based on the first number includes:

[0016] Determine a first parameter corresponding to the data request; the first parameter represents the identity of the corresponding key;

[0017] The first number and the first parameter are combined to obtain a key corresponding to the data request.

[0018] In the above solution, the data processing method further includes:

[0019] In a case where the first number corresponding to the data request cannot be obtained from the set number pool based on the first hash value, the first number in the set number pool is determined as the first number corresponding to the data request.

[0020] In the above solution, generating a corresponding first hash value based on the data request includes:

[0021] A hash calculation is performed on the request parameters of the data request to obtain the first hash value.

[0022] In a second aspect, an embodiment of the present invention provides a data processing device, the device comprising:

[0023] A first generating module, configured to generate a corresponding first hash value based on the data request when a data request is received;

[0024] an acquisition module, configured to acquire a first number corresponding to the data request from a set number pool based on the first hash value; the set number pool stores at least two different numbers;

[0025] The second generating module is used to generate a key corresponding to the data request based on the first number.

[0026] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the steps of the data processing method provided in the first aspect of the embodiment of the present invention.

[0027] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, including: the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the data processing method provided in the first aspect of the embodiment of the present invention are implemented.

[0028] When receiving a data request, the embodiment of the present invention generates a corresponding first hash value based on the data request, obtains a first number corresponding to the data request from a set digital pool based on the first hash value, and generates a key corresponding to the data request based on the first number. At least two different numbers are stored in the set digital pool. The embodiment of the present invention generates different keys based on different data requests, and the generated keys are traceable. The same data request always corresponds to the same key, which is very suitable for data statistics scenarios and can be used for data deduplication to ensure that duplicate statistics do not occur and ensure the accuracy of data statistical results. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 It is a schematic diagram of an implementation flow of a data processing method provided by an embodiment of the present invention;

[0030] Figure 2 It is a schematic diagram of an implementation flow of another data processing method provided by an embodiment of the present invention;

[0031] Figure 3 is a schematic diagram of another data processing flow provided by an embodiment of the present invention;

[0032] Figure 4 is a schematic diagram of a data processing device provided by an embodiment of the present invention;

[0033] Figure 5 It is a schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

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

[0035] When using Redis cache to count the total data, when a large amount of traffic accesses Redis, such as millions of requests accessing a key on Redis, the traffic will be too concentrated and reach the upper limit of the physical network card, causing the Redis server to crash. To solve this problem, related technologies increase the number of corresponding keys on the Redis side. The current common method is to generate new keys through random number combinations, and use the new keys to share the access pressure of the original keys.

[0036] However, the key generated by the random number combination is not traceable, and a different key will be generated based on the next request. This means that when using Redis to count users, the same user's access in different time periods will fall on different keys, resulting in inaccurate data statistics.

[0037] In view of the shortcomings of the above-mentioned related technologies, an embodiment of the present invention provides a data processing method, which can at least make the generated key traceable, and the same data request always corresponds to the same key, thereby ensuring the accuracy of the data statistical results. In order to illustrate the technical solution of the present invention, a specific embodiment is used for illustration below.

[0038] Figure 1 1 is a schematic diagram of an implementation flow of a data processing method provided by an embodiment of the present invention. The execution subject of the data processing method may be an electronic device, and the electronic device may be a desktop computer, a notebook computer, a server, etc. Figure 1 , the data processing methods include:

[0039] S101: upon receiving a data request, generating a corresponding first hash value based on the data request.

[0040] Here, the data request can be any request to Redis, for example, the data request can be to access a key in Redis.

[0041] In one embodiment, generating a corresponding first hash value based on the data request includes:

[0042] A hash calculation is performed on the request parameters of the data request to obtain the first hash value.

[0043] Here, the request parameters of the data request include a user name, a device number, etc. The request parameters are hashed to obtain a first hash value. In practical applications, the MurMurHash algorithm can be used to calculate the first hash value of the request parameters. MurmurHash is a non-encrypted hash function suitable for general hash retrieval operations.

[0044] The first hash value generated based on the same data request is unique, and the first hash values ​​generated based on different data requests are necessarily different.

[0045] S102: Obtain a first number corresponding to the data request from a set number pool based on the first hash value; the set number pool stores at least two different numbers.

[0046] The number pool is a pre-created data set for storing numbers. The number of numbers in the number pool is determined by the business request volume of Redis.

[0047] Before loading the business, you need to initialize the number pool and generate numbers in the number pool based on the parameters customized by the developer.

[0048] In one embodiment, when generating at least two numbers in the set number pool based on set parameters, the method includes:

[0049] Based on a double-layer nested for loop traversing the set parameters, the at least two different numbers are generated; each number in the at least two different numbers is distributed in the set number pool in order from small to large; the difference between all adjacent numbers in the at least two different numbers is equal.

[0050] Here, the custom parameter input by the developer is set as the setting parameter. In practical applications, the setting parameter can be calculated using the MurMurHash algorithm to obtain at least two different numbers.

[0051] In the process of generating at least two numbers, a double nested for loop is used to traverse the set parameters so that the generated at least two different numbers are evenly and stably distributed in the set number pool. For example, a total of 10 numbers are generated, and the distribution of the generated 10 numbers in the set number pool is (1, 3, 5, 7, 9, 11, 13, 15, 17, 19), where each number is distributed in order from small to large, and the difference between all adjacent numbers is 2.

[0052] In actual application, two layers of for loops are used to store the Long numbers generated by calling the MurMurHash algorithm in TreeMap. The setting parameters can be i+"*"+"1"+n, and the generated number value is Long type. All the numbers generated are finally saved in TreeMap<Long,String> In which Long is the algorithm Hash value, String is the description information, and keys refers to the digital pool.

[0053] In one embodiment, obtaining the first number corresponding to the data request from a set number pool based on the first hash value includes:

[0054] Based on the first hash value, a tailMap method of TreeMap is used to obtain a first number corresponding to the data request from the set number pool.

[0055] For example, assuming that the first hash value corresponding to the data request is A, based on the set number pool, use the tailMap(A).firstKey() method to obtain the first number B corresponding to the request parameter in the set number pool.

[0056] In one embodiment, the data processing method further includes:

[0057] In a case where the first number corresponding to the data request cannot be obtained from the set number pool based on the first hash value, the first number in the set number pool is determined as the first number corresponding to the data request.

[0058] When an exception occurs when calling the tailMap method, that is, the first number corresponding to the data request cannot be obtained from the set number pool, TreeMap is used to obtain firstKey(), that is, the first number in the set number pool is used as the first number corresponding to the data request.

[0059] S103: Generate a key corresponding to the data request based on the first number.

[0060] Here, the obtained first number can be directly used as the key corresponding to the data request, or the first number can be used as a part of the key.

[0061] refer to Figure 2 In one embodiment, generating a key corresponding to the data request based on the first number includes:

[0062] S201, determine a first parameter corresponding to the data request; the first parameter represents the identity of the corresponding key.

[0063] The first parameter here is used to distinguish different keys, so that developers can get some information through the first parameter. For example, if the first parameter is "APP+page 1", through the first parameter, developers can know that the corresponding data request of the key is to access page 1 of the APP.

[0064] S202: Combine the first number and the first parameter to obtain a key corresponding to the data request.

[0065] By combining the first number and the first parameter, developers can understand the key more easily, avoid conflicts with other keys, and distinguish it from other keys.

[0066] The field obtained by combining the first number and the first parameter is used as the key corresponding to the data request. In practical applications, the generated key can be stored in the Map<String,Object> In this example, String is the key and Object is the corresponding information. For example, if the number is counted, Object is the number of counts.

[0067] In this way, the same key can be calculated for each identical data request. The key is traceable, efficient, and available, which is very suitable for deduplication scenarios of people or devices. For example, when counting the number of visiting users, the same user's visits in different time periods always correspond to the same key, so that the same user will not be counted repeatedly, ensuring the accuracy of the statistical results. In addition, the same data request always corresponds to the same key, and other data requests will not request the key, so there will be no hot key problem caused by a single key.

[0068] When receiving a data request, the embodiment of the present invention generates a corresponding first hash value based on the data request, obtains a first number corresponding to the data request from a set digital pool based on the first hash value, and generates a key corresponding to the data request based on the first number. At least two different numbers are stored in the set digital pool. The embodiment of the present invention generates different keys based on different data requests, and the generated keys are traceable. The same data request always corresponds to the same key, which is very suitable for data statistics scenarios and can be used for data deduplication to ensure that duplicate statistics do not occur and ensure the accuracy of data statistical results.

[0069] refer to Figure 3 , Figure 3 It is a schematic diagram of a data processing flow provided by an application embodiment of the present invention. First, initialize a digital pool. Traverse the setting parameters through a double-layer nested for loop to control the total number of numbers in the digital pool so that the numbers are evenly and stably distributed in the digital pool. For example, a total of 10 numbers are generated, and the distribution of the 10 numbers generated in the setting digital pool is (1, 3, 5, 7, 9, 11, 13, 15, 17, 19), wherein each number is distributed in order from small to large, and the difference of all adjacent numbers is 2. The MurMurHash algorithm is used to perform hash calculation on the setting parameters, and the calculated hash value is stored in the TreeMap. Wherein, the setting parameters are parameters customized by the developer.

[0070] Then, based on the request parameters of the data request, the MurMurHash algorithm is used to generate a hash value A. Based on the hash value A, the tailMap method of TreeMap is used to intercept the current segment, obtain firstKey(), and obtain the number B in the number pool. The number B is used as the key corresponding to the data request, or part of the key. In the case that the number in the number pool cannot be obtained abnormally, TreeMap is used to obtain firstKey() as the key corresponding to the data request, or part of the key. Among them, the request parameters of the data request include user name, device number, etc. MurmurHash is a non-encrypted hash function suitable for general hash retrieval operations.

[0071] Finally, store the generated key in Map<String,Object> The generated key is traceable, and the same data request always corresponds to the same key, which is very suitable for data statistics scenarios and can be used for data deduplication to ensure that duplicate statistics do not occur and the accuracy of data statistics results. In addition, the same data request always corresponds to the same key, and other data requests will not request the key, so there will be no hot key problem caused by a single key.

[0072] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0073] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0074] It should be noted that the technical solutions described in the embodiments of the present invention can be arbitrarily combined without conflict.

[0075] In addition, in the embodiments of the present invention, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0076] refer to Figure 4 , Figure 4 is a schematic diagram of a data processing device provided by an embodiment of the present invention, such as Figure 5 As shown, the device includes: a first generating module, an acquiring module and a second generating module.

[0077] A first generating module, configured to generate a corresponding first hash value based on the data request when a data request is received;

[0078] an acquisition module, configured to acquire a first number corresponding to the data request from a set number pool based on the first hash value; the set number pool stores at least two different numbers;

[0079] The second generating module is used to generate a key corresponding to the data request based on the first number.

[0080] In one embodiment, when the acquisition module generates at least two numbers in the set number pool based on the set parameters, it is used to:

[0081] Based on a double-layer nested for loop traversing the set parameters, the at least two different numbers are generated; each number in the at least two different numbers is distributed in the set number pool in order from small to large; the difference between all adjacent numbers in the at least two different numbers is equal.

[0082] In the process of generating at least two numbers, a double nested for loop is used to traverse the set parameters so that the generated at least two different numbers are evenly and stably distributed in the set number pool. For example, a total of 10 numbers are generated, and the distribution of the generated 10 numbers in the set number pool is (1, 3, 5, 7, 9, 11, 13, 15, 17, 19), where each number is distributed in order from small to large, and the difference between all adjacent numbers is 2.

[0083] In one embodiment, the device further comprises:

[0084] The setting module is used to set the input custom parameters as the setting parameters.

[0085] In one embodiment, when the acquisition module acquires the first number corresponding to the data request from the set number pool based on the first hash value, it is used to:

[0086] Based on the first hash value, a tailMap method of TreeMap is used to obtain a first number corresponding to the data request from the set number pool.

[0087] For example, assuming that the first hash value corresponding to the data request is A, based on the set number pool, use the tailMap(A).firstKey() method to obtain the first number B corresponding to the request parameter in the set number pool.

[0088] In one embodiment, when the second generating module generates the key corresponding to the data request based on the first number, it is used to:

[0089] Determine a first parameter corresponding to the data request; the first parameter represents the identity of the corresponding key;

[0090] The first number and the first parameter are combined to obtain a key corresponding to the data request.

[0091] The first parameter here is used to distinguish different keys, so that developers can get some information through the first parameter. For example, if the first parameter is "APP+page 1", through the first parameter, developers can know that the corresponding data request of the key is to access page 1 of the APP. By combining the first number and the first parameter, it is easier for developers to understand the key, avoid conflicts with other keys, and distinguish it from other keys.

[0092] In one embodiment, the data processing device further includes:

[0093] A determination module is used to determine the first number in the set number pool as the first number corresponding to the data request when the first number corresponding to the data request cannot be obtained from the set number pool based on the first hash value.

[0094] In one embodiment, when the first generating module generates the corresponding first hash value based on the data request, it is used to:

[0095] A hash calculation is performed on the request parameters of the data request to obtain the first hash value.

[0096] The first hash value of the request parameter may be calculated using the MurMurHash algorithm. MurmurHash is a non-encryption hash function suitable for general hash retrieval operations.

[0097] In actual application, the first generation module, the acquisition module and the second generation module can be implemented by a processor in an electronic device, such as a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU) or a programmable gate array (FPGA).

[0098] It should be noted that: when the data processing device provided in the above embodiment performs data processing, only the division of the above modules is used as an example. In actual applications, the above processing can be assigned to different modules as needed, that is, the internal structure of the device is divided into different modules to complete all or part of the processing described above. In addition, the data processing device provided in the above embodiment and the data processing method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0099] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Figure 5 Schematic diagram of the hardware structure of the electronic device of the present application embodiment. Figure 5 As shown, the electronic equipment includes:

[0100] Communication interface, which can exchange information with other devices such as network equipment;

[0101] The processor is connected to the communication interface to realize information exchange with other devices, and is used to execute the method provided by one or more technical solutions of the electronic device side when running the computer program. The computer program is stored in the memory.

[0102] Of course, in actual applications, the various components in the electronic device are coupled together through the bus system. It is understandable that the bus system is used to achieve connection and communication between these components. In addition to the data bus, the bus system also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 5 In the specification, various buses are labeled as bus systems.

[0103] The memory in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0104] It can be understood that the memory can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.

[0105] The method disclosed in the above embodiment of the present application can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the program in the memory and completes the steps of the above method in combination with its hardware.

[0106] Optionally, when the processor executes the program, the corresponding processes implemented by the electronic device in each method of the embodiments of the present application are implemented, which will not be described in detail here for the sake of brevity.

[0107] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, including a first memory storing a computer program, and the computer program can be executed by a processor of an electronic device to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.

[0108] In the several embodiments provided in the present application, it should be understood that the disclosed devices, electronic devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0109] The units described above 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 distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0110] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0111] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.

[0112] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0113] It should be noted that the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0114] In addition, in the examples of the present application, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0115] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data processing method, characterized in that: include: In case of receiving a data request, generating a corresponding first hash value based on the data request; generating at least two different numbers from a set number pool based on set parameters; Obtaining a first number corresponding to the data request from the set number pool based on the first hash value; The set number pool stores at least two different numbers; A key corresponding to the data request is generated based on the first number.

2. The method according to claim 1, characterized in that When generating at least two numbers in the set number pool based on set parameters, the method includes: Based on a double-layer nested for loop traversing the set parameters, the at least two different numbers are generated; each number in the at least two different numbers is distributed in the set number pool in order from small to large; the difference between all adjacent numbers in the at least two different numbers is equal.

3. The method according to claim 2, characterized in that The method further comprises: Set the input custom parameters as the set parameters.

4. The method according to claim 1, characterized in that: The obtaining the first number corresponding to the data request from the set number pool based on the first hash value includes: Based on the first hash value, a tailMap method of TreeMap is used to obtain a first number corresponding to the data request from the set number pool.

5. The method according to claim 1, characterized in that The generating a key corresponding to the data request based on the first number includes: Determine a first parameter corresponding to the data request; the first parameter represents the identity of the corresponding key; The first number and the first parameter are combined to obtain a key corresponding to the data request.

6. The method according to claim 1, characterized in that The data processing method further includes: In a case where the first number corresponding to the data request cannot be obtained from the set number pool based on the first hash value, the first number in the set number pool is determined as the first number corresponding to the data request.

7. The method according to claim 1, characterized in that Generating a corresponding first hash value based on the data request includes: A hash calculation is performed on the request parameters of the data request to obtain the first hash value.

8. A data processing device, characterized in that: include: A first generating module, configured to generate a corresponding first hash value based on the data request when a data request is received; The acquisition module is further used to acquire the first number corresponding to the data request from a set number pool based on the first hash value; The set number pool stores at least two different numbers; the at least two different numbers are generated based on set parameters; The second generating module is used to generate a key corresponding to the data request based on the first number.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the data processing method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the data processing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • A data processing method and device, an electronic device and a computer storage medium

    CN109033278A

  • Resource processing method and device, server and computer readable storage medium

    CN110909978A