- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Kali Linux 2019.4 上使用以下命令安装了 Redis 服务器:
$ redisurl="http://download.redis.io/redis-stable.tar.gz"
$ curl -s -o redis-stable.tar.gz $redisurl
$ sudo su root
$ mkdir -p /usr/local/lib/
$ chmod a+w /usr/local/lib/
$ tar -C /usr/local/lib/ -xzf redis-stable.tar.gz
$ rm redis-stable.tar.gz
$ cd /usr/local/lib/redis-stable/
$ make && make install
然后在redis-cli
上,当我输入PING时,它会回复PONG
但是当我使用下面的 C 代码和 hiredis
时,它会回复 null
。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hiredis/hiredis.h>
redisContext *c;
redisReply *reply;
void main() {
c = redisConnect("127.0.0.1", 6379);
reply = redisCommand(c,"PING");
printf("PING: %s \n", reply->str);
}
输出:PING:(空)
有人可以帮我吗?
最佳答案
首先,您是否在正确的端口上将 Redis 作为后台服务运行?
我认为如果你想从新事物开始,最好从那些已经测试过的例子开始。而且,如果您再次遇到错误,可能您的 Redis Upstart 还没有真正完成。
请仔细查看以下链接并多加注意这些示例:
https://github.com/redis/hiredis
https://github.com/redis/hiredis/tree/master/examples
希望对您有所帮助。
关于c - hiredis 命令对简单 C 代码的空回复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59254106/
我正在开发一个简单的应用程序,它使用 Redis 的官方 C 客户端hiredis 的异步方面。作为第一步,我尝试编译the github repo 中的示例程序。 .我正在使用在 Ubuntu 20
我正在使用hiredis C library连接到我的 redis 实例。我正在考虑更改我的 redis.conf 以启用 requirepass 选项。我知道对于 redisConnect() 我只
我正在尝试使用 hiredis 编写连接池。我面临的问题是,如果用户触发命令但没有从连接读取响应,我应该在放入连接池之前清除该连接的响应。 有没有办法检查: 是否有更多数据要读取?所以我可以做 red
我正在使用 hiredis C client library在异步上下文中与 Redis 交互。 在我的工作流程的某些点上,我必须对 Redis 进行同步调用,但我无法从 Redis 获得成功响应。
我正在尝试在断开连接时重新连接到 Redis 服务器。 我正在使用 redisAsyncConnect 并且我已经设置了断开连接时的回调。在回调中,我尝试使用在程序开始时使用的相同命令重新连接以建立连
我正在使用 hiredis C 库连接到 redis 服务器。我不知道如何在订阅新消息后等待新消息。 我的代码如下: signal(SIGPIPE, SIG_IGN ); struct event
我正在为 Varnish 使用一个名为 libvmod-redis 的 redis 集成插件.我遇到一个问题,如果我收到大量并发请求(大约 350 个),redis 就会开始超时,最终我会在 Varn
我是 redis 新手。我想编写一个位于hiredis顶层的简单库(用于测试)。例如,为了实现 SET 命令,我编写了以下代码: #include #include #include #include
我正在尝试使用 hiredis 将结构SET 放入 Redis: struct StatLite { uid_t uid; gid_t gid; mode_t mode; }
我正在尝试在 CentOS 上以 C 运行 hiredis。 下面的代码似乎运行良好: ... const char *hostname = "my.redis-as-a-service.com";
我将 HiRedis 与 c/c++ 程序一起使用,并编写了一些测试来验证订阅是否有效(我的解决方案基于 this comment)。 但是,目前我只能通过在 redis-cli 终端中手动输入类似
reply = redisCommand(rcontext,"HGET %u %u",env->cr[3] ,KeyHandle); if(reply == NULL) { printf("in pr
如何使用 hiredis API 断开与 redis 服务器的连接?有 API 可以连接,但我找不到关闭连接的函数?redisFree 会自动执行此操作吗? 最佳答案 redisFree() 确实会关
我在多线程环境中使用 Redis,对它的运行方式有疑问。我在我的 c++ 应用程序中使用 hiredis c 库。 我的问题是:如果我在触发回调时使用异步模式,是否会在 Redis 客户端创建的另一个
我在 Kali Linux 2019.4 上使用以下命令安装了 Redis 服务器: $ redisurl="http://download.redis.io/redis-stable.tar.gz"
我想用 C 编译 redis 的客户端。我已经下载并安装了 libevent 库和 hiredis 文件。我用过这个命令: gcc -I/home/tasos/Dropbox/lists/hiredi
考虑以下示例: #include #include #include #include int main(int argc, char **argv) { redisContext *re
我有以下在 C 中使用 Redis 的代码。以 hiredis 为基础。 #include #include #include #include int main(int argc, char
我安装了redis服务器,可以从命令行使用它。现在,我想使用 hiredis 编写一个客户端程序。首先,我尝试编译 hiredis 目录中的 example.c: vishal@expmach:~/r
我正在尝试将一个多词字符串推送到一个 Redis 键但是每个词都被添加为一个新元素我怎样才能避免这种情况 #include #include #include #include int m
我是一名优秀的程序员,十分优秀!