Skip to content

Instantly share code, notes, and snippets.

@kasunkv
Created February 3, 2020 07:11
Show Gist options
  • Save kasunkv/41eb02d360c3116d18a63a7b2f9994b7 to your computer and use it in GitHub Desktop.
Save kasunkv/41eb02d360c3116d18a63a7b2f9994b7 to your computer and use it in GitHub Desktop.
Custom IOfflineCache implementation for Azure App Configuration
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