Created
February 3, 2020 07:11
-
-
Save kasunkv/41eb02d360c3116d18a63a7b2f9994b7 to your computer and use it in GitHub Desktop.
Custom IOfflineCache implementation for Azure App Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Configuration.AzureAppConfiguration; | |
using Microsoft.Extensions.Hosting; | |
using System.IO; | |
namespace MusicStore.Web.Cache | |
{ | |
public class LocalFileOfflineCache : IOfflineCache | |
{ | |
private readonly string _cacheFilePath; | |
public LocalFileOfflineCache(IHostEnvironment env) | |
{ | |
_cacheFilePath = Path.Combine(env.ContentRootPath, "offline_cache.json"); | |
} | |
public void Export(AzureAppConfigurationOptions options, string data) | |
{ | |
File.WriteAllText(_cacheFilePath, data); | |
} | |
public string Import(AzureAppConfigurationOptions options) | |
{ | |
return File.ReadAllText(_cacheFilePath); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment