文档首页 > > 移植指南> 移植Hiredis> 移植指导

移植指导

分享
更新时间:2020/08/31 GMT+08:00

介绍

简要介绍

Hiredis是Redis数据库的C接口库。

语言:C/C++

一句话描述:Redis的C接口库

建议的版本

建议使用版本为“hiredis-0.14.0”

环境要求

云服务器要求

本文以云服务器KC1实例测试,云服务器配置如表1所示。

表1 云服务器配置

项目

说明

规格

kc1.xlarge.2 | 4vCPUs | 8GB

磁盘

系统盘:高IO(40GB)

操作系统要求

操作系统要求如表2所示。

表2 操作系统要求

项目

版本

下载地址

EulerOS 2.8

2.8

在公共镜像中已提供。

Kernel

4.19.36

在公共镜像中已提供。

获取源码

执行以下命令,获取Hiredis软件包。

wget https://github.com/redis/hiredis/archive/v0.14.0.tar.gz

编译和安装

  1. 解压软件包。

    tar -zxvf v0.14.0.tar.gz

  2. 进入“hiredis-0.14.0”目录。

    cd hiredis-0.14.0

  3. 编译Hiredis源码。

    make -j4

    make install

运行和验证

测试之前,确保环境正常运行Redis服务。

“hiredis-0.14.0”目录里面,执行以下命令,测试接口可用性。

./hiredis-test

系统回显如下,则接口正常:

#01 Format command without interpolation: PASSED
#02 Format command with %s string interpolation: PASSED
#03 Format command with %s and an empty string: PASSED
#04 Format command with an empty string in between proper interpolations: PASSED
#05 Format command with %b string interpolation: PASSED
#06 Format command with %b and an empty string: PASSED
#07 Format command with literal %: PASSED
#08 Format command with printf-delegation (int): PASSED
#09 Format command with printf-delegation (char): PASSED
#10 Format command with printf-delegation (short): PASSED
#11 Format command with printf-delegation (long): PASSED
#12 Format command with printf-delegation (long long): PASSED
#13 Format command with printf-delegation (unsigned int): PASSED
#14 Format command with printf-delegation (unsigned char): PASSED
#15 Format command with printf-delegation (unsigned short): PASSED
#16 Format command with printf-delegation (unsigned long): PASSED
#17 Format command with printf-delegation (unsigned long long): PASSED
#18 Format command with printf-delegation (float): PASSED
#19 Format command with printf-delegation (double): PASSED
#20 Format command with invalid printf format: PASSED
#21 Format command by passing argc/argv without lengths: PASSED
#22 Format command by passing argc/argv with lengths: PASSED
#23 Format command into sds by passing argc/argv without lengths: PASSED
#24 Format command into sds by passing argc/argv with lengths: PASSED
#25 Error handling in reply parser: PASSED
#26 Memory cleanup in reply parser: PASSED
#27 Set error on nested multi bulks with depth > 7: PASSED
#28 Correctly parses LLONG_MAX: PASSED
#29 Set error when > LLONG_MAX: PASSED
#30 Correctly parses LLONG_MIN: PASSED
#31 Set error when < LLONG_MIN: PASSED
#32 Set error when array < -1: PASSED
#33 Set error when bulk < -1: PASSED
#34 Set error when array > INT_MAX: PASSED
#35 Works with NULL functions for reply: PASSED
#36 Works when a single newline (\r\n) covers two calls to feed: PASSED
#37 Don't reset state after protocol error: PASSED
#38 Don't do empty allocation for empty multi bulk: PASSED
#39 Returns error when host cannot be resolved: PASSED
#40 Returns error when the port is not open: PASSED
#41 Returns error when the unix_sock socket path doesn't accept connections: PASSED
#42 Don't fail when redisFree is passed a NULL value: PASSED
#43 Don't fail when freeReplyObject is passed a NULL value: PASSED

Testing against TCP connection (127.0.0.1:6379):
#44 Is able to deliver commands: PASSED
#45 Is a able to send commands verbatim: PASSED
#46 %s String interpolation works: PASSED
#47 %b String interpolation works: PASSED
#48 Binary reply length is correct: PASSED
#49 Can parse nil replies: PASSED
#50 Can parse integer replies: PASSED
#51 Can parse multi bulk replies: PASSED
#52 Can handle nested multi bulk replies: PASSED
#53 Successfully completes a command when the timeout is not exceeded: PASSED
#54 Does not return a reply when the command times out: PASSED
#55 Reconnect properly reconnects after a timeout: PASSED
#56 Reconnect properly uses owned parameters: PASSED
#57 Returns I/O error when the connection is lost: PASSED
#58 Returns I/O error on socket timeout: PASSED
#59 Set error when an invalid timeout usec value is given to redisConnectWithTimeout: PASSED
#60 Set error when an invalid timeout sec value is given to redisConnectWithTimeout: PASSED
#61 Append format command: PASSED
#62 Throughput:
(1000x PING: 0.042s)
(1000x LRANGE with 500 elements: 0.192s)
(1000x INCRBY: 0.045s)
(10000x PING (pipelined): 0.020s)
(10000x LRANGE with 500 elements (pipelined): 1.984s)
(10000x INCRBY (pipelined): 0.059s)

Testing against Unix socket connection (/tmp/redis.sock):
#63 Is able to deliver commands: PASSED
#64 Is a able to send commands verbatim: PASSED
#65 %s String interpolation works: PASSED
#66 %b String interpolation works: PASSED
#67 Binary reply length is correct: PASSED
#68 Can parse nil replies: PASSED
#69 Can parse integer replies: PASSED
#70 Can parse multi bulk replies: PASSED
#71 Can handle nested multi bulk replies: PASSED
#72 Successfully completes a command when the timeout is not exceeded: PASSED
#73 Does not return a reply when the command times out: PASSED
#74 Reconnect properly reconnects after a timeout: PASSED
#75 Reconnect properly uses owned parameters: PASSED
#76 Returns I/O error when the connection is lost: PASSED
#77 Returns I/O error on socket timeout: PASSED
#78 Throughput:
(1000x PING: 0.035s)
(1000x LRANGE with 500 elements: 0.181s)
(1000x INCRBY: 0.038s)
(10000x PING (pipelined): 0.019s)
(10000x LRANGE with 500 elements (pipelined): 2.020s)
(10000x INCRBY (pipelined): 0.074s)

Testing against inherited fd (/tmp/redis.sock):
Connecting to inherited fd 3
#79 Is able to deliver commands: PASSED
#80 Is a able to send commands verbatim: PASSED
#81 %s String interpolation works: PASSED
#82 %b String interpolation works: PASSED
#83 Binary reply length is correct: PASSED
#84 Can parse nil replies: PASSED
#85 Can parse integer replies: PASSED
#86 Can parse multi bulk replies: PASSED
#87 Can handle nested multi bulk replies: PASSED
ALL TESTS PASSED
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!非常感谢您的反馈,我们会继续努力做到更好!
反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问