question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileCachingLayer does not restore the saved data file even if the application is restarted. Manifest file empty.

See original GitHub issue

What does the bug do?

Although it saves the json file of the data generated with FileCachingLayer (JsonFileCacheLayer) in the folder, it does not write its metadata to the manifest file. When the application is restarted, although the data file exists, it does not pull the cached data and calls it from the getter again.

How can it be reproduced?

// Startup.cs
services.AddCacheStack(
   new ICacheLayer[]
   {
       //new MemoryCacheLayer(),
       new JsonFileCacheLayer(@"D:\jsoncachelayer")
   },
    new[] {
        new AutoCleanupExtension(TimeSpan.FromMinutes(30))
    });

// Controller.cs
public async Task<IActionResult> IndexAsync()
{
    var model = await _cacheStack.GetOrSetAsync<IndexViewModel>($"indexviewmodel", async (old) =>
    {
        return await _lnwCache.GetHomepageIndexModel();
    }, new CacheSettings(TimeSpan.FromMinutes(15)));

    return View("Index", model);
}
// manifest.json
{"Value":{}}

The file containing the data is stored in the folder named A1303B032BB63284F6F595600591AA13.json. But the manifest file is empty.

P.S: Read and write permissions are defined to the folder.

  • NuGet Package Version: 0.11.2
  • .NET Runtime Version: .NET 5
  • Operating System: Windows 10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Turnerjcommented, Aug 29, 2021

Yep, the DI system had this as intended behaviour so Cache Tower was just using it wrong. I’ve updated the service collection extensions to resolve this issue (allowing the cache stack and its layers to dispose, allowing the manifest to save).

I’ve just released v0.11.3 which includes the fix to the service collection/dependency injection so it should be disposed now (and thus trigger the manifest to save).

Let me know if it is still a problem after you’ve updated!

0reactions
Turnerjcommented, Aug 31, 2021

Everything is fine and working properly. Thank you for your effort.

Glad it is all working now!

There is one more thing I am wondering about. Is it possible to make a function that can manually refresh the data in the background? Same as with the staleAfter parameter but manually. cacheStack.RefreshValue(key, function?);

That’s an interesting idea - I’ve created #189 to track it. From what I’m picturing at the moment, it will likely need to take in the time-to-live value otherwise it can’t save the refreshed value in the cache. The method will likely need to be async too as background refreshing kinda cheats by simply not awaiting internally on an action.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No Saved Data Exists : r/MHRise
When I'm met with a Message telling me that "No Saved Data Exists. ... Is there a way to get my save file...
Read more >
The original file 'AndroidManifest.xml' has been deleted or ...
If you've deleted the file, you'll find it in history. ... go to your workspace->your project folder and see if there is a...
Read more >
possible corruption in the MANIFEST file?
The fix assumes that if the reopen of the manifest file fails, then everything is fine and life continues. But this is incorrect,...
Read more >
How to Restore Game Save Data on PS5 & Fix Lost Single ...
If your a PS Plus member, your game save data should auto upload to ... Now go to the setting section, then go...
Read more >
take photo and save to Album,but error - Microsoft Q&A
I use the codes to take photo and save it. private async void btnCamera_Clicked(object sender, EventArgs e) { var photo = await CrossMedia....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found