Method and device for processing data request for cache database

By dividing the data request commands of the cache database into multiple categories for parallel processing, the problem of low processing efficiency of the cache database is solved and the effect of improving data processing efficiency is achieved.

CN111930781BActive Publication Date: 2024-09-13BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010725403.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-24
Publication Date
2024-09-13
Estimated Expiration
2040-07-24

AI Technical Summary

Technical Problem

The cache database uses single-threaded serial processing when processing data requests, resulting in low processing efficiency and no effective solution.

Method used

Divide multiple commands for data requests into multiple types of commands and run them in parallel instead of using single-threaded serial processing.

Benefits of technology

By running multiple types of commands in parallel, the data processing efficiency is improved and the problem of low processing efficiency of the cache database is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111930781B
    Figure CN111930781B
Patent Text Reader

Abstract

The present application discloses a method and device for processing data requests for a cache database. The method includes: obtaining a data request, the data request is used to request an operation on the cache database; dividing multiple commands corresponding to the data request into multiple categories of commands, each of the multiple commands belonging to one of the multiple categories of commands; and running the multiple categories of commands in parallel. The present application solves the technical problem of low cache processing efficiency in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of the Internet, and in particular, to a method and device for processing data requests for a cache database. Background Art

[0002] With the development of computer technology, more and more computer technologies are being applied to various application systems. In order to solve the performance problems caused by high concurrency, current application systems generally add a cache layer between the application system and the database. The most widely used is the non-relational database (a cache database used on memory). As a buffer layer between the software and the traditional database, the operation commands are simple, and high performance is guaranteed while ensuring data validity.

[0003] After analyzing the relevant technologies, the inventors realized that in order to achieve high availability and high compatibility of the cache and ensure stable operation on most user machines, the cache is not optimized. When processing data requests, the cache processes the various commands corresponding to the request in sequence according to the instruction order, which results in low cache processing efficiency.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present application provide a method and device for processing data requests for a cache database, so as to at least solve the technical problem of low cache processing efficiency in related technologies.

[0006] According to one aspect of an embodiment of the present application, a method for processing data requests for a cache database is provided, including: obtaining a data request, wherein the data request is used to request an operation on the cache database; dividing multiple commands corresponding to the data request into multiple categories of commands, wherein each of the multiple commands belongs to one of the multiple categories of commands; and running the multiple categories of commands in parallel.

[0007] According to another aspect of an embodiment of the present application, a processing device for data requests for a cache database is also provided, including: an acquisition unit, used to acquire data requests, wherein the data requests are used to request operations on the cache database; a division unit, used to divide multiple commands corresponding to the data requests into multiple categories of commands, wherein each of the multiple commands belongs to one of the multiple categories of commands; and an execution unit, used to execute the multiple categories of commands in parallel.

[0008] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above method is executed when the program is run.

[0009] According to another aspect of an embodiment of the present application, an electronic device is further provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above method through the computer program.

[0010] In an embodiment of the present application, multiple commands corresponding to data requests are divided into multiple categories of commands, so that when performing data operations, it can be achieved by running multiple categories of commands in parallel, rather than running multiple commands of data requests serially in a traditional single-threaded manner. This can solve the technical problem of low cache processing efficiency in related technologies, thereby achieving the technical effect of improving data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0012] Figure 1 It is a schematic diagram of an operation scheme of Redis cache in the related art;

[0013] Figure 2 is a schematic diagram of a hardware environment of a method for processing a data request to a cache database according to an embodiment of the present application;

[0014] Figure 3 is a flowchart of an optional method for processing a data request for a cache database according to an embodiment of the present application;

[0015] Figure 4 is a flowchart of an optional method for processing a data request for a cache database according to an embodiment of the present application;

[0016] Figure 5 is a schematic diagram of an optional thread allocation according to an embodiment of the present application;

[0017] Figure 6 is a schematic diagram of an optional device for processing data requests to a cache database according to an embodiment of the present application; and,

[0018] Figure 7 It is a structural block diagram of a terminal according to an embodiment of the present application. DETAILED DESCRIPTION

[0019] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0020] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0021] After analyzing the relevant technologies, the inventors realized that traditional caches (such as Redis, which is mainly used for data caching, and the Redis API is mainly used to send Redis commands to Redis to operate the Redis database for reading and writing) use a single thread to process and execute the read and write operations of the commands, such as Figure 1 As shown, the client sends a data read request command to the Redis cache. The Redis cache detects the data read request command through the IO event, parses it using the parsing protocol, executes the parsed command, and returns the execution result to the client.

