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

Unrestrict Redis Key and String types #43

Open
andyscott opened this issue Aug 29, 2013 · 15 comments
Open

Unrestrict Redis Key and String types #43

andyscott opened this issue Aug 29, 2013 · 15 comments

Comments

@andyscott
Copy link
Contributor

Changes in c7bedc5 restrict Redis string ops to Scala strings. Redis strings and keys are "binary safe, [... and] can contain any kind of data".

Passing in serializable objects as keys was super useful.

See http://redis.io/topics/data-types-intro and http://redis.io/topics/data-types

@andyscott
Copy link
Contributor Author

I can head this up, assuming it's a wanted change.

@guersam
Copy link
Collaborator

guersam commented Aug 30, 2013

It makes sense.

Fortunately #41 accepts raw bytes input/output without modification, so it can be easily fixed by just replacing key type from String to Stringified basically.

To support for arbitrary objects out-of-box, additional changes in formats are needed though.

@andyscott
Copy link
Contributor Author

The Stringified front end looks nice. However, looking through the serialization package is seems everything that gets sent over the wire is still round tripped through toString and wrapped in a new ByteString using the UTF-8 string constructor. Binary data (at least Array[Byte]) can be directly wrapped in a ByteString.

@guersam
Copy link
Collaborator

guersam commented Aug 30, 2013

We already have that kind of reader and writer here and here.

Required changes are to make it more explicit (such as BinaryReader/Writer and BinaryFormat) and optionally to provide a delegation logic to (un)marshal complex data types based on existing readers/writers.

@debasishg
Copy link
Owner

+1 .. we already have the machinery in place.

@andyscott
Copy link
Contributor Author

Looks like you guys do. This would be a welcomed addition.

I've taken an initial stab at part of it, but I don't know the code base very well yet.

@guersam
Copy link
Collaborator

guersam commented Sep 10, 2013

Any update on this, @andyscott? It you don't have enough time I can handle this.

@andyscott
Copy link
Contributor Author

I haven't gotten around to it. Eventually I will, but it you have time and want to do it go ahead!

/ sent via phone /
Andy G. Scott /

On Sep 9, 2013, at 22:33, guersam [email protected] wrote:

Any update on this, @andyscott? It you don't have enough time I can handle this.


Reply to this email directly or view it on GitHub.

@danielkza
Copy link

I'm trying to use scala-redis-nb to serialize arbitrary Serializable objects, and currently I have to convert them to Base64 strings because a) scala-redis-nb routes everything to strings and b) The interfaces that can bypass that and read and write bytes are private. I would really appreciate, even if nobody has the time to change everything that is needed, at least consider providing a way to use Format with arbitrary byte content.

Thanks,
Daniel

@debasishg
Copy link
Owner

Hi Daniel -

Which version of scala-redis-nb are u using right now ?

Thanks.

@danielkza
Copy link

I'm using version 0.3.

@debasishg
Copy link
Owner

0.3 supports raw bytes in send/receive. Here's an example .. https://github.com/debasishg/scala-redis-nb/blob/master/src/test/scala/com/redis/serialization/SerializationSpec.scala#L71 .. Could u give a sample test case of the requirement ?

@danielkza
Copy link

How can I use that to write a Format object that can take a Serializable and process it then, since it only has read and write methods returning strings? Sorry if I misspoke on it not being possible, I just looked around for a way and had not found any. Does the manual conversion handle null bytes properly?

Edit: sorry for being a little silly, I think I have it figured out by now, I just have to override the to/fromByteString methods. But it would be better to refactor things a bit somehow because there is no enforced guarantee that read/write can be safely bypassed in all cases.

@danielkza
Copy link

What about using Akka's Serialization library? It's an already tested codebase, is very configurable, and already has all the dynamic dispatch work done, which I actually happen to be very interested in.

@debasishg
Copy link
Owner

A Pull Request will be welcome :-)

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

4 participants