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

hmset in Batch_write gives error #10

Open
saroj13278 opened this issue Mar 1, 2012 · 2 comments
Open

hmset in Batch_write gives error #10

saroj13278 opened this issue Mar 1, 2012 · 2 comments

Comments

@saroj13278
Copy link

Hi ,
Am writing a C -application which used to write data to redis.So basically the command is hmset input_list:0 msg "mess

agetest 1"

So the way am approaching is
sprintf(msg,"test message from redis 1"
sprintf(cmd,"hmset input_list:0 msg %s",msg);
Batch_write(batch, cmd, strlen(cmd), 1);
Here the error comes as wrong number of argumnets in hmset and as I check it through monitor the error is due to the fact that the command is fired to redis as "hmset input_list:0 test message from redis i.e after space it takes it as parameter not as single string.
Can u please help me in this.

@saroj13278
Copy link
Author

A snapshot of the code is

            Batch *batch = Batch_new();
            Executor *executor = Executor_new();

            md = 1
            sprintf(msg,"test  message from redis\ -%d",i);

            printf("Msg is %s\n",msg);



            sprintf(cmd ,"hmset input_list:%d  msg %s r\n",md,msg);
            printf("cmd - %s\n",cmd);
            Batch_write(batch, cmd, strlen(cmd), 1);

Thanks
saroj

@andoryu-
Copy link

Redis support both unified request protocol and "inline command" protocol.
The unified request protocol, much like http, prepends a length line before every data line.
hmset input_list:0 msg some text
should be translated as:
*4\r\n$5\r\nhmset\r\n$12\r\ninput_list:0\r\n$3\r\nmsg\r\n$9\r\nsome text\r\n

The "inline command", however, does not contain length lines, thus is unable to carry any space in strings, and should be only used when having nothing but telnet at hand.

Best,
andoryu

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