magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

Database syncing issue (Caching+Thread) #1202

Open sahilchaddha opened 8 years ago

sahilchaddha commented 8 years ago

Hi,

I am trying to sync whole coredata with web server in background thread. Right now, i am using "MR_contextForCurrentThread" for thread safe because we have a lot asynchronous process running in background and merging with coredata.

But, my problem is sometimes we are not getting latest data(current changes) while fetching data in background/main thread. So thread keeps syncing old data and that create data duplication in web server.

Is there any data caching or thread issue? I am trying to figure this out from days but did not find any clue.

Is there any way to save data in background synchronously ?

Thanks, Sahil

sammy-SC commented 8 years ago

Hello,

MR_contextForCurrentThread is marked as deprecated and therefore should be avoided.

If you are trying to do long running imports I advice you to go through https://github.com/magicalpanda/MagicalRecord/wiki/Importing-Data

There is a way to save data in background in blocking manner, try using MagicalRecord.saveWithBlockAndWait.

Now i am no expert, i am just talking from my experience