Database access method and device

By introducing network protocol layer proxy before Redis, using asynchronous threading model and connection pooling, and combining multiple Redis requests into Pineline batch requests, the problem of performance degradation in Redis under concurrent access and TLS encryption is solved, and the performance improvement is achieved by more than 1 times.

CN119884255APending Publication Date: 2025-04-25CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411761758.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

Redis has significantly reduced performance when handling large amounts of concurrent access and using TLS encrypted transmissions. How to improve the efficiency of Redis in handling concurrent access is an urgent issue.

Method used

A network protocol-level proxy process is introduced before the Redis service, and async threading model, connection pool and multiple Redis requests are merged into a Pineline batch request method to handle concurrent database access requests.

Benefits of technology

Under the premise of being fully compatible with the Redis ecosystem, the efficiency of Redis processing concurrent access is improved, and the service performance of Redis is increased by more than 1 times in specific scenarios, solving some obvious performance bottlenecks in Redis, and broadening the usage scenarios and product value of Redis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119884255A_ABST
    Figure CN119884255A_ABST
Patent Text Reader

Abstract

The invention provides a database access method and device. The method comprises the following steps: receiving concurrent database access requests sent by a plurality of terminals; merging the concurrent database access requests sent by the plurality of terminals to generate a merged access request; according to the method, a database is accessed according to a merged access request, an agent process of a network protocol level is introduced before Redis service, and modes of an asynchronous thread model, a connection pool, merging of a plurality of Redis requests into a Pineline batch request and the like are adopted, so that the efficiency of processing concurrent access by Redis is improved, and on the premise of being completely compatible with Redis ecology, the efficiency of processing concurrent access by Redis is improved. The service performance of the Redis can be improved by more than one time in a specific scene, some obvious performance bottleneck problems of the Redis are solved, and the use scene and the product value of the Redis are widened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a database access method and device. Background Art

[0002] Redis (Remote Dictionary Server) is a low-latency, highly available NoSQL (Not Only SQL) database, which is widely adopted by many enterprise developers and cloud vendors for its simple use, high performance, and mature ecosystem. The Redis core has only one thread to process data calculations. When faced with a large number of connections and requests, and when using TLS (Transport Layer Security) for encrypted transmission, there will be a significant performance degradation problem. How to improve the efficiency of Redis in handling concurrent access is an urgent problem to be solved. Summary of the invention

[0003] The present application shows a database access method and device.

[0004] In a first aspect, the present application provides a database access method, the method comprising:

[0005] Receive concurrent database access requests sent by multiple terminals;

[0006] Merging the concurrent database access requests sent by the multiple terminals to generate a merged access request;

[0007] The database is accessed according to the combined access request.

[0008] Optionally, the receiving concurrent database access requests sent by multiple terminals includes:

[0009] An asynchronous single-threaded model is used to receive concurrent database access requests sent by multiple terminals.

[0010] Optionally, merging the concurrent database access requests sent by the multiple terminals to generate a merged access request includes:

[0011] Parsing the database access request according to the Redis protocol to obtain the data type of the database access request;

[0012] According to the data type, storing the database access request in a corresponding data list, wherein the data list at least includes a request list and a sending list;

[0013] The database access requests in each data list are merged to generate a merged access request.

[0014] Optionally, accessing the database according to the combined access request includes:

[0015] After the working thread completes cyclic processing of the database access requests in the data list, determining whether there is a write task or a read task;

[0016] In the absence of a write task or a read task, the database access request in the data list is written into the input / output interface at one time.

[0017] Optionally, the method further comprises:

[0018] Each database access request is distributed to a different node of the database.

[0019] In a second aspect, the present application provides a database access device, the device comprising:

[0020] A receiving module, used for receiving concurrent database access requests sent by multiple terminals;

[0021] A merging module, used to merge the concurrent database access requests sent by the multiple terminals to generate a merged access request;

[0022] The access module is used to access the database according to the combined access request.

[0023] Optionally, the receiving module is used to:

[0024] An asynchronous single-threaded model is used to receive concurrent database access requests sent by multiple terminals.

[0025] Optionally, the merging module is used to:

[0026] Parsing the database access request according to the Redis protocol to obtain the data type of the database access request;

[0027] According to the data type, storing the database access request in a corresponding data list, wherein the data list at least includes a request list and a sending list;

[0028] The database access requests in each data list are merged to generate a merged access request.

[0029] Optionally, the access module is used to:

[0030] After the working thread completes cyclic processing of the database access requests in the data list, determining whether there is a write task or a read task;

[0031] In the absence of a write task or a read task, the database access request in the data list is written into the input / output interface at one time.

[0032] Optionally, the access module is used to:

[0033] Each database access request is assigned to a different node of the database. In a third aspect, the present application shows an electronic device, the electronic device comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to execute the method as described in any of the above aspects.

[0034] In a fourth aspect, the present application illustrates a non-temporary computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a method as described in any of the above aspects.

[0035] In a fifth aspect, the present application illustrates a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in any of the above aspects.

[0036] The technical solution provided by the present application may include the following beneficial effects: an embodiment of the present application provides a database access method, including receiving concurrent database access requests sent by multiple terminals; merging the concurrent database access requests sent by the multiple terminals to generate a merged access request; accessing the database according to the merged access request, introducing a proxy process at the network protocol level before the Redis service, adopting an asynchronous thread model, connection pool, merging multiple Redis requests into a batch request of a Pineline pipeline, etc., thereby improving the efficiency of Redis in handling concurrent access. On the premise of being fully compatible with the Redis ecosystem, the service performance of Redis can be improved by more than 1 times in specific scenarios, solving some obvious performance bottleneck problems of Redis and broadening the usage scenarios and product value of Redis. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a flowchart of the steps of a database access method of the present application;

[0038] Figure 2 This is a database access architecture diagram of this application;

[0039] Figure 3 It is a thread processing flow diagram of this application;

[0040] Figure 4 This is a schematic diagram of a decoder design of this application;

[0041] Figure 5 This is a flowchart of a Decoder finite state machine of this application;

[0042] Figure 6 This is a thread-level connection pool diagram of this application;

[0043] Figure 7 This is a flowchart of merging multiple requests into one Pineline request and sending it to Redis.

[0044] Figure 8 It is a structural block diagram of a database access device of the present application;

[0045] Fig. 9 is a block diagram of an electronic device of the present application;

[0046] Fig.10 It is a block diagram of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

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

[0048] Reference Figure 1 , shows a flowchart of a database access method of the present application, which can be applied to an electronic device, wherein the method specifically may include the following steps:

[0049] S101, receiving concurrent database access requests sent by multiple terminals;

[0050] S102, merging concurrent database access requests sent by multiple terminals to generate a merged access request;

[0051] S103: Access the database according to the merged access request.

[0052] In the embodiment of the present application, a proxy process at the network protocol level is introduced in front of the Redis service, and an asynchronous thread model, connection pool, and multiple Redis requests are merged into a Pineline batch request. That is, concurrent database access requests sent by multiple terminals are merged to generate a merged access request. According to the merged access request, the database is accessed. Under the premise of being fully compatible with the Redis ecosystem, the service performance of Redis can be improved by more than 1 times in specific scenarios, which solves some obvious performance bottleneck problems of Redis and broadens the use scenarios and product value of Redis.

[0053] Among them, Redis is an open source log-type, Key-Value database written in ANSI C language, supporting the network, memory-based and persistent, and providing API protocols in multiple languages.

[0054] Redis is a key-value (a database that stores data in key-value pairs) storage system. Similar to Memcached (a distributed high-speed cache system), it supports relatively more value types for storage, including string, list, set, zset (sorted set), and hash. These data types support push / pop, add / remove, intersection, union, difference, and richer operations, and these operations are atomic. On this basis, Redis supports various different sorting methods. Like Memcached, in order to ensure efficiency, data is cached in memory. The difference is that Redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master-slave synchronization is implemented.