[0022] As a cache service with more reads than writes, the single-threaded mode that can only process a single command in serial is the performance bottleneck of the Redis cache. According to one aspect of the embodiment of the present application, a method embodiment of a method for processing data requests for a cache database is provided.

[0023] Optionally, in this embodiment, the above method for processing data requests to the cache database can be applied to: Figure 2 In the hardware environment composed of the first device 201 and the second device 203 shown in FIG. Figure 2As shown, the second device 203 is connected to the first device 201 via a network, and can be used to provide services (such as data services, application services, etc.) for the first device or a client installed on the first device. A database 205 can be set on the second device or independently of the second device to provide data storage services for the second device 203. The above-mentioned network includes but is not limited to: a wide area network, a metropolitan area network or a local area network. The first device 201 is not limited to a PC, a mobile phone, a tablet computer, etc.; the second device 203 is not limited to a server, a computer device, etc.

[0024] The method for processing a data request for a cache database in the embodiment of the present application may be executed by the second device 203 , or may be executed jointly by the second device 203 and the first device 201 . Figure 3 is a flowchart of an optional method for processing a data request to a cache database according to an embodiment of the present application, such as Figure 3 As shown, the method may include the following steps:

[0025] Step S302: The second device obtains a data request, where the data request is used by the first device to request an operation on a cache database on the second device.

[0026] The cache database may be a non-relational database cache such as Redis, Memchache, MongoDb, etc. The cache may be located between the second device and the database 205, and the data request is used to request operations such as read, write, modify, and delete.

[0027] Step S304, the second device divides the multiple commands corresponding to the data request into multiple categories of commands, each of the multiple commands belongs to one of the multiple categories of commands, the multiple categories of commands are commands that can be executed in parallel, and the multiple categories of commands are commands that have no data correlation.

[0028] Step S306: The second device runs multiple types of commands in parallel and obtains corresponding running results, which can be returned to the first device.

[0029] By adopting the technical solution described in the above steps of this application, multiple commands corresponding to data requests are divided into multiple categories of commands. In this way, when processing data requests, multiple categories of commands can be run in parallel, rather than running multiple commands of data requests in series in a traditional single-threaded manner. This can solve the technical problem of low cache processing efficiency in related technologies, thereby achieving the technical effect of improving data processing efficiency. Figure 3 The steps shown further detail the technical solution of the present application.

[0030] In the technical solution provided in step S302, when the first device needs to operate the cache database on the second device, the first device sends a data request for representing a data operation command to the second device.

[0031] In the technical solution provided in step S304, the second device divides the multiple commands corresponding to the data request into multiple categories of commands, and each of the multiple commands belongs to one of the multiple categories of commands, so as to run the multiple categories of commands in parallel.

[0032] The above-mentioned multiple types of commands run in parallel on the corresponding carriers, and the level of parallel running can be chip-level parallel running (i.e., each chip runs one type of command), chip core-level parallel running (i.e., each chip core runs one type of command), process-level parallel running (i.e., each process on the chip runs one type of command), and thread-level parallel running (i.e., each thread on the chip runs one type of command). The following will take thread-level parallel running as an example for explanation.

[0033] In the above embodiment, the multiple commands corresponding to the data request are divided into multiple categories of commands, which can be classified according to the type of command, such as read command, write command, modification, deletion, etc., where each type of command is divided into one type. It can also be divided into two types of threads, namely read command processing thread and write command processing thread (which can process write, modify, delete and other operations, and merge these operations into one thread to optimize the use of processor core resources, thereby reducing unnecessary interaction overhead between threads). When the thread corresponding to the client (i.e., the client managing the database) detects the IO event to be processed, it parses the command and assigns the corresponding thread to process it, and then uses the corresponding thread to process the data.

[0034] Optionally, dividing the multiple commands corresponding to the data request into multiple types of commands includes the following steps 1 to 5:

[0035] Step 1: When the first thread receives a data request (i.e., an IO event) from the first device, a second thread in an idle state is searched among multiple second threads. For example, the multiple second threads can run in parallel, i.e., multiple data requests can be processed in the same period of time, so it is possible to directly query whether each second thread is processing other data requests to check whether it is in an idle state.

[0036] Step 2: The first thread sends a data request to the second thread in the idle state.

[0037] Step 3, the second thread parses the data request, the data request includes a packet header and a packet tail set in an agreed format and a data operation command therebetween, and the parsing can be performed according to the agreed format.

