Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using GetOrFetchObject never seems to invalidate objects #87

Closed
TheAngryByrd opened this issue Oct 20, 2013 · 5 comments
Closed

Using GetOrFetchObject never seems to invalidate objects #87

TheAngryByrd opened this issue Oct 20, 2013 · 5 comments
Labels

Comments

@TheAngryByrd
Copy link

Using thee GetOrFetchObject for operations that write to disk, it never seem to invalidate using the absolute expiration.

@anaisbetts
Copy link
Member

How are you testing that it's not invalidating?

@TheAngryByrd
Copy link
Author

Maybe I'm just using it wrong?

I have a project here: https://github.com/TheAngryByrd/GetOrFetchProblem/

If you notice in the Mainpage.xaml.cs, the OnNavigatedTo demostrates what i'm trying to do.

I call :

  var value = await BlobCache.LocalMachine.GetOrFetchObject("key", () => GetThing(), DateTimeOffset.Now.AddSeconds(10));

and it will write out the console when GetThing() gets called and when it returns a value.

Now if you stop the app, wait 10 seconds and open it back up, it never seems to call GetThing() again.

@anaisbetts
Copy link
Member

I think I know what's happening. You're killing the app via the Stop button, and you're using the deprecated backend (i.e. not SQLite3) - when you do this (and you don't Dispose BlobCache on shutdown), Akavache doesn't flush the metadata so it loses the expiration.

@anaisbetts
Copy link
Member

Here's the 411:

https://github.com/github/Akavache/blob/master/Akavache/PersistentBlobCache.cs#L104

We need at least 30sec of idle time before we'll attempt to flush the cache. If you make a bunch of writes then immediately kill it and you don't shutdown the blob cache properly, you'll see this. The way to shut it down is:

BlobCache.LocalMachine.Dispose();
await BlobCache.Shutdown;

@TheAngryByrd
Copy link
Author

Ok awesome. I'll make sure to do that.

Or maybe I'll move to using sqllite.

Thanks!

@lock lock bot added the outdated label Jun 25, 2019
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants