2

I am using Akavache standard approach on iOS (actually, it's .NET Standard project for Android/iOS), but the issue appears with iOS only.

I save some value during the app lifecycle:

    await BlobCache.Secure.InsertObject("user", user);

And on the app new session this:

    var user = await BlobCache.Secure.GetObject<UserModel>("user");

But the object is not available (with KeyNotFoundException exception).

Recently I also was trying to call BlobCache.Secure.Flush().Wait() right after the object saving, but there is still no effect.

The issue happens with iOS only. Android is fine. The issue happens with both Secure and UserAccount objects.

The data is not available even after "gentle" BlobCache.Shutdown().Wait() on the application closing. So, have no idea even where to search the solution now.

Any thoughts why might cause this issue and how I can solve it?

Agat
  • 4,577
  • 2
  • 34
  • 62

2 Answers2

1

There's another issue people have had is that the SqlLite cache is getting linked out. If you check the type on LocalMachine and it's of type MemoryCache that won't be resilient.

Just add the linker static class somewhere in your project (even if it's a PCL or Standard lib).

That worked for me.

Simon Corcos
  • 962
  • 14
  • 31
0

Did you set the ApplicationName property on BlobCache? On iOS this seems more of a necessity than on Android it seems.

Qonstrukt
  • 194
  • 8
  • Yes. It's properly setup in accordance to the documentation. Pretty simple and straightforward. – Agat Feb 01 '18 at 14:47
  • Did you try using the `User` blob? Because `Secure` is a dummy implementation anyway. (It's not secure at all on iOS.) – Qonstrukt Feb 01 '18 at 14:50
  • Is this your issue? https://stackoverflow.com/questions/47279254/possible-bug-in-akavache-in-xamarin-forms-xamarin-ios/47369487#47369487 iOS likes to link out the dll used to save things to a persistent store. If that gets linked out then the cache just uses InMemory Cache which isn't persistent. Android doesn't really have the same problem – Shane Neuville Feb 01 '18 at 16:21