[0055] The emergence of Redis has largely compensated for the shortcomings of key / value storage such as memcached, and can play a good supplement to relational databases in some occasions. It provides clients such as Java, C / C++, C#, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang, etc., which are very convenient to use. Redis supports master-slave synchronization. Data can be synchronized from the master server to any number of slave servers, and the slave server can be the master server associated with other slave servers. This allows Redis to perform single-layer tree replication. Data can be written intentionally or unintentionally when saving to disk. Since the publish / subscribe mechanism is fully implemented, when the slave database synchronizes the tree anywhere, it can subscribe to a channel and receive the complete message publishing record of the master server. Synchronization is very helpful for the scalability of read operations and data redundancy.

[0056] The embodiment of the present application introduces a proxy node of the network protocol layer in front of Redis, and fully utilizes the Pipeline high-performance mechanism of Redis while being fully compatible with the network protocol and all commands of Redis. While reducing the number of Redis connections, it also greatly improves the overall throughput of Redis.

[0057] The embodiment of the present application provides a database access method, including receiving concurrent database access requests sent by multiple terminals; merging the concurrent database access requests sent by the multiple terminals to generate a merged access request; accessing the database according to the merged access request, introducing a proxy process at the network protocol level before the Redis service, adopting an asynchronous thread model, a connection pool, merging multiple Redis requests into a Pineline batch request, etc., thereby improving the efficiency of Redis in handling concurrent access. Under the premise of being fully compatible with the Redis ecosystem, the service performance of Redis can be improved by more than 1 times in specific scenarios, solving some obvious performance bottleneck problems of Redis and broadening the use scenarios and product value of Redis.

[0058] In one embodiment of the present application, receiving concurrent database access requests sent by multiple terminals includes:

[0059] An asynchronous single-threaded model is used to receive concurrent database access requests sent by multiple terminals.

[0060] In another embodiment of the present application, concurrent database access requests sent by multiple terminals are merged to generate a merged access request, including:

[0061] According to the Redis protocol, the database access request is parsed to obtain the data type of the database access request;

[0062] According to the data type, the database access request is stored in a corresponding data list, wherein the data list at least includes a request list and a sending list;

[0063] The database access requests in each data list are merged to generate a merged access request.

[0064] Specifically, according to the merged access request, the database is accessed, including:

[0065] After the worker thread completes the loop processing of the database access requests in the data list, it determines whether there is a write task or a read task;

[0066] In the absence of a write task or a read task, the database access requests in the data list are written into the input and output interface at one time.

[0067] The method further includes:

[0068] Distribute each database access request to a different database node.

[0069] Specifically, a connection pool corresponds to a group of Redis, including 1 master node and zero or more backup Redis node information, and each node has zero or more connections. Generally speaking, the combination of a node and a db value corresponds to a connection. For write requests, they are all sent to the connection of the master node; for read requests, you can choose to send them to the master node or the backup node for execution according to the configuration.

[0070] like Figure 7 As shown, the embodiment of the present application provides a database access method, including:

[0071] 1. As Figure 2 As shown, a database access architecture diagram is provided, which can maintain a local Redis configuration information and load it into the memory for subsequent connection pool establishment;

[0072] 2. Create N worker threads according to the configuration and maintain them in an array, such as Figure 3 shown.

[0073] 3. Implement an Acceptor function to listen to a specific network port. When a new connection comes, assign the new connection to a certain work thread in a polling manner and create a corresponding connection object.

[0074] The main function of Acceptor is to receive the client's connection request and establish a connection. Specifically, Acceptor receives the client's connection request through the listen socket. When a new connection request arrives, Acceptor calls the registered callback function to process these requests, thereby establishing a new connection.

[0075] 4. The worker thread receives the assigned connection handle and loads the epoll event listener.

[0076] Among them, epoll is an efficient I / O event notification mechanism in the Linux kernel for handling a large number of concurrent connections. It is an enhanced version of select and poll, designed for handling a large number of file descriptors, especially in high-concurrency processing applications, such as network servers and distributed systems; epoll performs asynchronous event-driven I / O operations by listening to events on file descriptors. It has two working modes: level triggering (LT) and edge triggering (ET), of which edge triggering is the default working mode. In LT mode, the kernel will continue to notify whether the file descriptor is ready, and if it is not processed, it will continue to notify; in ET mode, the kernel only notifies once.

[0077] 5. When epoll listens to several connection handle read events at a time, it starts a loop execution: reading network messages into memory and calling the processing method of the corresponding connection object.

[0078] 6. As Figure 4 and Figure 5 As shown in the figure, the Redis protocol interpreter Frontend Decoder based on the finite state machine is implemented to interpret the content of the message: the decoder maintains a message stack and a network message cache list. According to the Redis protocol, different data types are interpreted. When encountering a composite data type, it is interpreted in combination with the message stack. If a complete message can be interpreted, it is sent to the subsequent steps. Otherwise, the partial message content interpreted this time is cached and the current interpretation state is saved. When reading new data next time, it continues to interpret from the last interpretation, and finally merges all the previous data into a complete message.

[0079] Among them, FrontEnd (computer front end) is responsible for receiving signal input and converting it into a feature sequence, while Decoder uses the feature sequence generated by FrontEnd to perform actual decoding work and finally produce recognition results.

[0080] Decoder (efficient interpreter) is a network protocol interpreter based on finite state machine and stack, which supports the unpacking and sticking of network messages and is responsible for the actual decoding work using the feature sequence generated by FrontEnd.

[0081] 7. After receiving the message, the connection object first uses Frontend Decoder to interpret a complete request message. Then, according to the first parameter of the request message, it finds the corresponding command and uses the rest as the command parameters. According to the login information corresponding to the connection, it verifies the user's command authority. If the verification is successful, it executes the command. Otherwise, it returns an error message to the client.

[0082] 8. As Figure 6 As shown, command execution is processed based on different command rules and implementation methods, mainly including the following methods:

[0083] 1) For unknown commands that are not supported, an error message is directly returned.

[0084] 2) For configured dangerous commands, error messages are also returned.

[0085] 3) For some common commands that do not involve actual data, such as PING requests, the correct message is directly returned. The PING command is a network diagnostic tool that is mainly used to detect network connectivity. By sending an ICMP (Internet Control Message Protocol) echo request data packet to the target host and waiting for its response, the network connection status can be determined. The PING command can be used to detect whether the local network settings are correct, including IP address, subnet mask, default gateway, etc. Through the PING command, the user can check whether the IP address of the machine is set incorrectly and whether the connection between the machine and the local network is normal.

[0086] ICMP (Internet Control Message Protocol) is a sub-protocol of the TCP / IP protocol family, mainly used to transmit control messages between IP hosts and routers. These control messages include information such as whether the network is connected, whether the host is reachable, and whether the route is available. Although they do not transmit user data, they play an important role in the transmission of user data.

[0087] 4) For commands involving Redis data, select the connection corresponding to the Redis connection pool and directly send the received message.

[0088] 9. Implementation of Redis connection pool: A connection pool corresponds to a group of Redis, including 1 master node and zero or more backup Redis node information, and each node has zero or more connections. Generally speaking, the combination of a node and a db value corresponds to a connection. For write requests, they are all sent to the connection of the master node; for read requests, you can choose to send them to the master node or the backup node for execution according to the configuration.

[0089] 10. There is a request list and a sending list inside the Redis connection. Every time a request is sent to Redis, it is not sent directly to Redis's network IO, but is first added to the request list and the sending list, and is added to the write task list of the current working thread with idempotence.

[0090] 11. After the current working thread has processed all readable requests in a loop, check whether there are any write tasks, and write all the current write requests of the Redis connection to the network IO in batches at once.

[0091] 12.epoll joins the network event monitoring of Redis connection.

[0092] 13. Implement the second streamlined Redis protocol interpreter backend decoder based on the finite state machine, which does not cache some messages but sends them directly to the subsequent callback function for processing.

[0093] 14. After epoll listens to the Redis connection read event, it reads the data into the memory and uses the backend decoder to interpret the message. It calls the response function of the first request in the request list. If the message is complete, it deletes the first request in the request list.

[0094] 15. The request reply function writes the response result message back to the client.

[0095] The embodiment of the present application is aimed at high-concurrency scenarios. The ready events of a single epoll read all corresponding requests, merge the messages of these Redis requests into a large message, and finally write it only once to the corresponding Redis connection. The number of IO system calls is reduced, and the Pineline scenario for Redis is also the performance sweet spot of Redis, which can enable Redis to achieve higher performance. Because it is based on the merger of a single epoll cycle, it does not bring more request processing delays.

