I was originally trying to fetch and cache an image using BlobCache.LocalMachine.LoadImageFromUrl(someURL)
, but I found that it
just stopped responding after I called this method. (Yes, I've set BlobCache.ApplicationName
, I even called BlobCache.EnsureInitialized()
, and the SQL3 lib wasn't stripped by the linker.) So I did some experiments and tried to find out what was wrong.
After several hours of testing I found that only these methods should work in my circumstances:
1.
BlobCache.LocalMachine.DownloadUrl(someURL).Wait(); // Can fetch the right image file but it won't store it into cache; The cache disappears if I restart the app
var image = BlobCache.LocalMachine.LoadImage(someURL).Wait().ToNative(); // This part is good
2.
BlobCache.LocalMachine.InsertObject<string>(key, value).Wait();
var value = BlobCache.LocalMachine.GetObject<string>(key).Wait(); // This functions well; I can get the correct value right away after a restart
Also, whenever I use await in my code, it falls to infinite deadlock(?). Say, var value = await BlobCache.LocalMachine.GetObject<string>(key);
. (Of course I've imported System.Reactive.Linq
.) The possible workaround to me is to use wait()
or subscribe()
instead.
BlobCache.LocalMachine.GetOrFetchObject() won't work either.
P.S.: I have the latest Xamarin.iOS & Mono build on my VS Mac.
So did I miss anything that's important when using Akavache in Xamarin.iOS? Please enlighten me.
I've posted an issue here.