MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / main

Function main

deps/hiredis/examples/example-libevent.c:40–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40int main (int argc, char **argv) {
41#ifndef _WIN32
42 signal(SIGPIPE, SIG_IGN);
43#endif
44
45 struct event_base *base = event_base_new();
46 redisOptions options = {0};
47 REDIS_OPTIONS_SET_TCP(&options, "127.0.0.1", 6379);
48 struct timeval tv = {0};
49 tv.tv_sec = 1;
50 options.connect_timeout = &tv;
51
52
53 redisAsyncContext *c = redisAsyncConnectWithOptions(&options);
54 if (c->err) {
55 /* Let *c leak for now... */
56 printf("Error: %s\n", c->errstr);
57 return 1;
58 }
59
60 redisLibeventAttach(c,base);
61 redisAsyncSetConnectCallback(c,connectCallback);
62 redisAsyncSetDisconnectCallback(c,disconnectCallback);
63 redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
64 redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
65 event_base_dispatch(base);
66 return 0;
67}

Callers

nothing calls this directly

Calls 5

redisLibeventAttachFunction · 0.85
redisAsyncCommandFunction · 0.85

Tested by

no test coverage detected