[0038] Step 4: When the command obtained through parsing is a write command, the second thread sends the write command obtained through parsing to the command list of the first thread.

[0039] Step 5: When the command obtained through parsing is a read command, the second thread saves the read command obtained through parsing as a command to be executed.

[0040] In the above scheme, commands are mainly divided into two categories, one is a read command (which can be processed by the second thread), and the other is a write command (which can be processed by the first thread). In practice, more categories can be included as needed.

[0041] In the technical solution provided in step S306, multiple types of commands are executed in parallel, and the execution results are sent to the first device.

[0042] In the above embodiment, each type of command among the multiple types of commands can be run on one carrier among the multiple carriers, and the carriers used to run any two types of commands among the multiple types of commands are different. The same type of commands can be run on the same carrier or on different carriers respectively. The multiple carriers are carriers running in parallel, such as processor chips, chip cores, processes, threads, etc.

[0043] Optionally, taking thread-level parallel processing as an example, before running each of the multiple types of commands on one of the multiple carriers, multiple threads can be created on the processor of the second device, and the multiple carriers include multiple threads; when running each of the multiple types of commands on one of the multiple carriers, each of the multiple types of commands is run on one of the multiple threads, and each thread runs one type of command.

[0044] Optionally, running each of the multiple types of commands on one of the multiple threads includes: running a write command on the first thread, the write command is used to indicate writing data in the cache database, the write command belongs to the first type of commands among the multiple types of commands (commands other than read commands, such as write commands, modify commands, delete commands, etc., can be set as first type of commands), and the multiple threads include the first thread; and / or, running a read command on the second thread, the read command is used to indicate reading data from the cache database, the read command belongs to the second type of commands among the multiple types of commands (the read command can be set as the second type of command), and the multiple threads include the second thread.

[0045] In the above embodiment, when running a write command on the first thread, the number of first threads can be multiple, but in order to take into account the existing scenarios (the existing scenarios use a single thread), it can also be one. At this time, running the write command on the first thread includes running each write command in the command list on the first thread in the following manner: the first thread obtains the target write command from the command list, caches all pending write commands through the command list, and the target write command is the pending write command in the command list; and runs the target write command on the first thread.

[0046] Optionally, the cache may be temporarily inaccessible due to some reasons (such as downtime or locked state), but will be restored after a period of time. In order to ensure the normal execution of the business, during the process of running the write command on the first thread, the processing status of the command can be recorded according to the scheme shown in the following steps 1 to 3, and repeated when necessary:

[0047] Step 1, after the first thread obtains the target write command from the command list, the state of the target write command is changed from pending to being processed;

[0048] Step 2: If the first thread successfully executes the target write command, the status of the target write command is changed from being processed to completed, and the command with the completed status will not be executed again;

[0049] Step 3: When the first thread fails to execute the target write command, the state of the target write command is changed from being processed to pending, so that it can be executed again later.

[0050] Optionally, considering that some faults are unrecoverable in a short time, but read and write resources are limited, in order to use limited resources to process valuable services, after changing the status of the target write command from being processed to pending, the following steps 1-2 can be followed:

[0051] Step 1, record the number of times the target write command fails to run;

[0052] Step 2: When the number of target write command execution failures reaches a target threshold, the target write command is no longer executed repeatedly, and prompt information indicating that the target write command execution failed is pushed to the first device.

[0053] In the above embodiment, in order to improve processing efficiency, when running a read command on the second thread, if there are multiple read commands, multiple read commands are run on multiple second threads, each second thread is used to run at least one read command, the number of read commands is m, and the number of second threads is n, then the number m is greater than or equal to n, and these multiple read commands can be to read the same file or a type of data (each read command reads a part of it), or they can read multiple files or multiple types of data (each read command reads at least one file or at least one type of data).

[0054] Optionally, after the command is executed, when multiple types of commands are executed in parallel on the first device, the execution results obtained by executing the multiple types of commands on multiple carriers may be returned to the first device.

[0055] In the technical solution of the present application, the command parsing part can be separated into a read command running thread (i.e., the second thread), and the write command running thread can be set to one. Since the read command running thread does not involve the modification of memory data, it can be set to multiple threads. The specific number can be parameterized according to the specific business scenario, thereby improving the processing efficiency in the relevant technology.

[0056] Redis is a cache service with more reads than writes. Therefore, a single command processing thread is the bottleneck of Redis performance. As an optional implementation example, Figure 4 and Figure 5 , taking Redis cache as an example, the technical solution of this application is further described in detail.

