aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs30
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs5
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs
index 3584344..7908313 100644
--- a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs
+++ b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs
@@ -83,6 +83,9 @@ namespace VNLib.Data.Caching.ObjectCache
/// </summary>
public IBlobCacheTable Cache { get; } = cache ?? throw new ArgumentNullException(nameof(cache));
+
+ private readonly ILogProvider _tLog = config.LogTransactions ? config.Log : new NullLogger();
+
///<inheritdoc/>
protected override async Task ProcessAsync(FBMContext context, T? userState, CancellationToken exitToken)
{
@@ -250,6 +253,8 @@ namespace VNLib.Data.Caching.ObjectCache
if (found)
{
EnqueEvent(change);
+
+ _tLog.Debug("Deleted cache entry {id}", change.CurrentId);
}
}
@@ -260,6 +265,8 @@ namespace VNLib.Data.Caching.ObjectCache
EnqueEvent(change);
+ _tLog.Debug("Cache entry {id} added or updated. New ID {nid}", change.CurrentId, change.AlternateId);
+
context.CloseResponse(ResponseCodes.Okay);
}
@@ -286,5 +293,28 @@ namespace VNLib.Data.Caching.ObjectCache
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
+
+ sealed class NullLogger : ILogProvider
+ {
+ public void Flush()
+ { }
+
+ public object GetLogProvider() => null!;
+
+
+ public bool IsEnabled(LogLevel level) => false;
+
+ public void Write(LogLevel level, string value)
+ { }
+
+ public void Write(LogLevel level, Exception exception, string value = "")
+ { }
+
+ public void Write(LogLevel level, string value, params object?[] args)
+ { }
+
+ public void Write(LogLevel level, string value, params ValueType[] args)
+ { }
+ }
}
}
diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs
index 1098be4..492dfb8 100644
--- a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs
+++ b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs
@@ -47,5 +47,10 @@ namespace VNLib.Data.Caching.ObjectCache
/// data in FBM header fields
/// </summary>
public bool EnableMessageChecksums { get; init; } = true;
+
+ /// <summary>
+ /// A flag that enables logging of transactions (events) to the log
+ /// </summary>
+ public bool LogTransactions { get; init; }
}
}