From 96832e3d1ea53868feb02ef48637a6fbbfd9f037 Mon Sep 17 00:00:00 2001 From: Ahmed Yasin Koculu Date: Mon, 15 Aug 2022 12:26:57 +0200 Subject: [PATCH] Improve cache index collision handler. --- src/ZoneTree/Segments/Disk/CircularBlockCache.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ZoneTree/Segments/Disk/CircularBlockCache.cs b/src/ZoneTree/Segments/Disk/CircularBlockCache.cs index afaef1e..29b0b3a 100644 --- a/src/ZoneTree/Segments/Disk/CircularBlockCache.cs +++ b/src/ZoneTree/Segments/Disk/CircularBlockCache.cs @@ -30,7 +30,10 @@ public class CircularBlockCache block, (key, existingBlock) => { - if (existingBlock.LastAccessTicks + + // todo: add secondary table to optimize + // cache index collision. + if (MaxCachedBlockCount > 32 && + existingBlock.LastAccessTicks + MinimumBlockLifeSpanInMilliseconds > DateTime.UtcNow.Ticks) return existingBlock;