[0057] The present invention is mainly aimed at customers with high performance requirements. These customers need Redis to accept IOPS capabilities that exceed the conventional ones. Assuming that the QPS of the conventional Redis community version is generally around N (such as 100,000), but they want to increase an instance to several times or even ten times N without adding so many nodes, thereby solving the customer's problem.

[0058] Step S402: When the client initiates a command execution request (or command execution request), the write command execution thread detects a new IO event connection.

[0059] Step S404: when there is a new connection, the write command execution thread distributes the IO event to the corresponding read command execution thread according to the algorithm.

[0060] Step S406: the read command execution thread receives an IO event.

[0061] Step S408, the read command execution thread starts processing the IO event, performs corresponding protocol analysis, and obtains the analyzed command.

[0062] Step S410, determine whether it is a read command or a write command. The read command execution thread distinguishes data read commands and data modification or write commands through the command table. If it is a read command, execute step S412, and if it is a write command, execute step S416.

[0063] Step S412: the read command execution thread itself executes the read command.

[0064] Step S414: After the read command execution thread completes its own execution, it returns the execution result to the client.

[0065] Step S416: If it is a write command, the read command execution thread sends the command to the command queue of the write command execution thread. When the write command execution thread finds that there is corresponding data in its queue, it reads the command to be executed.

[0066] Step S418: The write command execution thread executes the corresponding command, and updates the data, updates the master-slave replication information, and other operations that affect the state of data consistency.

[0067] Step S420: After the command execution is completed, the command execution thread directly returns the result to the client.

[0068] In the technical solution of the present application, the logic of command execution is divided into different threads, multiple read command processing threads and multiple write command processing threads are adopted, a single write command execution thread is maintained, and the special characteristics of native Redis are maintained.

[0069] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0070] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0071] According to another aspect of an embodiment of the present application, a device for processing data requests to a cache database for implementing the above-mentioned method for processing data requests to a cache database is also provided. Figure 6 is a schematic diagram of an optional device for processing data requests to a cache database according to an embodiment of the present application, such as Figure 6 As shown, the device may include:

[0072] The acquisition unit 601 is used to acquire a data request, where the data request is used to request an operation to be performed on a cache database.

[0073] The division unit 603 is configured to divide the multiple commands corresponding to the data request into multiple categories of commands, wherein each of the multiple commands belongs to one of the multiple categories of commands.

[0074] The running unit 605 runs multiple types of commands in parallel.

[0075] It should be noted that the acquisition unit 601 in this embodiment can be used to execute step S302 in the embodiment of the present application, the division unit 603 in this embodiment can be used to execute step S304 in the embodiment of the present application, and the operation unit 605 in this embodiment can be used to execute step S306 in the embodiment of the present application.

[0076] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 2 In the hardware environment shown, it can be implemented by software or by hardware.

[0077] Through the above module, multiple commands corresponding to data requests are divided into multiple categories of commands, so that when executing data operation commands, it can be achieved by running multiple categories of commands in parallel, rather than running multiple commands of data requests serially in a traditional single-threaded manner. This can solve the technical problem of low cache processing efficiency in related technologies, thereby achieving the technical effect of improving data processing efficiency.

[0078] Optionally, the running unit of the present application is used to run each type of command in the multiple types of commands on one of the multiple carriers before running the multiple types of commands in parallel to the first device, wherein the carriers used to run any two types of commands in the multiple types of commands are different, and the multiple carriers are carriers running in parallel.

[0079] Optionally, the running unit may be further configured to return to the first device running results obtained by running multiple types of commands on multiple carriers.

[0080] Optionally, the apparatus of the present application may further include: a creation unit, configured to create multiple threads on a processor of the second device before running each of the multiple types of commands on one of the multiple carriers, wherein the multiple carriers include multiple threads.

[0081] Optionally, the execution unit may also be configured to execute each type of command among the multiple types of commands on one thread among the multiple threads.

[0082] Optionally, the above-mentioned running unit can also be used to: run a write command on the first thread, wherein the write command is used to indicate writing data in the cache database, the write command belongs to a first type of command among multiple types of commands, and the multiple threads include the first thread; and / or, run a read command on the second thread, wherein the read command is used to indicate reading data from the cache database, the read command belongs to a second type of command among multiple types of commands, and the multiple threads include the second thread.

[0083] Optionally, the above-mentioned execution unit can also be used to execute each write command in the command list on the first thread in the following manner: the first thread obtains a target write command from the command list, wherein the command list is used to store write commands to be processed, and the target write command is the write command to be processed in the command list; and, executes the target write command on the first thread.

[0084] Optionally, the above-mentioned running unit can also be used to: during the process of running a write command on the first thread, after the first thread obtains the target write command from the command list, change the status of the target write command from pending to processing; when the first thread successfully runs the target write command, change the status of the target write command from processing to completed; and, when the first thread fails to run the target write command, change the status of the target write command from processing to pending.

[0085] Optionally, the above-mentioned operation unit can also be used to: record the number of times the target write command fails to run after changing the status of the target write command from being processed to being processed; and, when the number of times the target write command fails to run reaches a target threshold, no longer repeatedly run the target write command, and push a prompt message that the target write command has failed to run to the first device.

[0086] Optionally, the above-mentioned execution unit may also be used for: in the case where there are multiple read commands, executing the multiple read commands on multiple second threads, wherein each second thread is used for executing at least one read command.

[0087] Optionally, the above-mentioned division unit can also be used for: when the first thread detects a data request, the first thread sends the data request to the second thread, wherein the multiple threads include the first thread and the second thread; the second thread parses the data request; when the command obtained by parsing is a write command, the second thread sends the parsed write command to the command list of the first thread; and when the command obtained by parsing is a read command, the second thread saves the parsed read command as a command to be executed.

[0088] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 2 In the hardware environment shown, it can be implemented by software or by hardware, wherein the hardware environment includes a network environment.

[0089] According to another aspect of an embodiment of the present application, a server or terminal for implementing the above-mentioned method for processing data requests to a cache database is also provided.

[0090] Figure 7is a structural block diagram of a terminal according to an embodiment of the present application, such as Figure 7 As shown, the terminal may include: one or more ( Figure 7 (only one is shown) processor 701, memory 703, and transmission device 705, as shown in Figure 7 As shown, the terminal may also include an input and output device 707.

[0091] Among them, the memory 703 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for processing data requests for the cache database in the embodiment of the present application. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 703, that is, the above-mentioned method for processing data requests for the cache database is realized. The memory 703 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 703 may further include a memory remotely arranged relative to the processor 701, and these remote memories can be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0092] The above-mentioned transmission device 705 is used to receive or send data via a network, and can also be used for data transmission between a processor and a memory. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one example, the transmission device 705 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 705 is a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.

[0093] Specifically, the memory 703 is used to store application programs.

[0094] The processor 701 may call the application stored in the memory 703 through the transmission device 705 to perform the following steps:

[0095] Obtaining a data request, wherein the data request is used to request an operation on a cache database;

[0096] dividing the plurality of commands corresponding to the data request into a plurality of categories of commands, wherein each of the plurality of commands belongs to one of the plurality of categories of commands; and

[0097] Run multiple types of commands in parallel.

[0098] The processor 701 is further configured to execute the following steps:

[0099] In the event that the first thread detects the data request requested by the data request, the first thread sends the data request to the second thread, wherein the plurality of threads includes the first thread and the second thread;

[0100] The second thread parses the data request;

[0101] In the case where the command obtained by parsing is a write command, the second thread sends the write command obtained by parsing to the command list of the first thread; and,

[0102] When the command obtained through parsing is a read command, the second thread saves the read command obtained through parsing as a command to be executed.

[0103] By adopting the embodiment of the present application, a scheme of "obtaining a data request, wherein the data request is used to request an operation on a cache database; dividing multiple commands corresponding to the data request into multiple categories of commands, wherein each of the multiple commands belongs to one of the multiple categories of commands; and running the multiple categories of commands in parallel" is provided. By dividing the multiple commands corresponding to the data request into multiple categories of commands, the processing of the data request can be achieved by running multiple categories of commands in parallel, rather than running multiple commands of the data request serially in a single-threaded manner, which can solve the technical problem of low cache processing efficiency in the related art, thereby achieving the technical effect of improving data processing efficiency.

[0104] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0105] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only, and the terminal may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 7 It does not limit the structure of the above electronic device. For example, the terminal may also include Figure 7 More or fewer carriers (such as network interfaces, display devices, etc.) as shown in, or having Figure 7 Different configurations shown.

[0106] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0107] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to execute the program code of the method for processing data requests to the cache database.

[0108] Optionally, in this embodiment, the storage medium may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.

[0109] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:

[0110] Obtaining a data request, wherein the data request is used to request an operation on a cache database;

[0111] dividing the plurality of commands corresponding to the data request into a plurality of categories of commands, wherein each of the plurality of commands belongs to one of the plurality of categories of commands; and

