diff options
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; |