Skip to content

Commit

Permalink
Merge pull request #133 from LeonAquitaine/master
Browse files Browse the repository at this point in the history
Local cache debug features
  • Loading branch information
lbotinelly authored Nov 10, 2023
2 parents 12bcacc + d65dcf7 commit 0e971f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Zen.Storage/Cache/Local.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ namespace Zen.Storage.Cache
{
public static class Local
{
public static readonly string BasePath = Base.Current.Options?.CachePath ?? $"{Host.DataDirectory}{Path.DirectorySeparatorChar}cache{Path.DirectorySeparatorChar}";
public static readonly string BasePath;

static Local()
{
BasePath = Base.Current.Options?.CachePath ?? Path.Combine(Host.DataDirectory, "cache");
Base.Current.Log.KeyValuePair("Local Cache BasePath", BasePath, Base.Module.Log.Message.EContentType.StartupSequence);
}

public static string WriteString(string key, string source) { return Write(key, new MemoryStream(Encoding.UTF8.GetBytes(source))); }

Expand All @@ -21,6 +27,8 @@ public static string Write(string key, Stream source)
var targetFile = Path.Combine(BasePath, key);
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));

Log.KeyValuePair("Local Cache Write", targetFile, Base.Module.Log.Message.EContentType.Debug);

using (var fileStream = File.Create(targetFile))
{
source.Seek(0, SeekOrigin.Begin);
Expand Down

0 comments on commit 0e971f5

Please sign in to comment.