bwlewis / rredis

R client for Redis
http://illposed.net/
93 stars 25 forks source link

redisLPush(key, value, ...) #31

Closed ersidam closed 8 years ago

ersidam commented 9 years ago

function is not adding correnct value to list, it can be a character encoding problem

bwlewis commented 9 years ago

Can you provide a reproducible example?

ersidam commented 9 years ago

I'm reading some json string and make some calculation... Then I need to return a json string but when working with redisLPush, it returns some value like in screenshoot. firstly I think problem in jsonlite so I send just text string, there is no change in result.

library("rredis"); library("jsonlite"); redisConnect(host = "192.168.1.25",port = 6379); while(TRUE){ req <- redisRPop("request"); if(!is.null(req)){

data <- fromJSON(req);
#calculations
    #print(data);

res <- toJSON(data);
redisLPush(key = 'response',value = res );

} }

ekran alintisi

bwlewis commented 8 years ago

See the 'raw' options to send un-serialized data to Redis (also discussed in the vignette).

The default sends serialized R objects.

On 9/4/15, ersidam notifications@github.com wrote:

I'm reading some json string and make some calculation... Then I need to return a json string but when working with redisLPush, it returns some value like in screenshoot. firstly I think problem in jsonlite so I send just text string, there is no change in result.

library("rredis"); library("jsonlite"); redisConnect(host = "192.168.1.25",port = 6379); while(TRUE){ req <- redisRPop("request"); if(!is.null(req)){

data <- fromJSON(req);
  #calculations
    #print(data);

res <- toJSON(data);
redisLPush(key = 'response',value = res );

} }

ekran
alintisi


Reply to this email directly or view it on GitHub: https://github.com/bwlewis/rredis/issues/31#issuecomment-137796398

ersidam commented 8 years ago

applying charToRaw() function before sending data tp redis is a solution thanks

bwlewis commented 8 years ago

Great, glad that works. I'm trying to get doRedis updated on CRAN soon, but still have some work to do on the package... Closing this issue now.