WO2020238060A1 - 一种redis分片方法、装置、计算机设备和存储介质 - Google Patents
一种redis分片方法、装置、计算机设备和存储介质 Download PDFInfo
- Publication number
- WO2020238060A1 WO2020238060A1 PCT/CN2019/118231 CN2019118231W WO2020238060A1 WO 2020238060 A1 WO2020238060 A1 WO 2020238060A1 CN 2019118231 W CN2019118231 W CN 2019118231W WO 2020238060 A1 WO2020238060 A1 WO 2020238060A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- redis
- service
- unique code
- protocol agent
- value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2255—Hash tables
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2453—Query optimisation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2458—Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
- G06F16/2471—Distributed queries
Definitions
- This application relates to the technical field of fragmentation, and in particular to a REDIS fragmentation method, device, computer equipment, and storage medium.
- Redis cluster provides a way to automatically distribute data on multiple Redis nodes.
- Each database in the Redis cluster stores all the data in the cluster, so the total data storage capacity of the cluster is limited to the database node with the smallest available storage memory. This forms the barrel effect.
- Redis sharding is usually used, which is the process of splitting data into multiple Redis instances, so that each instance will only contain a subset of all keys.
- the inventor of the present application found that the prior art has the following problem: the existing sharding technology does not support multi-key operations. Transactions involving multiple keys cannot be used. Fragmentation granularity is the key. Data processing of large data blocks becomes more complicated, requiring storage after splitting, and operating data becomes complicated.
- a REDIS fragmentation method includes: receiving sent parameter values, verifying the parameter values to obtain a unique code; sending an operation request to a REDIS protocol agent;
- the REDIS protocol agent analyzes the unique code according to preset configuration parameters; according to the service agent obtained after the analysis, the REDIS protocol agent performs the corresponding REDIS service jump; the REDIS protocol agent selects a route according to the configuration, And access the REDIS service; the REDIS database receives the access and executes the access result, and returns the access result to the REDIS protocol agent; receives the return result sent by the REDIS protocol agent.
- a REDIS fragmentation device includes: a unique code obtaining unit, configured to receive a parameter value sent, and verify the parameter value to obtain a unique code; and send an operation request Unit, used to send an operation request to the REDIS protocol agent; a unique code analysis unit, used for the REDIS protocol agent to analyze the unique code according to preset configuration parameters; REDIS service jump unit, used to obtain according to the analysis Business agent, the REDIS protocol agent performs the jump of the corresponding REDIS service; REDIS service access unit, used for the REDIS protocol agent to select a route according to configuration, and access the REDIS service; access result return unit, for The REDIS database receives the access and executes the access result, and returns the access result to the REDIS protocol agent; the receiving unit is configured to receive the return result sent by the REDIS protocol agent.
- non-volatile readable storage medium storing computer readable instructions, which, when executed by one or more processors, cause one or more processors to execute The steps of the aforementioned REDIS fragmentation method.
- the foregoing REDIS fragmentation method, device, computer equipment and storage medium receive the sent parameter value and verify the parameter value to obtain a unique code including: receiving the sent parameter value and verifying the parameter value, Obtain the unique code; send an operation request to the REDIS protocol agent; the REDIS protocol agent parses the unique code according to the preset configuration parameters; according to the service agent obtained after the analysis, the REDIS protocol agent performs the corresponding REDIS service jump; REDIS protocol agent Select a route according to the configuration and access the REDIS service; REDIS database receives the access and executes the access result, and returns the access result to the REDIS protocol agent; receives the return result sent by the REDIS protocol agent. Therefore, when big data processing is required, a request is sent to the REDIS protocol agent.
- the REDIS protocol agent interprets the ID code according to the configuration, jumps to the designated correct node by the route, and then obtains the data result according to the hash value, and then passes the proxy After obtaining the operator, execute the multi-key operation in a loop and wait for the result state to be returned.
- This method greatly improves the balance of data storage through the hash technology of proxy assistance and query routing, and the data is more centralized and standardized, and the query speed of data in large clusters is improved.
- FIG. 1 is a diagram of an implementation environment of the REDIS fragmentation method provided in an embodiment
- Figure 2 is a block diagram of the internal structure of a computer device in an embodiment
- FIG. 3 is a flowchart of a REDIS fragmentation method in an embodiment
- Figure 4 is a flow chart of verifying parameter values to obtain a unique code in an embodiment
- Figure 5 is a flow chart of sending an operation request to the REDIS protocol agent in an embodiment
- FIG. 6 is a flowchart of receiving the return result sent by the REDIS protocol agent in an embodiment
- FIG. 7 is a flowchart of a REDIS fragmentation method in an embodiment
- FIG. 8 is a structural block diagram of REDIS fragmentation in an embodiment
- Fig. 9 is a structural block diagram of a unique code obtaining unit in an embodiment
- FIG. 10 is a structural block diagram of an operation request sending unit in an embodiment
- Figure 11 is a structural block diagram of a unique code parsing unit in an embodiment
- Fig. 12 is a structural block diagram of a receiving unit in an embodiment.
- FIG. 1 is a diagram of the implementation environment of the REDIS fragmentation method provided in an embodiment.
- the implementation environment includes a computer device 110 and a terminal 120.
- the computer device 110 is a client device, for example, a computer device such as a computer used by a user.
- An application system is installed on the computer device 110, and the input parameter value is received through the application system.
- the terminal 120 is installed with an application system that needs to perform REDIS service processing.
- REDIS fragmentation is required, the user can input parameter values in the computer device 110, and the computer device 110 receives the input parameter values and calibrates the parameter values. To obtain a unique code.
- the REDIS protocol agent on the terminal 120 parses the unique code according to the preset configuration parameters, and performs the corresponding REDIS service jump according to the service agent obtained after the analysis; then the REDIS protocol The agent selects a route according to the configuration to access the REDIS service, the REDIS database receives the access and executes the access result, returns the access result to the REDIS protocol agent, and finally sends the returned result to the computer device 110.
- the terminal 120 and the computer device 110 may be smart phones, tablet computers, notebook computers, desktop computers, etc., but are not limited thereto.
- the computer device 110 and the terminal 110 may be connected via Bluetooth, USB (Universal Serial Bus, Universal Serial Bus) or other communication connection methods, which is not limited in this application.
- FIG. 2 is a schematic diagram of the internal structure of a computer device in an embodiment.
- the computer device includes a processor, a non-volatile storage medium, a memory, and a network interface connected through a system bus.
- the non-volatile storage medium of the computer device stores an operating system, a database, and computer-readable instructions.
- the database may store control information sequences.
- the processor can realize a A REDIS fragmentation method.
- the processor of the computer equipment is used to provide calculation and control capabilities, and supports the operation of the entire computer equipment.
- a computer-readable instruction may be stored in the memory of the computer device, and when the computer-readable instruction is executed by the processor, the processor may execute a REDIS slicing method.
- the network interface of the computer device is used to connect and communicate with the terminal.
- FIG. 2 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
- the specific computer device may Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
- FIG. 3 in an embodiment, a REDIS fragmentation method is proposed.
- the REDIS fragmentation method can be applied to the above-mentioned computer device 110, and specifically may include the following steps:
- Step 302 Receive the sent parameter value and verify the parameter value to obtain a unique code; in this embodiment, after the computer device 110 receives the request, it needs to verify the parameter and generate a unique code.
- Step 304 Send an operation request to the REDIS protocol agent; in this embodiment of the application, the computer device 110 will establish the connection address of the agent to access it, such as the ORACLE database JDBC.
- Step 306 The REDIS protocol agent parses the unique code according to the preset configuration parameters; further, the REDIS protocol agent parses the unique code according to the preset configuration parameters including: obtaining the operation mode and the unique code in turn; according to the preset
- the configuration parameter intercepts the service type, and cyclically analyzes the composition of the unique code.
- the unique code is the Key value and ID code.
- the ID code is generated by the application according to the coding rules.
- customer information includes Zhang San, ID type, ID, family, etc., and you can use unique ID card for encoding.
- P001 is a customer information agent.
- ID proxy configuration + routing point service instance + hash value composition
- crc16 identity card number
- 91568mod 16384 5; the fifth hash slot partition.
- N+ number namely P001R1N5HASH91568.
- P001R0HASH0024936 P001 is obtained according to the proxy configuration method, R0 is the REDIS instance, HASH0024936 is the hash algorithm in the 002 partition, 4936 nodes.
- Step 308 According to the service agent obtained after the analysis, the REDIS protocol agent performs the jump of the corresponding REDIS service; in the embodiment of the present application, the REDIS protocol agent analyzes the requested service service, and then performs internal services according to the agent cluster connection Jump. For example, after P002 receives the request, and the unique code resolves the service type P001, the command operation and key-value value are redirected to the corresponding proxy service P001. For example, there are 3 agents and 5 different clusters. The application system will generate the key value of ID according to the rules.
- P001R1N5HASH9156 is generated by the splicing code; then, after the set(key, value) operation, the proxy server is called; then, the proxy P002 receives the information, intercepts the first 4 digits of the verification parameter P001, and then transfers to the P001 proxy On the above, if it is oneself, continue to execute the following; further, P001 service, intercept the first two R1, jump to the REDIS cluster according to the configuration information; finally, you can perform data access operations.
- the parameters of N and HASH are found in the R1 cluster and stored on the node5 node.
- the HASH value is used as the unique value of the cluster.
- P001 will determine which business series it is, and then jump to the corresponding business agent.
- the Redis storage method is in the form of key-value. Key is the primary key and value is the data type.
- a multi-key transaction is to operate multiple KEYs at the same time, and the data may be stored in different redis after fragmentation. For example, if you modify the value of 3 pieces of data, the values of key1, key2, and key3 are sliced and saved on different REDIS. When modifying, only key1 is found on the redis server, and key2 and key3 cannot be found, so it cannot be realized. And by adding the request transfer in the REDIS-PROXY agent, it will be distributed to different REDIS, and the result will be returned after all the requests are obtained.
- the REDIS protocol agent selects a route according to the configuration and accesses the REDIS service; further, the REDIS protocol agent judges whether there is a parameter value of the route in the unique code, and if so, access to the REDIS service is performed.
- the REDIS instance is obtained after the agent is the service agent corresponding to the request. If the route (R0) instance parameter is included in the unique code, the REDIS service request is performed.
- the REDIS protocol agent selecting a route according to configuration and accessing the REDIS service includes:
- Step 312 the REDIS database receives the access and executes the access result, and returns the access result to the REDIS protocol agent; in the embodiment of the present application, REDIS receives the access and executes the result, and returns the result to the agent service.
- the aforementioned query process includes a to 10000; jump to node2 and execute get a on node2.
- the Redis storage method is in the form of key-value.
- Key is the primary key, and value is the data type; a multi-key transaction is to operate multiple KEYs at the same time, and the data may be stored in different redis after fragmentation. For example, if you modify the value of 3 pieces of data, the values of key1, key2, and key3 are sliced and saved on different REDIS. When modifying, only key1 is found on the redis server, and key2 and key3 cannot be found, so it cannot be realized.
- Step 314 Receive the return result sent by the REDIS protocol agent.
- the proxy service returns the result into the LIST array, records the operation result, and waits for all the results.
- Fig. 4 shows a flowchart of the step of receiving the sent parameter value in step S302, and verifying the parameter value to obtain a unique code in an embodiment, which may specifically include the following steps:
- S406 Obtain the value of the corresponding target REDIS instance according to the code of the proxy service, and perform polling for the value;
- S408 Perform a hash algorithm calculation on the key value of the transferred parameter to generate a hash value
- the computer equipment 110 application system receives the parameters, judges the service type according to the input parameter values, and obtains the code of the proxy service, and performs polling according to the value of the source-end target REDIS instance corresponding to the proxy service code (load balancing REDIS service, Make the data evenly distributed), and perform the crc16 algorithm hash on the key value of the transferred parameter, and calculate the partition position of the hash slot according to the remainder of the hash value. Finally, it is assembled into a unique code in the system, and the unique code is used as the key value. Generate request proxy commands based on request operations.
- the operation method is set( ⁇ "name":"zhangsan” ⁇ , ⁇ "birthday”:"1985-01-01” ⁇ ), and the application gets the name parameter , It is judged that it is a customer information service, then the corresponding code service p001 code is obtained, and the REDIS service corresponding to R0, R1, R2, R3 under the P001 code.
- the application system polls to obtain the corresponding REDIS service (that is, after taking R0, take R1 , After R2, R3, R1 have been looping). Then finally it becomes set( ⁇ "P001R0N3HASH235544":"zhangsan" ⁇ , ⁇ "P001R0N3HASH235544":"1985-01-01” ⁇ ).
- Fig. 5 shows an implementation flow chart of the step of sending an operation request to the REDIS protocol agent in step S304 in an embodiment, which may specifically include the following steps:
- S504 Send the operation request through the connection address. After transcoding executes the operation command, the application client will establish a connection session of the agent according to the configured connection pool, and make a data sending request.
- Fig. 6 shows an implementation flow chart of the step S314 of receiving the return result sent by the REDIS protocol agent in an embodiment, which may specifically include the following steps:
- the REDIS protocol agent records the operation result and obtains all the operation results
- the proxy service returns the results into the LIST array, records the operation results, and waits for all results. Record the result as all successes to return the result. Otherwise, as long as there is a failure, the failure result will be returned.
- Redis-proxy proxy link distribution processing intercepting and obtaining operators (save, query, update, etc.), and then cyclically analyzing uniqueness based on internal multiple keys ( ⁇ key:value ⁇ , ⁇ key:value ⁇ ) Code composition, internally jump to the corresponding agent, and then find the REDIS connection pool according to the instance name, access the REDIS cluster, and wait for the operation result status to return.
- a REDIS slicing device may be integrated in the above-mentioned computer device 110, and may specifically include a unique code obtaining unit 802 and an operation request sending unit 804 , Unique code analysis unit 806, REDIS service jump unit 808, REDIS service access unit 810, access result return unit 812, and receiving unit 814.
- the unique code obtaining unit 802 is used to receive the sent parameter value and verify the parameter value to obtain the unique code; the operation request sending unit 804 is used to send the operation request to the REDIS protocol agent; the unique code analysis unit 806 is used to The REDIS protocol agent parses the unique code according to the preset configuration parameters; the REDIS service jump unit 808 is used to perform the jump of the corresponding REDIS service according to the service agent obtained after the analysis; the REDIS service access unit 810 uses The REDIS protocol agent selects a route according to the configuration and accesses the REDIS service; the access result returning unit 812 is used to receive the access to the REDIS database and execute the access result, and return the access result to the REDIS protocol agent; the receiving unit 814 is used to receive REDIS The return result sent by the protocol agent.
- the unique code obtained by the unique code obtaining unit 802 is composed of REDIS protocol proxy configuration, routing point service instance, and hash value.
- the unique code obtaining unit 802 includes: a service type judgment module 802A, a proxy service code obtaining module 802B, a REDIS instance value obtaining module 802C, a hash value generating module 802D, and a unique code assembling module 802E.
- the service type judgment module 802A is used to judge the service type according to the parameter value; the proxy service code obtaining module 802B is used to obtain the code of the proxy service according to the service type; the REDIS instance value obtaining module 802C is used to obtain the code according to the proxy service The service code obtains the value of the corresponding target REDIS instance, and performs polling to obtain the value; the hash value generation module 802D is used to calculate the hash algorithm for the key value of the transferred parameter to generate the hash value; the unique code assembly module 802E, used to take the remainder of the hash value to obtain the location of the hash slot partition, and then assemble to obtain a unique code.
- the operation request sending unit 804 includes: a connection address establishment module 804A and an operation request execution module 804B.
- the connection address establishment module 804A is used to establish a connection address with the REDIS protocol agent according to the configured connection pool; the operation request execution module 804B is used to send an operation request through the connection address.
- the unique code analysis unit 806 includes: an information acquisition module 806A and a loop analysis module 806B.
- the information acquisition module 806A is used to obtain the operation mode and the unique code in sequence; the cyclic analysis module 806B is used to intercept the service type according to the preset configuration parameters and cyclically analyze the composition of the unique code.
- the REDIS service access unit 810 includes: a parameter judgment module for judging whether the parameter value of the route exists in the unique code, and if it exists, the REDIS service access is performed.
- the receiving unit 814 includes: an operation result obtaining module 814A, a first execution module 814B, and a second execution module 814C.
- the operation result obtaining module 814A is used for the REDIS protocol agent to record the operation result and obtain all the operation results;
- the first execution module 814B is used for sending the return result when all the operation results meet the preset requirements;
- the second execution module 814C used to return a failure result when any of the operation results does not meet the preset requirements.
- a computer device includes a memory, a processor, and computer-readable instructions stored on the memory and running on the processor, and the processor executes all
- the computer-readable instruction implements the following steps: receiving the sent parameter value, and verifying the parameter value to obtain a unique code; sending an operation request to the REDIS protocol agent; the REDIS protocol agent checking all parameters according to preset configuration parameters The unique code is analyzed; according to the service agent obtained after the analysis, the REDIS protocol agent performs the jump of the corresponding REDIS service; the REDIS protocol agent selects a route according to the configuration and accesses the REDIS service; REDIS database receives Access and execute the access result, return the access result to the REDIS protocol agent; receive the return result sent by the REDIS protocol agent.
- the step of obtaining a unique code according to the parameter value received and sent by the processor and checking the parameter value includes: judging the service type according to the parameter value; The service type obtains the code of the proxy service; obtains the value of the corresponding target REDIS instance according to the code of the proxy service, and performs polling to obtain the value; performs a hash algorithm calculation on the key value of the transferred parameter to generate a hash value; After taking the remainder of the hash value and obtaining the location of the hash slot partition, it is assembled to obtain a unique code.
- the step of sending the operation request to the REDIS protocol agent performed by the processor includes: establishing a connection address with the REDIS protocol agent according to a configured connection pool; and using the connection address Send the operation request.
- the step of the REDIS protocol proxy executed by the processor to parse the unique code according to preset configuration parameters includes: sequentially obtaining the operation mode and the unique code; and according to the preset configuration The parameter intercepts the service type, and cyclically analyzes the composition of the unique code.
- the REDIS protocol proxy executed by the processor selects a route according to the configuration, and the step of accessing the REDIS service includes: judging whether there is a parameter value of the route in the unique code, if If it exists, the REDIS service access is performed.
- the unique code executed by the processor is composed of the REDIS protocol proxy configuration, a routing point service instance, and a hash value.
- the step of receiving the return result sent by the REDIS protocol agent performed by the processor includes: the REDIS protocol agent records the operation result and obtains all the operation results; when the operation results are all satisfied When a preset requirement is set, the return result is sent; when any one of the operation results does not meet the preset requirement, a failure result is returned.
- a storage medium storing computer-readable instructions is provided.
- the one or more processors When the computer-readable instructions are executed by one or more processors, the one or more processors perform the following steps: receiving sent parameters Value and verify the parameter value to obtain a unique code; send an operation request to the REDIS protocol agent; the REDIS protocol agent parses the unique code according to preset configuration parameters; according to the service agent obtained after the analysis, The REDIS protocol agent performs the jump of the corresponding REDIS service; the REDIS protocol agent selects a route according to the configuration, and accesses the REDIS service; the REDIS database receives the access and executes the access result, and returns the access result to all The REDIS protocol agent; receiving the return result sent by the REDIS protocol agent.
- the step of obtaining a unique code according to the parameter value received and sent by the processor and checking the parameter value includes: judging the service type according to the parameter value; The service type obtains the code of the proxy service; obtains the value of the corresponding target REDIS instance according to the code of the proxy service, and performs polling to obtain the value; performs a hash algorithm calculation on the key value of the transferred parameter to generate a hash value; After taking the remainder of the hash value and obtaining the location of the hash slot partition, it is assembled to obtain a unique code.
- the step of sending the operation request to the REDIS protocol agent performed by the processor includes: establishing a connection address with the REDIS protocol agent according to a configured connection pool; and using the connection address Send the operation request.
- the step of the REDIS protocol proxy executed by the processor to parse the unique code according to preset configuration parameters includes: sequentially obtaining the operation mode and the unique code; and according to the preset configuration The parameter intercepts the service type, and cyclically analyzes the composition of the unique code.
- the REDIS protocol proxy executed by the processor selects a route according to the configuration, and the step of accessing the REDIS service includes: judging whether there is a parameter value of the route in the unique code, if If it exists, the REDIS service access is performed.
- the unique code executed by the processor is composed of the REDIS protocol proxy configuration, a routing point service instance, and a hash value.
- the step of receiving the return result sent by the REDIS protocol agent performed by the processor includes: the REDIS protocol agent records the operation result and obtains all the operation results; when the operation results are all satisfied When a preset requirement is set, the return result is sent; when any one of the operation results does not meet the preset requirement, a failure result is returned.
- the computer-readable instructions can be stored in a non-volatile computer readable.
- the storage medium when the computer-readable instructions are executed, they may include the processes of the foregoing method embodiments.
- the aforementioned storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disc, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM), etc.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Fuzzy Systems (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Computer And Data Communications (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
一种REDIS分片方法、装置、计算机设备和存储介质,所述方法包括:接收发送的参数值,并对所述参数值进行校验,获得唯一码(S302);发送操作请求给REDIS协议代理(S304);所述REDIS协议代理根据预设配置参数对所述唯一码进行解析(S306);根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转(S308);所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问(S310);REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理(S312);接收所述REDIS协议代理发送的返回结果(S314)。上述方法可以改善数据存储的均衡,数据更集中规范,提高了大集群下数据的查询速度。
Description
本申请要求与2019年5月31日提交中国专利局、申请号为2019104704374、申请名称为“一种REDIS分片方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
本申请涉及分片技术领域,特别是涉及一种REDIS分片方法、装置、计算机设备和存储介质。
Redis集群提供一种方式自动将数据分布在多个Redis节点上,Redis集群的每个数据库都存储集群中的所有数据,那么集群的总数据存储量受限于可用存储内存最小的数据库节点,由此而形成木桶效应。
目前,在进行数据处理时,通常采用Redis分片,就是将数据拆分到多个Redis实例的过程,这样每个实例将只包含所有键的子集。然而,在对现有技术的研究与实践中,本申请的发明人发现,现有技术存在以下问题:现有的分片技术不支持多键的操作。涉及多个键的事务不能使用,分片粒度是键,大数据块的数据处理变得更复杂,需要拆分后存储,操作数据也变的复杂。
发明内容
基于此,有必要针对在进行REDIS分片时,现有的技术不支持多键的操作。涉及多个键的事务不能使用,大数据块的处理变得更复杂,需要拆分后存储,操作数据也变得复杂的问题,提供一种REDIS分片方法、装置、计算机设备和存储介质。
依据本申请一个方面,提供一种REDIS分片方法,所述REDIS分片方法包括:接收发送的参数值,并对所述参数值进行校验,获得唯一码;发送操作请求给REDIS协议代理;所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收所述REDIS协议代理发送的返回结果。
依据本申请另一个方面,提供一种REDIS分片装置,所述装置包括:唯一码获得单元,用于接收发送的参数值,并对所述参数值进行校验,获得唯一码;操作请求发送单元,用于发送操作请求给REDIS协议代理;唯一码解析单元,用于所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;REDIS服务跳转单元,用于根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;REDIS服务访问单元,用于所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;访问结果返回单元,用于REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收单元,用于接收所述REDIS协议代理发送的返回结果。
依据本申请又一个方面,提供一种存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述所述REDIS分片方法的步骤。
上述REDIS分片方法、装置、计算机设备和存储介质,通过接收发送的参数值,并对该参数值进行校验,获得唯一码包括:接收发送的参数值,并对该参数值进行校验,获得唯一码;发送操作请求给REDIS协议代理;该REDIS协议代理根据预设配置参数对唯一码进行解析;根据解析后获得的业务代理,REDIS协议代理进行对应的REDIS服务的跳转;REDIS协议代理根据配置选取路由,并对REDIS服务进行访问;REDIS数据库接收访问并执行访问结果,将访问结果返回给REDIS协议代理;接收REDIS协议代理发送的返回结果。因此,当需要进行大数据处理时,发送请求到REDIS协议代理上,REDIS协议代理根据配置解读ID编码,由路由跳转到指定的正确节点上,然后根据哈希值获取到数据结果,通过代理获取操作符后,对多键操作进行循环执行并等待返回结果状态。该方法通过代理协助和查询路由的哈希技术,极大的改善了数据存储的均衡,数据更集中规范,提高了大集群下数据的查询速度。
图1为一个实施例中提供的REDIS分片方法的实施环境图;
图2为一个实施例中计算机设备的内部结构框图;
图3为一个实施例中REDIS分片方法的流程图;
图4为一个实施例中对参数值进行校验,获得唯一码的流程图;
图5为一个实施例中发送操作请求给REDIS协议代理的流程图;
图6为一个实施例中接收REDIS协议代理发送的返回结果的流程图;
图7为一个实施例中REDIS分片方法的流程图;
图8为一个实施例中REDIS分片的结构框图;
图9为一个实施例中唯一码获得单元的结构框图;
图10为一个实施例中操作请求发送单元的结构框图;
图11为一个实施例中唯一码解析单元的结构框图;
图12为一个实施例中接收单元的结构框图。
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。
图1为一个实施例中提供的REDIS分片方法的实施环境图,如图1所示,在该实施环境中,包括计算机设备110以及终端120。计算机设备110为客户端设备,例如为用户使用的电脑等计算机设备,计算机设备110上安装有应用系统,通过该应用系统接收传入参数值。终端120上安装有需要进行REDIS服务处理的应用系统,当需要进行REDIS分片时,用户可以在计算机设备110输入参数值,计算机设备110接收该输入的参数值,并对所述参数值进行校验,获得唯一码。然后发送操作请求给REDIS协议代理,终端120上的REDIS协议代理根据预设配置参数对该唯一码进行解析,并根据解析后获得的业务代理,进行对应的REDIS服务的跳转;然后由REDIS协议代理根据配置选取路由,对REDIS服务进行访问,REDIS数据库接收访问并执行访问结果,将该访问结果返回给REDIS协议代理,最后即将返回结果发送给计算机设备110。需要说明的是,终端120以及计算机设备110可为智能手机、平板电脑、笔记本电脑、台式计算机等,但并不局限于此。计算机设备110以及终端110可以通过蓝牙、USB(Universal Serial Bus,通用串行总线)或者其他通讯连接方式进行连接,本申请在此不做限制。
图2为一个实施例中计算机设备的内部结构示意图。如图2所示,该计算机设备包括通过系统总线连接的处理器、非易失性存储介质、存储器和网络接口。其中,该计算机设备的非易失性存储介质存储有操作系统、数据库和计算机可读指令,数据库中可存储有控件信息序列,该计算机可读指令被处理器执行时,可使得处理器实现一种REDIS分片方法。该计算机设备的处理器用于提供计算和控制能力,支撑整个计算机设备的运行。该计算机设备的存储器中可存储有计算机可读指令,该计算机可读指令被处理器执行时,可使得处理器执行一种REDIS分片方法。该计算机设备的网络接口用于与终端连接通信。本领域技术人员可以理解,图2中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。如图3所示,在一个实施例中,提出了一种REDIS分片方法,该REDIS分片方法可以应用于上述的计算机设备110中,具体可以包括以下步骤:
步骤302,接收发送的参数值,并对参数值进行校验,获得唯一码;在本实施例中,计算机设备110接收请求后,需要对参数进行校验并产生一个唯一码。
步骤304,发送操作请求给REDIS协议代理;在本申请实施例中,计算机设备110会建立代理的连接地址,进行访问,如:ORACLE数据库JDBC一样。操作请求包括操作方法如,set保存,get获取等等,还包含key-value值。例如,当要保存一个人的姓名时,即为:name=zhangsan,即set(“name”,“zhangsan”)。
步骤306,REDIS协议代理根据预设配置参数对唯一码进行解析;进一步的,REDIS协议代理根据预设配置参数对唯一码进行解析包括:依次获得操作方式和所述唯一码;根据所述预设配置参数截取业务类型,循环解析所述唯一码的组成。在本申请实施例中,当REDIS协议代理接收请求后,会根据配置信息对该请求进行解析。例如:Config配置P001=R0,R0=redis库连接域名。唯一码也就是Key值、ID编码,ID编码是应用根据编码规则生成的,应用系统ID生成具体规则如下:例如,客户信息包括张三,证件类型,身份证,家庭等等,可以用唯一的身份证来进行编码。P001为客户信息代理。在客户信息集群R1上,ID=代理配置+路由点服务实例+哈希值组成,crc16(身份证号)=91568;HASH+哈希数字;91568mod 16384=5;第5个哈希槽分区。N+数字,即P001R1N5HASH91568。再比如P001R0HASH0024936,P001根据代理配 置获取方法,R0是REDIS实例,HASH0024936是哈希算法在002分区,4936节点。启动多个代理效果更佳。在代理中转的过程中,Redis-proxy代理链路分发处理,拦截获取操作符(save,query,update等),然后根据内部多键({key:value},{key:value}),循环解析唯一码的组成。
步骤308,根据解析后获得的业务代理,REDIS协议代理进行对应的REDIS服务的跳转;在本申请实施例中,REDIS协议代理解析出请求的业务服务后,会根据代理集群连接,进行内部服务的跳转。如P002接收到了请求,而唯一码解析出业务类型P001后,将命令操作和key-value值,跳转到相应代理服务P001上。例如代理有3台及5个不同的集群。应用系统会根据规则生成ID这个key值。如330123199008082314这个参数,通过拼接码生成P001R1N5HASH9156;然后,在set(key,value)操作后,调用代理服务器;接着,代理P002收到信息后,截取前4位校验参数P001,然后中转到P001代理上,如果是自己就继续执行后面的;进一步的,P001服务,截取前2位R1,根据配置信息跳转到REDIS集群上;最后,即可进行数据的存取操作。其中,在R1集群找到N与HASH的参数,在node5节点上存储。HASH值作为该集群的唯一值。例如,代理集群包括三个业务时,分别为业务一、业务二、业务三,其中的Config配置具体包括:P001=R0,R1;P002=R3,R4;P003=R2R0,R1,R2,R3,R4=redis库连接域名。以R1数据库业务为例,P001会判断是哪个业务系列的,然后跳转到对应的业务代理上。在一些申请实施例中,比如有3000条客户信息,需要保存到REDIS。如果保存到一台的话,发生故障后,就整体丢失了。所以在保存的时候,就进行拆分。Redis存储方式是key-value形式的。Key是主键,value是数据类型。多键事务是同时操作多个KEY,分片后数据可能存在不同的redis上。例如,修改3个数据的value值,key1,key2,key3的值分片后保存在不同的REDIS上,而修改的时候在redis服务器上只找到了key1,无法找到key2,key3,故无法实现。而通过在REDIS-PROXY代理中添加了请求中转,会分发到不同的REDIS上,获取全部请求后返回结果。
步骤310,REDIS协议代理根据配置选取路由,并对REDIS服务进行访问;进一步的,REDIS协议代理判断所述唯一码中是否存在所述路由的参数值,若存在,则进行REDIS服务访问。在本申请实施例中,该代理是请求所对应的业务代理后,获取根据REDIS实例,如果唯一码中有该路由(R0)实例参数,就进行REDIS服务请求。所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问包括:
步骤312,REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;在本申请实施例中,REDIS接收访问并执行结果,将结果返回代理服务。在集群搭建的时候,需要给集群节点,分配哈希槽,包括0-16383,即16383个分区;例如在node1执行set a时,具体的步骤为:第一步,使用crc16算法对key进行计算,得到一个数字,然后对这个数字进行求余16384,Crc16:a=26384,26384%16384=10000;第二步,查找包含1000插槽的节点,找到node2,自动跳转到node2;第三步,在node2上执行set a命令,最终可以在node3上执行get a。换句话说,前述的查询过程包括a至10000;跳转到node2以及在node2执行get a。进一步的,Redis存储方式是key-value形式的。Key是主键,value是数据类型;多键事务是同时操作多个KEY,分片后数据可能存在不同的redis上。例如,修改3个数据的value值,key1,key2,key3的值分片后保存在不同的REDIS上,而修改的时候在redis服务器上只找到了key1,无法找到key2,key3,故无法实现。而通过在REDIS-PROXY代理中添加了请求解析并中转,会分发到不同的REDIS上,获取全部请求后返回结果。例如:set({“P001R0N3HASH235544”:”zhangsan”}),redis执行set方法操作,并返回结果。
步骤314,接收REDIS协议代理发送的返回结果。在本申请实施例中,代理服务将结果返回放入LIST数组中,记录操作结果,等待所有结果。
图4示出了在一个实施例中,步骤S302即接收发送的参数值,并对所述参数值进行校验,获得唯一码步骤的实现流程图,具体可以包括以下步骤:
S402,根据所述参数值判断业务类型;
S404,根据所述业务类型获得代理服务的编码;
S406,根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;
S408,对转入参数的键值进行哈希算法计算,生成哈希值;
S410,将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。
计算机设备110应用系统接收参数,根据传入参数值,进行业务类型判断,得出代理服务的编码,根据代理服务编码对应的源端目标REDIS实例的值进行轮询取值(负载均衡REDIS服务,使数据均匀分布),并对转入参数的key值进行crc16算法哈希,根据哈希值取余算出哈希槽分区位置。最后进行拼装成系统中的唯一码,并用该唯一码作为key值。根据请求操作生成请求代理命令。例如,客户端想要发送“保 存人的信息的请求,则操作方法为set({“name”:”zhangsan”},{“birthday”:”1985-01-01”}),应用获取name参数,判断是客户信息业务,则获取对应代码服务p001编码,而P001编码下对应R0,R1,R2,R3的REDIS服务。应用系统则轮询获取对应的REDIS服务(即取完R0,则取R1,后R2,R3,R1一直循环)。则最终变成set({“P001R0N3HASH235544”:”zhangsan”},{“P001R0N3HASH235544”:”1985-01-01”})。
图5示出了一个实施例中,步骤S304即发送操作请求给REDIS协议代理的步骤的实现流程图,具体可以包括以下步骤:
S502,根据配置的连接池,建立与REDIS协议代理之间的连接地址;
S504,通过连接地址发送所述操作请求。在转码后执行操作命令,应用客户端会根据配置的连接池,建立代理的连接会话,进行数据发送请求。
图6示出了一个实施例中,步骤S314即接收REDIS协议代理发送的返回结果的步骤的实现流程图,具体可以包括以下步骤:
S602,REDIS协议代理记录操作结果,并获得所有的操作结果;
S604,当操作结果全部满足预设要求时,将返回结果进行发送;
S606,当操作结果中任一项不满足预设要求时,返回失败结果。
代理服务将结果返回放入LIST数组中,记录操作结果,等待所有结果。记录结果为全部成功才能返回结果。否则,只要出现失败,就返回失败结果。以图7为例,Redis-proxy代理链路分发处理,拦截获取操作符(save,query,update等),然后根据内部多键({key:value},{key:value}),循环解析唯一码的组成,内部跳转到相应代理上,然后根据实例名称找到REDIS连接池,访问REDIS集群,并等待操作结果状态返回。
如图8所示,在一个实施例中,提供了一种REDIS分片装置,该REDIS分片装置可以集成于上述的计算机设备110中,具体可以包括唯一码获得单元802、操作请求发送单元804、唯一码解析单元806、REDIS服务跳转单元808、REDIS服务访问单元810、访问结果返回单元812、接收单元814。唯一码获得单元802,用于接收发送的参数值,并对参数值进行校验,获得唯一码;操作请求发送单元804,用于发送操作请求给REDIS协议代理;唯一码解析单元806,用于REDIS协议代理根据预设配置参数对唯一码进行解析;REDIS服务跳转单元808,用于根据解析后获得的业务代理,REDIS协议代理进行对应的REDIS服务的跳转;REDIS服务访问单元810,用于REDIS协议代理根据配置选取路由,并对REDIS服务进行访问;访问结果返回单元812,用于REDIS数据库接收访问并执行访问结果,将访问结果返回给REDIS协议代理;接收单元814,用于接收REDIS协议代理发送的返回结果。
如图9所示,在一个实施例中,唯一码获得单元802获得的唯一码由REDIS协议代理配置、路由点服务实例和哈希值组成。唯一码获得单元802包括:业务类型判断模块802A、代理服务编码获得模块802B、REDIS实例值获得模块802C、哈希值生成模块802D、唯一码拼装模块802E。业务类型判断模块802A、用于根据所述参数值判断业务类型;代理服务编码获得模块802B,用于根据所述业务类型获得代理服务的编码;REDIS实例值获得模块802C,用于根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;哈希值生成模块802D,用于对转入参数的键值进行哈希算法计算,生成哈希值;唯一码拼装模块802E,用于将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。
如图10所示,在一个实施例中,操作请求发送单元804包括:连接地址建立模块804A和操作请求执行模块804B。连接地址建立模块804A,用于根据配置的连接池,建立与REDIS协议代理之间的连接地址;操作请求执行模块804B,用于通过连接地址发送操作请求。
如图11所示,在一个实施例中,唯一码解析单元806包括:信息获取模块806A和循环解析模块806B。
信息获取模块806A,用于依次获得操作方式和所述唯一码;循环解析模块806B,用于根据预设配置参数截取业务类型,循环解析唯一码的组成。在一个实施例中,REDIS服务访问单元810包括:参数判断模块,用于判断唯一码中是否存在所述路由的参数值,若存在,则进行REDIS服务访问。
如图12所示,在一个实施例中,接收单元814包括:操作结果获得模块814A、第一执行模块814B和第二执行模块814C。操作结果获得模块814A,用于REDIS协议代理记录操作结果,并获得所有的操作结果;第一执行模块814B,用于当操作结果全部满足预设要求时,将返回结果进行发送;第二执行模块814C,用于当操作结果中任一项不满足预设要求时,返回失败结果。
在一个实施例中,提出了一种计算机设备,所述计算机设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现以下步骤:接 收发送的参数值,并对所述参数值进行校验,获得唯一码;发送操作请求给REDIS协议代理;所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收所述REDIS协议代理发送的返回结果。在一个实施例中,所述处理器所执行的根据所述接收发送的参数值,并对所述参数值进行校验,获得唯一码的步骤包括:根据所述参数值判断业务类型;根据所述业务类型获得代理服务的编码;根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;对转入参数的键值进行哈希算法计算,生成哈希值;将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。在一个实施例中,所述处理器所执行的所述发送操作请求给REDIS协议代理的步骤包括:根据配置的连接池,建立与所述REDIS协议代理之间的连接地址;通过所述连接地址发送所述操作请求。在一个实施例中,所述处理器所执行的所述REDIS协议代理根据预设配置参数对所述唯一码进行解析的步骤包括:依次获得操作方式和所述唯一码;根据所述预设配置参数截取业务类型,循环解析所述唯一码的组成。在一个实施例中,所述处理器所执行的所REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问的步骤包括:判断所述唯一码中是否存在所述路由的参数值,若存在,则进行REDIS服务访问。在一个实施例中,所述处理器所执行的所述唯一码由所述REDIS协议代理配置、路由点服务实例和哈希值组成。
在一个实施例中,所述处理器所执行的接收所述REDIS协议代理发送的返回结果的步骤包括:所述REDIS协议代理记录操作结果,并获得所有的操作结果;当所述操作结果全部满足预设要求时,将所述返回结果进行发送;当所述操作结果中任一项不满足所述预设要求时,返回失败结果。在一个实施例中,提出了一种存储有计算机可读指令的存储介质,该计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:接收发送的参数值,并对所述参数值进行校验,获得唯一码;发送操作请求给REDIS协议代理;所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收所述REDIS协议代理发送的返回结果。在一个实施例中,所述处理器所执行的根据所述接收发送的参数值,并对所述参数值进行校验,获得唯一码的步骤包括:根据所述参数值判断业务类型;根据所述业务类型获得代理服务的编码;根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;对转入参数的键值进行哈希算法计算,生成哈希值;将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。在一个实施例中,所述处理器所执行的所述发送操作请求给REDIS协议代理的步骤包括:根据配置的连接池,建立与所述REDIS协议代理之间的连接地址;通过所述连接地址发送所述操作请求。在一个实施例中,所述处理器所执行的所述REDIS协议代理根据预设配置参数对所述唯一码进行解析的步骤包括:依次获得操作方式和所述唯一码;根据所述预设配置参数截取业务类型,循环解析所述唯一码的组成。在一个实施例中,所述处理器所执行的所REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问的步骤包括:判断所述唯一码中是否存在所述路由的参数值,若存在,则进行REDIS服务访问。在一个实施例中,所述处理器所执行的所述唯一码由所述REDIS协议代理配置、路由点服务实例和哈希值组成。在一个实施例中,所述处理器所执行的接收所述REDIS协议代理发送的返回结果的步骤包括:所述REDIS协议代理记录操作结果,并获得所有的操作结果;当所述操作结果全部满足预设要求时,将所述返回结果进行发送;当所述操作结果中任一项不满足所述预设要求时,返回失败结果。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,该计算机可读指令可存储于一计算机非易失性可读存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,前述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等非易失性存储介质,或随机存储记忆体(Random Access Memory,RAM)等。
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。
Claims (20)
- 一种REDIS分片方法,所述方法包括:接收发送的参数值,并对所述参数值进行校验,获得唯一码;发送操作请求给REDIS协议代理;所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收所述REDIS协议代理发送的返回结果。
- 根据权利要求1所述的方法,所述接收发送的参数值,并对所述参数值进行校验,获得唯一码包括:根据所述参数值判断业务类型;根据所述业务类型获得代理服务的编码;根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;对转入参数的键值进行哈希算法计算,生成哈希值;将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。
- 根据权利要求1所述的方法,所述发送操作请求给REDIS协议代理包括:根据配置的连接池,建立与所述REDIS协议代理之间的连接地址;通过所述连接地址发送所述操作请求。
- 根据权利要求1所述的方法,所述REDIS协议代理根据预设配置参数对所述唯一码进行解析包括:依次获得操作方式和所述唯一码;根据所述预设配置参数截取业务类型,循环解析所述唯一码的组成。
- 根据权利要求1所述的方法,所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问包括:判断所述唯一码中是否存在所述路由的参数值,若存在,则进行REDIS服务访问。
- 根据权利要求1所述的方法,所述唯一码由所述REDIS协议代理配置、路由点服务实例和哈希值组成。
- 根据权利要求1所述的方法,所述接收所述REDIS协议代理发送的返回结果包括:所述REDIS协议代理记录操作结果,并获得所有的操作结果;当所述操作结果全部满足预设要求时,将所述返回结果进行发送;当所述操作结果中任一项不满足所述预设要求时,返回失败结果。
- 一种REDIS分片装置,所述装置包括:唯一码获得单元,用于接收发送的参数值,并对所述参数值进行校验,获得唯一码;操作请求发送单元,用于发送操作请求给REDIS协议代理;唯一码解析单元,用于所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;REDIS服务跳转单元,用于根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;REDIS服务访问单元,用于所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;访问结果返回单元,用于REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收单元,用于接收所述REDIS协议代理发送的返回结果。
- 根据权利要求8所述的装置,所述唯一码获得单元包括:业务类型判断模块,用于根据所述参数值判断业务类型;代理服务编码获得模块,用于根据所述业务类型获得代理服务的编码;REDIS实例值获得模块,用于根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;哈希值生成模块,用于对转入参数的键值进行哈希算法计算,生成哈希值;唯一码拼装模块,用于将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。
- 根据权利要求8所述的装置,所述操作请求发送单元包括:连接地址建立模块,用于根据配置的连接池,建立与所述REDIS协议代理之间的连接地址;操作请求执行模块,用于通过所述连接地址发送所述操作请求。
- 根据权利要求8所述的装置,所述唯一码解析单元包括:信息获取模块,用于依次获得操作方式和所述唯一码;循环解析模块,用于根据所述预设配置参数截取业务类型,循环解析所述唯一码的组成。
- 根据权利要求8所述的装置,所述REDIS服务访问单元包括:参数判断模块,用于判断所述唯一码中是否存在所述路由的参数值,若存在,则进行REDIS服务访问。
- 根据权利要求8所述的装置,所述唯一码获得单元获得的所述唯一码由所述REDIS协议代理配置、路由点服务实例和哈希值组成。
- 根据权利要求8所述的装置,所述接收单元包括:操作结果获得模块,用于所述REDIS协议代理记录操作结果,并获得所有的操作结果;第一执行模块,用于当所述操作结果全部满足预设要求时,将所述返回结果进行发送;第二执行模块,用于当所述操作结果中任一项不满足所述预设要求时,返回失败结果。
- 一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述处理器执行所述计算机可读指令时实现REDIS分片方法,包括:接收发送的参数值,并对所述参数值进行校验,获得唯一码;发送操作请求给REDIS协议代理;所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收所述REDIS协议代理发送的返回结果。
- 根据权利要求15所述的计算机设备,所述处理器执行所述计算机可读指令时实现所述接收发送的参数值,并对所述参数值进行校验,获得唯一码包括:根据所述参数值判断业务类型;根据所述业务类型获得代理服务的编码;根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;对转入参数的键值进行哈希算法计算,生成哈希值;将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。
- 根据权利要求15所述的计算机设备,所述处理器执行所述计算机可读指令时实现所述发送操作请求给REDIS协议代理包括:根据配置的连接池,建立与所述REDIS协议代理之间的连接地址;通过所述连接地址发送所述操作请求。
- 一种非易失性可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现REDIS分片方法,包括:接收发送的参数值,并对所述参数值进行校验,获得唯一码;发送操作请求给REDIS协议代理;所述REDIS协议代理根据预设配置参数对所述唯一码进行解析;根据解析后获得的业务代理,所述REDIS协议代理进行对应的REDIS服务的跳转;所述REDIS协议代理根据配置选取路由,并对所述REDIS服务进行访问;REDIS数据库接收访问并执行访问结果,将所述访问结果返回给所述REDIS协议代理;接收所述REDIS协议代理发送的返回结果。
- 根据权利要求18所述的存储介质,所述计算机可读指令被处理器执行时实现所述接收发送的参数值,并对所述参数值进行校验,获得唯一码包括:根据所述参数值判断业务类型;根据所述业务类型获得代理服务的编码;根据所述代理服务的编码获得对应的目标REDIS实例的值,并进行轮询取值;对转入参数的键值进行哈希算法计算,生成哈希值;将所述哈希值进行取余,获得哈希槽分区的位置后,进行拼装获得唯一码。
- 根据权利要求18所述的存储介质,所述计算机可读指令被处理器执行时实现所述发送操作请求给REDIS协议代理包括:根据配置的连接池,建立与所述REDIS协议代理之间的连接地址;通过所述连接地址发送所述操作请求。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910470437.4A CN110347718B (zh) | 2019-05-31 | 2019-05-31 | 一种redis分片方法、装置、计算机设备和存储介质 |
| CN201910470437.4 | 2019-05-31 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020238060A1 true WO2020238060A1 (zh) | 2020-12-03 |
Family
ID=68174546
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/118231 Ceased WO2020238060A1 (zh) | 2019-05-31 | 2019-11-13 | 一种redis分片方法、装置、计算机设备和存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110347718B (zh) |
| WO (1) | WO2020238060A1 (zh) |
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113742352A (zh) * | 2021-09-17 | 2021-12-03 | 中国银行股份有限公司 | 一种数据处理方法、装置、电子设备及存储介质 |
| CN115842862A (zh) * | 2022-12-23 | 2023-03-24 | 福建天晴数码有限公司 | 一种代理网关超时转发的方法及系统 |
| CN116126910A (zh) * | 2022-12-27 | 2023-05-16 | 上海天旦网络科技发展有限公司 | 海量会话数据滚动聚合方法、系统、设备及介质 |
| CN116737812A (zh) * | 2023-05-30 | 2023-09-12 | 北京米可世界科技有限公司 | Redis访问处理方法、装置、电子设备及计算机可读存储介质 |
| CN118349400A (zh) * | 2024-06-17 | 2024-07-16 | 杭州宇信数字科技有限公司 | 一种用于Java应用的Redis连接池的创建方法、装置和存储介质 |
| CN118377435A (zh) * | 2024-06-24 | 2024-07-23 | 杭州宇信数字科技有限公司 | 一种基于终端代理的集群扩缩容方法、装置、介质和设备 |
| CN118784937A (zh) * | 2024-09-11 | 2024-10-15 | 海看网络科技(山东)股份有限公司 | 快速分片续传超大图片的方法、系统、装置及存储介质 |
| WO2025081619A1 (zh) * | 2023-10-19 | 2025-04-24 | 天翼电子商务有限公司 | 访问请求处理方法、装置及电子设备 |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110347718B (zh) * | 2019-05-31 | 2023-12-15 | 平安科技(深圳)有限公司 | 一种redis分片方法、装置、计算机设备和存储介质 |
| CN112351096B (zh) * | 2020-11-04 | 2023-03-24 | 福建天泉教育科技有限公司 | 一种大数据场景下消息处理的方法及终端 |
| CN117857627A (zh) * | 2023-12-12 | 2024-04-09 | 天翼云科技有限公司 | 一种分布式缓存发布订阅的方法、系统和装置 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105357296A (zh) * | 2015-10-30 | 2016-02-24 | 河海大学 | 一种Docker云平台下弹性缓存系统 |
| US20160062900A1 (en) * | 2014-08-29 | 2016-03-03 | International Business Machines Corporation | Cache management for map-reduce applications |
| CN106055698A (zh) * | 2016-06-14 | 2016-10-26 | 智者四海(北京)技术有限公司 | 数据迁移方法、代理节点及数据库实例 |
| CN108183961A (zh) * | 2018-01-04 | 2018-06-19 | 中电福富信息科技有限公司 | 一种基于Redis的分布式缓存方法 |
| CN110347718A (zh) * | 2019-05-31 | 2019-10-18 | 平安科技(深圳)有限公司 | 一种redis分片方法、装置、计算机设备和存储介质 |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105138501B (zh) * | 2015-08-10 | 2018-04-03 | 北京思特奇信息技术股份有限公司 | 一种可配置的动态报表生成方法及系统 |
| US10262012B2 (en) * | 2015-08-26 | 2019-04-16 | Oracle International Corporation | Techniques related to binary encoding of hierarchical data objects to support efficient path navigation of the hierarchical data objects |
| CN105159985A (zh) * | 2015-08-31 | 2015-12-16 | 努比亚技术有限公司 | 基于redis集群的数据查询装置及方法 |
| CN106682004A (zh) * | 2015-11-06 | 2017-05-17 | 网宿科技股份有限公司 | 一种Redis Key管理方法及系统 |
| US10592482B2 (en) * | 2015-12-29 | 2020-03-17 | Cognizant Technology Solutions India Pvt. Ltd. | Method and system for identifying and analyzing hidden data relationships in databases |
| US10305861B2 (en) * | 2016-08-29 | 2019-05-28 | Microsoft Technology Licensing, Llc. | Cross-tenant data leakage isolation |
| CN109769028A (zh) * | 2019-01-25 | 2019-05-17 | 深圳前海微众银行股份有限公司 | Redis集群管理方法、装置、设备及可读存储介质 |
-
2019
- 2019-05-31 CN CN201910470437.4A patent/CN110347718B/zh active Active
- 2019-11-13 WO PCT/CN2019/118231 patent/WO2020238060A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20160062900A1 (en) * | 2014-08-29 | 2016-03-03 | International Business Machines Corporation | Cache management for map-reduce applications |
| CN105357296A (zh) * | 2015-10-30 | 2016-02-24 | 河海大学 | 一种Docker云平台下弹性缓存系统 |
| CN106055698A (zh) * | 2016-06-14 | 2016-10-26 | 智者四海(北京)技术有限公司 | 数据迁移方法、代理节点及数据库实例 |
| CN108183961A (zh) * | 2018-01-04 | 2018-06-19 | 中电福富信息科技有限公司 | 一种基于Redis的分布式缓存方法 |
| CN110347718A (zh) * | 2019-05-31 | 2019-10-18 | 平安科技(深圳)有限公司 | 一种redis分片方法、装置、计算机设备和存储介质 |
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113742352A (zh) * | 2021-09-17 | 2021-12-03 | 中国银行股份有限公司 | 一种数据处理方法、装置、电子设备及存储介质 |
| CN115842862A (zh) * | 2022-12-23 | 2023-03-24 | 福建天晴数码有限公司 | 一种代理网关超时转发的方法及系统 |
| CN116126910A (zh) * | 2022-12-27 | 2023-05-16 | 上海天旦网络科技发展有限公司 | 海量会话数据滚动聚合方法、系统、设备及介质 |
| CN116737812A (zh) * | 2023-05-30 | 2023-09-12 | 北京米可世界科技有限公司 | Redis访问处理方法、装置、电子设备及计算机可读存储介质 |
| WO2025081619A1 (zh) * | 2023-10-19 | 2025-04-24 | 天翼电子商务有限公司 | 访问请求处理方法、装置及电子设备 |
| CN118349400A (zh) * | 2024-06-17 | 2024-07-16 | 杭州宇信数字科技有限公司 | 一种用于Java应用的Redis连接池的创建方法、装置和存储介质 |
| CN118377435A (zh) * | 2024-06-24 | 2024-07-23 | 杭州宇信数字科技有限公司 | 一种基于终端代理的集群扩缩容方法、装置、介质和设备 |
| CN118784937A (zh) * | 2024-09-11 | 2024-10-15 | 海看网络科技(山东)股份有限公司 | 快速分片续传超大图片的方法、系统、装置及存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110347718B (zh) | 2023-12-15 |
| CN110347718A (zh) | 2019-10-18 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020238060A1 (zh) | 一种redis分片方法、装置、计算机设备和存储介质 | |
| JP7304442B2 (ja) | クラウドベースの認証、承認、及びユーザ管理サービスの発見及びマッピング | |
| US12124344B2 (en) | Systems and methods for enabling a highly available managed failover service | |
| US10931774B2 (en) | Discovery and service mapping of application programming interface proxies | |
| US10740355B2 (en) | System and method for optimizing data migration in a partitioned database | |
| US11366728B2 (en) | Systems and methods for enabling a highly available managed failover service | |
| US8495013B2 (en) | Distributed storage system and method for storing objects based on locations | |
| US20240248810A1 (en) | Systems and methods for cross-regional back up of distributed databases on a cloud service | |
| US20180293257A1 (en) | Method for accessing distributed database and distributed data service apparatus | |
| US11341005B2 (en) | Systems and methods for enabling a highly available managed failover service | |
| US11546307B2 (en) | Method to implement multi-tenant/shared Redis cluster using envoy | |
| US20210334409A1 (en) | Integrity verification in cloud key-value stores | |
| US10481963B1 (en) | Load-balancing for achieving transaction fault tolerance | |
| US11048547B2 (en) | Method and system for routing and executing transactions | |
| US20240356762A1 (en) | Database tenant-level move | |
| US12034712B2 (en) | Communication between server systems in different network regions | |
| CN117978809A (zh) | 网关节点推荐方法、装置、计算机设备和存储介质 | |
| JP2024010659A (ja) | コマンド検証による迅速なエラー検出 | |
| US20250365169A1 (en) | Systems and methods for load-balanced chaincode execution and verification in a blockchain network | |
| US12445445B1 (en) | Resource protection for a microservice-based application | |
| CN119484609B (zh) | 会话管理方法、装置、计算机设备和可读存储介质 | |
| KR100970207B1 (ko) | 이동 통신 서비스의 인증 시스템 및 그 인증 방법 | |
| CN121255354A (zh) | 一种基于OpenStack的跨可用区迁移虚拟机的方法及系统 | |
| Hang | A Study over Registration Server System Simulation | |
| CN120011433A (zh) | 数据库调度方法、装置、设备、存储介质和程序产品 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19930555 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19930555 Country of ref document: EP Kind code of ref document: A1 |