[0112] Run multiple types of commands in parallel.

[0113] Optionally, the storage medium is further configured to store program codes for executing the following steps:

[0114] In case the first thread detects the data request, the first thread sends the data request to the second thread, wherein the plurality of threads include the first thread and the second thread;

[0115] The second thread parses the data request;

[0116] In the case where the command obtained by parsing is a write command, the second thread sends the write command obtained by parsing to the command list of the first thread; and,

[0117] When the command obtained through parsing is a read command, the second thread saves the read command obtained through parsing as a command to be executed.

[0118] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0119] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0120] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0121] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.

[0122] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0123] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, 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. For example, multiple units or carriers can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0124] 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 distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0125] In addition, each functional unit in each embodiment 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 software functional units.

[0126] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for processing a data request for a cache database, characterized in that: include: Obtaining a data request, wherein the data request is used to request an operation to be performed on a cache database; dividing the plurality of commands corresponding to the data request into a plurality of categories of commands, wherein each of the plurality of commands belongs to one of the plurality of categories of commands; and Running the multiple types of commands in parallel; The multiple commands corresponding to the data request are divided into multiple categories of commands including: When the first thread receives the data request, the first thread sends the data request to the second thread in an idle state; The second thread parses the data request; In the case where the command obtained by parsing is a write command, the second thread sends the write command obtained by parsing to the command list of the first thread; and When the command obtained by parsing is a read command, the second thread saves the read command obtained by parsing as a command to be executed.

2. The method according to claim 1, characterized in that: Running the multiple types of commands in parallel includes: Each type of command among the multiple types of commands is run on one of the multiple carriers, wherein the carriers used for running any two types of commands among the multiple types of commands are different, and the multiple carriers are carriers that run in parallel.

3. The method according to claim 2, characterized in that Before running each of the plurality of classes of commands on one of the plurality of carriers, the method further comprises: creating a plurality of threads on a processor, wherein the plurality of carriers comprises the plurality of threads; Running each of the plurality of types of commands on one of the plurality of carriers includes: running each of the plurality of types of commands on one of the plurality of threads.

4. The method according to claim 3, characterized in that Running each of the plurality of types of commands on one of the plurality of threads comprises: Running a write command on a first thread, wherein the write command is used to instruct to write data in the cache database, the write command belongs to a first type of command among the multiple types of commands, and the multiple threads include the first thread; A read command is executed on a second thread, wherein the read command is used to instruct to read data from the cache database, the read command belongs to a second type of command among the multiple types of commands, and the multiple threads include the second thread.

5. The method according to claim 4, characterized in that Running the write commands on the first thread includes running each write command in the command list on the first thread as follows: The first thread obtains a target write command from the command list, wherein the command list is used to store all pending write commands, and the target write command is a currently pending write command in the command list; and The target write command is executed on the first thread.

6. The method according to claim 5, characterized in that In the process of running a write command on the first thread, the method further includes: After the first thread obtains the target write command from the command list, changing the state of the target write command from pending to being processed; If the first thread successfully executes the target write command, changing the state of the target write command from being processed to completed; and When the first thread fails to execute the target write command, the state of the target write command is changed from being processed to pending.

7. The method according to claim 6, characterized in that After changing the state of the target write command from being processed to pending, the method further includes: Recording the number of times the target write command fails to execute; and, When the number of times that the target write command fails to be repeatedly executed reaches a target threshold, the target write command is no longer repeatedly executed, and prompt information that the target write command fails to be executed is pushed.

8. The method according to claim 4, characterized in that Running a read command on the second thread involves: In the case that there are multiple read commands, the multiple read commands are executed on multiple second threads, wherein each second thread is used for executing at least one read command.

9. A device for processing data requests for a cache database, characterized in that: include: An acquisition unit, used for acquiring a data request, wherein the data request is used for requesting to operate a cache database; a dividing unit, configured to divide the plurality of commands corresponding to the data request into a plurality of categories of commands, wherein each of the plurality of commands belongs to one of the plurality of categories of commands; and An execution unit, configured to execute the plurality of types of commands in parallel; Partitioning units can also be used to: When the first thread receives the data request, the first thread sends the data request to the second thread in an idle state; The second thread parses the data request; In the case where the command obtained by parsing is a write command, the second thread sends the write command obtained by parsing to the command list of the first thread; and When the command obtained by parsing is a read command, the second thread saves the read command obtained by parsing as a command to be executed.

10. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 8 when executed.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor executes the method described in any one of claims 1 to 8 through the computer program.