[0096] Use a connection pool that is not shared by threads. While maintaining high performance, it reduces the number of Redis connections.

[0097] High-performance multi-threaded processing model. IO asynchronous processing method: Network IO is asynchronous, 100% non-blocking. A single thread can support multiple connections concurrently, and connection binding threads: both the client's front-end connection and the back-end Redis connection are bound to specific threads. All calculations do not involve multi-threaded processing, and there are no locks, blocking waits, or synchronization operations. The overall performance scales almost linearly with the number of threads.

[0098] Introduce a proxy process at the network protocol level in front of the Redis service, adopt an asynchronous thread model, connection pool, merge multiple Redis requests into a Pineline batch request, etc., to improve the service performance of Redis while being fully compatible with the Redis ecosystem.

[0099] In the present application embodiment:

[0100] 1. High performance, more than double the performance of direct connection to Redis. Especially in scenarios with high concurrency of multiple connections and encrypted transmission (TLS);

[0101] 2. Strong scalability, and the read-write separation function or Redis cluster proxy can be expanded later;

[0102] 3. Strong ecological compatibility, fully compatible with the Redis network protocol, and can be seamlessly connected to any existing client;

[0103] 4. Deploy in SideCar mode, with the proxy and Redis deployed on the same machine to minimize network forwarding overhead;

[0104] Among them, Sidecar is a technical model that is mainly used in service governance and microservice architecture. It provides additional functional support by attaching one or more services next to the application. This model is similar to the sidecar next to a motorcycle. The sidecar model achieves the purpose of separation of control and logic by adding a "sidecar" to the application service. Sidecar can be used to implement functions such as log collection, service registration, service discovery, current limiting, and authentication.

[0105] 5. Adopt an efficient thread model with low resource overhead.

[0106] The embodiment of the present application provides a database access method, including receiving concurrent database access requests sent by multiple terminals; merging the concurrent database access requests sent by the multiple terminals to generate a merged access request; accessing the database according to the merged access request, introducing a proxy process at the network protocol level before the Redis service, adopting an asynchronous thread model, a connection pool, merging multiple Redis requests into a Pineline batch request, etc., thereby improving the efficiency of Redis in handling concurrent access. Under the premise of being fully compatible with the Redis ecosystem, the service performance of Redis can be improved by more than 1 times in specific scenarios, solving some obvious performance bottleneck problems of Redis and broadening the use scenarios and product value of Redis.

[0107] It should be noted that, for the 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 order of the actions described, 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 optional embodiments, and the actions involved are not necessarily required by the present application.

[0108] Reference Figure 8 , shows a structural block diagram of a database access device of the present application, the device includes: a receiving module 901, a merging module 902 and an access module 903, wherein:

[0109] The receiving module 901 is used to receive concurrent database access requests sent by multiple terminals;

[0110] The merging module 902 is used to merge concurrent database access requests sent by multiple terminals to generate a merged access request;

[0111] The access module 903 is used to access the database according to the combined access request.

[0112] The embodiment of the present application provides a database access device, including receiving concurrent database access requests sent by multiple terminals; merging concurrent database access requests sent by multiple terminals to generate a merged access request; accessing the database according to the merged access request, introducing a proxy process at the network protocol level before the Redis service, adopting an asynchronous thread model, connection pool, merging multiple Redis requests into a Pineline batch request, etc., to improve the efficiency of Redis in handling concurrent access, and under the premise of being fully compatible with the Redis ecosystem, the service performance of Redis can be improved by more than 1 times in specific scenarios, solving some obvious performance bottleneck problems of Redis and broadening the use scenarios and product value of Redis. Optionally, the receiving module is used to:

[0113] An asynchronous single-threaded model is used to receive concurrent database access requests sent by multiple terminals.

[0114] In one embodiment of the present application, the merging module is used to:

[0115] According to the Redis protocol, the database access request is parsed to obtain the data type of the database access request;

[0116] According to the data type, the database access request is stored in a corresponding data list, wherein the data list at least includes a request list and a sending list;

[0117] The database access requests in each data list are merged to generate a merged access request.

