redisGetReply(_connect, (void **)&reply); if (reply) { // 这里的逻辑写的依然有问题 freeReplyObject(reply); } else { log_debug("expire set failed ret type:%d value:%lld", reply->type, reply->integer); } return RedisSuccess; }
错误原因:注意第 7 行和第 8 行,此处添加了两条指令 hset 和 expire,但是由于机器内存不足,dump 不成功,redisGetReply 会请求 hset 的返回出错,错误信息为: “MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.”,UpdateHash 从 14 行错误返回。
/* Try to read pending replies */ if (redisGetReplyFromReader(c,&aux) == REDIS_ERR) return REDIS_ERR;
/* For the blocking context, flush output buffer and read reply */ if (aux == NULL && c->flags & REDIS_BLOCK) { /* Write until done */ do { if (redisBufferWrite(c,&wdone) == REDIS_ERR) return REDIS_ERR; } while (!wdone);
/* Read until there is a reply */ do { if (redisBufferRead(c) == REDIS_ERR) return REDIS_ERR; if (redisGetReplyFromReader(c,&aux) == REDIS_ERR) return REDIS_ERR; } while (aux == NULL); }
/* Set reply object */ if (reply != NULL) *reply = aux; return REDIS_OK; }
typedefstructredisContext { int err; /* Error flags, 0 when there is no error */ char errstr[128]; /* String representation of error when applicable */ int fd; int flags; char *obuf; /* Write buffer */ redisReader *reader; /* Protocol reader */ } redisContext;
#!/bin/bash for i in {1..3000} do echo"" > /tmp/test.txt for j in {1..100} do cat /proc/sys/kernel/random/uuid >> /tmp/test.txt done s=$(cat /tmp/test.txt) echo$s redis-cli -p 6379 -n 15 set test5_$i"$s" done