aboutsummaryrefslogtreecommitdiff
path: root/lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs
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 /lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs
parent746ec92adcbc9ed4ce3400f4e9f577230061ece0 (diff)
Extra debug
Diffstat (limited to 'lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs')
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/CacheEntry.cs22
1 files changed, 8 insertions, 14 deletions
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>