[0118] In yet another embodiment of the present application, the access module is used to:

[0119] After the worker thread completes the loop processing of the database access requests in the data list, it determines whether there is a write task or a read task;

[0120] In the absence of a write task or a read task, the database access requests in the data list are written into the input and output interface at one time.

[0121] In yet another embodiment of the present application, the access module is used to:

[0122] Each database access request is distributed to different nodes of the database. As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0123] An embodiment of the present application provides a database access device, including receiving concurrent database access requests sent by multiple terminals; merging the concurrent database access requests sent by the multiple terminals to generate a merged access request; accessing the database according to the merged access request, introducing a proxy process at the network protocol level before the Redis service, adopting an asynchronous thread model, a connection pool, merging multiple Redis requests into a Pineline batch request, etc., thereby improving the efficiency of Redis in processing concurrent access. Under the premise of being fully compatible with the Redis ecosystem, the service performance of Redis can be improved by more than 1 times in specific scenarios, solving some obvious performance bottleneck problems of Redis and broadening the use scenarios and product value of Redis.

[0124] Optionally, an embodiment of the present application further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0125] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0126] FIG9 is a block diagram of an electronic device 800 shown in the present application. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0127] Reference Fig. 9 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0128] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0129] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, images, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0130] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.

[0131] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0132] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0133] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0134] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0135] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast operation information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0136] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0137] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0138] Fig.10 19 is a block diagram of a computer-readable storage medium 1900 shown in the present application. For example, the computer-readable storage medium 1900 may be provided as a server.

[0139] Reference Fig.10 , the computer-readable storage medium 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions, such as an application, that can be executed by the processing component 1922. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.

[0140] The computer readable storage medium 1900 may also include a power supply component 1926 configured to perform power management of the computer readable storage medium 1900, a wired or wireless network interface 1950 configured to connect the computer readable storage medium 1900 to a network, and an input / output (I / O) interface 1958. The computer readable storage medium 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.

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

[0142] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods 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 such an 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, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0143] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

[0144] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0145] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0146] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, 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 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 devices or units, which can be electrical, mechanical or other forms.

[0147] 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.

[0148] 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.

[0149] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a 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 the 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 a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps 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 USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.

[0150] 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 database access method, characterized in that: The method comprises: Receive concurrent database access requests sent by multiple terminals; Merging the concurrent database access requests sent by the multiple terminals to generate a merged access request; The database is accessed according to the combined access request.

2. The database access method according to claim 1, characterized in that: The receiving concurrent database access requests sent by multiple terminals includes: An asynchronous single-threaded model is used to receive concurrent database access requests sent by multiple terminals.

3. The database access method according to claim 1, characterized in that: The step of merging the concurrent database access requests sent by the multiple terminals to generate a merged access request includes: Parsing the database access request according to the Redis protocol to obtain the data type of the database access request; According to the data type, storing the database access request in a corresponding data list, wherein the data list at least includes a request list and a sending list; The database access requests in each data list are merged to generate a merged access request.

4. The database access method according to claim 3, characterized in that: The accessing the database according to the combined access request includes: After the working thread completes cyclic processing of the database access requests in the data list, determining whether there is a write task or a read task; In the absence of a write task or a read task, the database access request in the data list is written into the input / output interface at one time.

5. The database access method according to claim 2, characterized in that: The method further comprises: Each database access request is distributed to a different node of the database.

6. A database access device, characterized in that: The device comprises: A receiving module, used for receiving concurrent database access requests sent by multiple terminals; A merging module, used to merge the concurrent database access requests sent by the multiple terminals to generate a merged access request; The access module is used to access the database according to the combined access request.

7. The database access device according to claim 6, characterized in that: The receiving module is used for: An asynchronous single-threaded model is used to receive concurrent database access requests sent by multiple terminals.

8. The database access device according to claim 6, characterized in that: The merging module is used to: Parsing the database access request according to the Redis protocol to obtain the data type of the database access request; According to the data type, storing the database access request in a corresponding data list, wherein the data list at least includes a request list and a sending list; The database access requests in each data list are merged to generate a merged access request.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method according to any one of claims 1 to 6 when executed by the processor.

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