Storing byte array in REDIS

4,484 views
Skip to first unread message

Rumi Kalita

unread,
Nov 17, 2016, 8:27:39 AM11/17/16
to Redis DB
Hi Team,

I have one concern.

Without REDIS:
I have an object. First I have serialized it, then I tried to create object after deserialization,
and object has created successfully.

With REDIS:
I have an object, after serialization I have inserted in REDIS.
Then I retrieved it from REDIS and when I tried to create object after deserialization, object was not created.

Please suggest me some solution.

Thanks,
Rumi

Marc Gravell

unread,
Nov 17, 2016, 9:56:57 AM11/17/16
to redi...@googlegroups.com
That sounds like a bug in your code, or  how you are using whatever library you are using.

Redis  is binary safe  throughout, for both keys and values. However,  some client libraries might  not be, so if you are using binary (from the "byte array" mention in the subject), then it might  fail. If that  is the case, fixes might include:

- use a different library, one that is binary safe
- use a different serializer  (text based, json for example)
- base-64  encode the data that you send

Personally, I prefer the first option. It is also possible that the error is in the code you are using to serialize / deserialize etc. You might want to show some of that  code, or at least give an indication of the flavor of the code, and the libraries (both redis client and serialization) that you are using.

Marc

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Marc
Message has been deleted

Rumi Kalita

unread,
Nov 18, 2016, 2:10:26 AM11/18/16
to Redis DB
Hi Marc,

I am using base64 encode/ decode.
After that also the same issue.
What is the best approach to store and retrieve byte array in REDIS.

Thanks,
Rumi  

Marc Gravell

unread,
Nov 18, 2016, 8:14:33 PM11/18/16
to redi...@googlegroups.com
If you're still getting the issue with base-64 encoded data, then: neither redis nor the library is your problem. Your serialization code sounds suspect.

As for the best approach to store and retrieve byte array in redis: use a library that supports byte arrays directly

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Marc
Reply all
Reply to author
Forward
0 new messages