Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to run the 'multi' command? #112

Open
LazyHippogriff opened this issue Apr 15, 2019 · 1 comment
Open

how to run the 'multi' command? #112

LazyHippogriff opened this issue Apr 15, 2019 · 1 comment

Comments

@LazyHippogriff
Copy link

I want to implement atomic execution of a bunch of statements for which I need to execute the 'multi' command. However, I'm getting error. Given below is my program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<unistd.h>
#include <hircluster.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main(int argc, char **argv) {
struct timeval timeout = { 1, 500000 }; // 1.5 seconds
redisClusterContext *cc = redisClusterContextInit();
redisClusterSetOptionAddNodes(cc, "172.16.129.68:6380");
redisClusterSetOptionConnectTimeout(cc, timeout);
redisClusterSetOptionRouteUseSlots(cc);
redisClusterSetOptionParseSlaves(cc);

redisClusterConnect2(cc);
if (cc != NULL && cc->err) {
  printf("Error: %s\n", cc->errstr);
  // handle error
  exit(-1);
}

redisReply *reply;
reply = (redisReply*)(redisClusterCommand(cc,"MULTI"));
if (cc != NULL && cc->err)
printf("\n[%s::%d]Error: %s\n",__FILE__,__LINE__,cc->errstr);
else
printf("MULTI RESPONSE: %s\n", reply->str);
freeReplyObject(reply);
redisClusterFree(cc);
return 0;
}

Output

[cluster-example.c::52]Error: Parse command error. Cmd type: 0, state: 5, break position: 13.

@GooglerLi
Copy link

redis cluster 不支持事务的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants