-
Notifications
You must be signed in to change notification settings - Fork 272
Support use across multiple processess, how to use it? #28
Comments
IPC for multiprocess supportTo share data between two processes you need inter-process communication (IPC). A common android example for this are Implementing Why a databaseA So The Sqlite database is used to store the data. It's no just a simple key value store (like the shared preferences) because you can get additional informations for every key value pair saved to Tray automatically. You can get informations when the data was saved first or when the data was last updated. (see here). ContentProvider facts
Tray is not asyncTray doesn't support asynchronous operations. Everything runs synchronous. A It's up to the developer where to save the data, inside the UI Thread or in a worker thread. In my cases this was never a problem because I was writing data in a non-UI process where I didn't have to care about frames. I hope I could help you understand this lib 😄! |
so now everything is clear. I propose to describe(copy your text) it on the main page or in the documentation |
I have a question,when a call mPrefs.get("key") on the ui thread, and it is synchronous, will it block the UI thread when the data is so big? |
Support use across multiple processess
I'm trying to understand how can I take advantage of it . Can you give a practical example ?
Is it simply writes data asynchronous?
what will be happen when the app is killed before the data has been written to disk?
Is it true 'commit' semantics?
Topics that do not fully understand:
Tray solves this problem with a ContentProvider based storage.
What are the benefits it gives to us? Why we want use ContentProvider? Whether it's sharing of resources between different applications ?
Works multiprocess
So I can save several values in parallel?
automatically saves metadata for each entry (created, last updated, ...)
I do not understand? automatically saves metadata?
At first, it was the simpst way to use IPC with Binder to solve the multiprocess problem. Using the ContentProvider with a database turned out to be very handy when it comes to save metadata. We thought about replacing the database with the real SharedPreferences to boost the performance (the SharedPreferences do not access the disk for every read/write action which causes the multiprocess problem btw) but the metadata seemed to be more valuable to us.
Why we want use ContentProvider? Whether it's sharing of resources between different applications ?
The text was updated successfully, but these errors were encountered: