aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-09-08 23:21:04 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-09-08 23:21:04 -0400
commit1035e47446ffb80811d673e5e3d0d83b18b76a5e (patch)
tree5c0e4e18577f8de4f251f42c588f47fa4ae231c8
parent746ec92adcbc9ed4ce3400f4e9f577230061ece0 (diff)
Extra debug
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs1
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs22
-rw-r--r--lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs5
3 files changed, 14 insertions, 14 deletions
diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs b/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs
index 4b88957..92db1d4 100644
--- a/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs
+++ b/lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs
@@ -76,6 +76,7 @@ namespace VNLib.Data.Caching.ObjectCache
/// <param name="other">The other handle to compare</param>
/// <returns>True if the handles hold a referrence to the same bucket</returns>
public bool Equals(CacheBucketHandle other) => ReferenceEquals(_bucket, other._bucket);
+
/// <summary>
/// Determines if the other handle instance is equal to the current. Handles are
/// equal iff the underlying bucket referrence is equal.
diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs b/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs
index f650cc3..9183d0a 100644
--- a/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs
+++ b/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs
@@ -31,7 +31,6 @@ using System.Runtime.CompilerServices;
using VNLib.Utils.Memory;
using VNLib.Utils.Extensions;
-
namespace VNLib.Data.Caching
{
/// <summary>
@@ -66,41 +65,37 @@ namespace VNLib.Data.Caching
MemoryHandle<byte> handle = heap.Alloc<byte>(bufferSize);
//Create new entry from handle
- CacheEntry entry = new (handle, data.Length);
+ CacheEntry entry = new (handle);
+ entry.SetLength(data.Length);
//Get the data segment
Span<byte> segment = entry.GetDataSegment();
+ Debug.Assert(segment.Length == data.Length);
+
//Copy data segment
data.CopyTo(segment);
return entry;
}
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
+
private static int GetRequiredHandleSize(int size)
{
//Caculate the minimum handle size to store all required information, rounded to nearest page
return (int)MemoryUtil.NearestPage(size + DATA_SEGMENT_START);
}
- private CacheEntry(MemoryHandle<byte> handle, int length)
+ private CacheEntry(MemoryHandle<byte> handle)
{
_handle = handle;
- //Store data length, assumes the handle is large enough to store it
- SetLength(length);
}
-
///<inheritdoc/>
public readonly void Dispose() => _handle?.Dispose();
-
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
+
private readonly Span<byte> GetTimeSegment() => _handle.AsSpan(0, TIME_SEGMENT_SIZE);
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
+
private readonly Span<byte> GetLengthSegment() => _handle.AsSpan(TIME_SEGMENT_SIZE, LENGTH_SEGMENT_SIZE);
/// <summary>
@@ -115,7 +110,6 @@ namespace VNLib.Data.Caching
return _handle.ByteLength;
}
-
/// <summary>
/// Gets the last set time
/// </summary>
diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs
index df7008d..6250e6c 100644
--- a/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs
+++ b/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs
@@ -202,6 +202,11 @@ namespace VNLib.Plugins.Extensions.VNCache
{
pluginLog.Debug("Failed to connect to random cache server because a TCP connection could not be established");
}
+ catch(HttpRequestException he) when(he.StatusCode.HasValue)
+ {
+ pluginLog.Warn("Failed to negotiate with cache server {reason}", he.Message);
+ await Task.Delay(1000, exitToken);
+ }
finally
{
IsConnected = false;