Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Values as InputStreams #33

Open
stephanenicolas opened this issue Jul 7, 2015 · 3 comments
Open

Values as InputStreams #33

stephanenicolas opened this issue Jul 7, 2015 · 3 comments

Comments

@stephanenicolas
Copy link

Hi Tray team,

What do you think of adding the ability to read an input stream from a tray item and write to a tray item using an outputstream ?
(Ideally there would be no transformation of the binary stream to get higher speed levels).

Actually, it would help to serialize and parse Pojos encoded with whatever format devs want (I would use it for JSON, but protobuf would also work, etc..)

thanks for your efforts on this lib guys !

@passsy
Copy link
Contributor

passsy commented Jul 15, 2015

No transformation of the binary stream for more speed is impossible. tl;dr Everything needs to be passed to a different process. Please read this for more infos about Binder and the ContentProvider.

Another thing: Tray isn't fast (and it will never be fast) by design. If you want something fast use the SharedPreferences but you will lose the multiprocess support. That in mind, it is properly not a good idea to store complex data structures in Tray unless it is very important for the data to stay in sync and persisted between different processes. Otherwise it would be a better idea to use a seperate database or a simple file for the data.

There is also a Binder limitation of ~2mb per transaction (visible in logcat as !!! FAILED BINDER TRANSACTION !!!). This means you can't save unlimited data per key.

But I see some cases where persisting a byte[] or a stream could be useful. I hope it does not get abused 😒.

@stephanenicolas
Copy link
Author

Thx a lot @pascal Welsch for the details. Though Tray is not what we are
looking for, I wish you good luck with your lib.

2015-07-15 11:02 GMT-07:00 Pascal Welsch [email protected]:

No transformation of the binary stream for more speed is impossible. tl;dr
Everything needs to be passed to a different process. Please read this
#28 (comment)
for more infos about Binder and the ContentProvider.

Another thing: Tray isn't fast (and it will never be fast) by design. If
you want something fast use the SharedPreferences but you will lose the
multiprocess support. That in mind, it is properly not a good idea to store
complex data structures in Tray unless it is very important for the data to
stay in sync and persisted between different processes. Otherwise it would
be a better idea to use a seperate database or a simple file for the data.

There is also a Binder limitation of ~2mb per transaction (visible in
logcat as !!! FAILED BINDER TRANSACTION !!!). This means you can't save
unlimited data per key.

But I see some cases where persisting a byte[] or a stream could be
useful. I hope it does not get abused [image: 😒].


Reply to this email directly or view it on GitHub
#33 (comment).

@ronanhardiman
Copy link

@stephanenicolas What about the library you looking for? Did you find it。Thx

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants