diff options
author | vnugent <public@vaughnnugent.com> | 2023-09-08 23:21:04 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-09-08 23:21:04 -0400 |
commit | 1035e47446ffb80811d673e5e3d0d83b18b76a5e (patch) | |
tree | 5c0e4e18577f8de4f251f42c588f47fa4ae231c8 /lib/VNLib.Data.Caching.ObjectCache | |
parent | 746ec92adcbc9ed4ce3400f4e9f577230061ece0 (diff) |
Extra debug
Diffstat (limited to 'lib/VNLib.Data.Caching.ObjectCache')
-rw-r--r-- | lib/VNLib.Data.Caching.ObjectCache/src/CacheBucketHandle.cs | 1 | ||||
-rw-r--r-- | lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs | 22 |
2 files changed, 9 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> |