Akavache
Akavache copied to clipboard
Akavache 5.0 keyes exist but values are null
Note: for support questions, please ask on StackOverflow: https://stackoverflow.com/questions/tagged/Akavache . This repository's issues are reserved for feature requests and bug reports.
Do you want to request a feature or report a bug? bug
What is the current behavior?
| 0down votefavorite | I am using Akavache 5.0 with Xamarin.Forms. Out of nowhere my cache stopped working. I am using Blobcache.LocalMachine to save a key with an object. For the last year it has worked and now on restart of the app it still has the keys stored and brings back objects with all of the values being null. I have also tried this using Blobcache.UserAccount and the same results.On my App.cs Init() i set the name for Blobcache and call EnsureInitialize as well.Yes I have checked that my Visual Studio settings are set to keep the cache on restart for android. I have deployed my app to the google play beta store and still the same results.I am also using Azure Mobile Service Client which I have read can cause some issues.Any help would be appreciated. |
|---|
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
What is the expected behavior? the values are not null
What is the motivation / use case for changing the behavior?
Which versions of Akavache, and which platform / OS are affected by this issue? Did this work in previous versions of Akavache? Please also test with the latest stable and snapshot (https://www.myget.org/feed/Akavache/package/nuget/Akavache) versions.
Other information (e.g. stacktraces, related issues, suggestions how to fix)
I have the exact same problem.
I noticed that my app was no longer remembering the current user's information across sessions. I was still logged in (ie. the user exists in the cache), but the object was empty, all properties set to null. So I don't know exactly when and how it stopped working.
This only happens in my Authentication service (that is created synchronously when the app starts) and immediately creates an observable that loads the previous known user from the cache. I suspect that Akavache/SQLite aren't fully initialized when this happen and that the observables Akavache provides are hot.
public AuthenticationService()
{
/* simplified */
var lastSessionMember = secureCache.GetObject<Member>(MemberStorageKey)
.Catch<Member, KeyNotFoundException>(ex => Observable.Return(default(Member)))
.Do(member => { /* setting a breakpoint here: I get an empty Member object */ });
}
But this works:
public AuthenticationService()
{
/* simplified */
var lastSessionMember = Observable.Start(() => Unit.Default)
.SelectMany(_ => secureCache.GetObject<Member>(MemberStorageKey))
.Catch<Member, KeyNotFoundException>(ex => Observable.Return(default(Member)))
.Do(member => { /* The Member object is fully hydrated here! */ });
}
Any help or fix would be appreciated to avoid this workaround.
It is the same for me, it stopped working on Xamarin.Forms and give me empty objects.