diff --git a/BitFaster.Caching/CacheDebugView.cs b/BitFaster.Caching/CacheDebugView.cs index e7f02e3a..f418ea1f 100644 --- a/BitFaster.Caching/CacheDebugView.cs +++ b/BitFaster.Caching/CacheDebugView.cs @@ -6,6 +6,7 @@ namespace BitFaster.Caching { [ExcludeFromCodeCoverage] internal class CacheDebugView + where K : notnull { private readonly ICache cache; diff --git a/BitFaster.Caching/Lfu/Builder/LfuBuilderBase.cs b/BitFaster.Caching/Lfu/Builder/LfuBuilderBase.cs index c89386ac..af6967e2 100644 --- a/BitFaster.Caching/Lfu/Builder/LfuBuilderBase.cs +++ b/BitFaster.Caching/Lfu/Builder/LfuBuilderBase.cs @@ -12,6 +12,7 @@ namespace BitFaster.Caching.Lfu.Builder /// The type of the builder. /// The return type of the builder. public abstract class LfuBuilderBase where TBuilder : LfuBuilderBase + where K : notnull { internal readonly LfuInfo info; diff --git a/BitFaster.Caching/Lfu/Builder/LfuInfo.cs b/BitFaster.Caching/Lfu/Builder/LfuInfo.cs index 963daacf..a7d06400 100644 --- a/BitFaster.Caching/Lfu/Builder/LfuInfo.cs +++ b/BitFaster.Caching/Lfu/Builder/LfuInfo.cs @@ -7,6 +7,7 @@ namespace BitFaster.Caching.Lfu.Builder { internal sealed class LfuInfo + where K : notnull { private object? expiry = null; diff --git a/BitFaster.Caching/Lfu/LfuNode.cs b/BitFaster.Caching/Lfu/LfuNode.cs index ed80f61b..5d37ad5e 100644 --- a/BitFaster.Caching/Lfu/LfuNode.cs +++ b/BitFaster.Caching/Lfu/LfuNode.cs @@ -2,6 +2,7 @@ namespace BitFaster.Caching.Lfu { internal class LfuNode + where K : notnull { internal LfuNodeList list; internal LfuNode next; @@ -66,6 +67,7 @@ internal enum Position } internal sealed class AccessOrderNode : LfuNode + where K : notnull { public AccessOrderNode(K k, V v) : base(k, v) { diff --git a/BitFaster.Caching/Lru/AfterAccessPolicy.cs b/BitFaster.Caching/Lru/AfterAccessPolicy.cs index 04dcbf24..98c6c5dd 100644 --- a/BitFaster.Caching/Lru/AfterAccessPolicy.cs +++ b/BitFaster.Caching/Lru/AfterAccessPolicy.cs @@ -7,6 +7,7 @@ namespace BitFaster.Caching.Lru /// Implement an expire after access policy. /// internal readonly struct AfterAccessPolicy : IItemPolicy> + where K : notnull { private readonly Duration timeToLive; private readonly Time time; diff --git a/BitFaster.Caching/Lru/Builder/LruBuilderBase.cs b/BitFaster.Caching/Lru/Builder/LruBuilderBase.cs index ab1eb208..e5a03b63 100644 --- a/BitFaster.Caching/Lru/Builder/LruBuilderBase.cs +++ b/BitFaster.Caching/Lru/Builder/LruBuilderBase.cs @@ -7,6 +7,7 @@ namespace BitFaster.Caching.Lru.Builder /// Recursive generic base class enables builder inheritance. /// public abstract class LruBuilderBase where TBuilder : LruBuilderBase + where K : notnull { internal readonly LruInfo info; diff --git a/BitFaster.Caching/Lru/Builder/LruInfo.cs b/BitFaster.Caching/Lru/Builder/LruInfo.cs index 1e9355cc..ba69b5da 100644 --- a/BitFaster.Caching/Lru/Builder/LruInfo.cs +++ b/BitFaster.Caching/Lru/Builder/LruInfo.cs @@ -9,6 +9,7 @@ namespace BitFaster.Caching.Lru.Builder /// The LRU key type // backcompat: make class internal public sealed class LruInfo + where K : notnull { private object? expiry = null; diff --git a/BitFaster.Caching/Lru/DiscretePolicy.cs b/BitFaster.Caching/Lru/DiscretePolicy.cs index 01dc2c61..8e70a327 100644 --- a/BitFaster.Caching/Lru/DiscretePolicy.cs +++ b/BitFaster.Caching/Lru/DiscretePolicy.cs @@ -4,6 +4,7 @@ namespace BitFaster.Caching.Lru { internal readonly struct DiscretePolicy : IDiscreteItemPolicy + where K : notnull { private readonly IExpiryCalculator expiry; private readonly Time time; diff --git a/BitFaster.Caching/Lru/IDiscreteItemPolicy.cs b/BitFaster.Caching/Lru/IDiscreteItemPolicy.cs index ab6b432b..ec02d395 100644 --- a/BitFaster.Caching/Lru/IDiscreteItemPolicy.cs +++ b/BitFaster.Caching/Lru/IDiscreteItemPolicy.cs @@ -6,6 +6,7 @@ /// /// public interface IDiscreteItemPolicy : IItemPolicy> + where K : notnull { } } diff --git a/BitFaster.Caching/Lru/IItemPolicy.cs b/BitFaster.Caching/Lru/IItemPolicy.cs index af6ebdb6..8f3b588c 100644 --- a/BitFaster.Caching/Lru/IItemPolicy.cs +++ b/BitFaster.Caching/Lru/IItemPolicy.cs @@ -9,6 +9,7 @@ namespace BitFaster.Caching.Lru /// The type of the value. /// The type of the LRU item. public interface IItemPolicy where I : LruItem + where K : notnull { /// /// Creates an LRU item. diff --git a/BitFaster.Caching/Lru/ITelemetryPolicy.cs b/BitFaster.Caching/Lru/ITelemetryPolicy.cs index 9ca7501f..27d991cf 100644 --- a/BitFaster.Caching/Lru/ITelemetryPolicy.cs +++ b/BitFaster.Caching/Lru/ITelemetryPolicy.cs @@ -7,6 +7,7 @@ namespace BitFaster.Caching.Lru /// The type of the key. /// The type of the value. public interface ITelemetryPolicy : ICacheMetrics, ICacheEvents + where K : notnull { /// /// Increment the miss counter. diff --git a/BitFaster.Caching/Lru/LongTickCountLruItem.cs b/BitFaster.Caching/Lru/LongTickCountLruItem.cs index 31de3feb..3c218351 100644 --- a/BitFaster.Caching/Lru/LongTickCountLruItem.cs +++ b/BitFaster.Caching/Lru/LongTickCountLruItem.cs @@ -7,6 +7,7 @@ namespace BitFaster.Caching.Lru /// The type of the key. /// The type of the value. public class LongTickCountLruItem : LruItem + where K : notnull { /// /// Initializes a new instance of the LongTickCountLruItem class with the specified key and value. diff --git a/BitFaster.Caching/Lru/LruItem.cs b/BitFaster.Caching/Lru/LruItem.cs index 56944316..44e48939 100644 --- a/BitFaster.Caching/Lru/LruItem.cs +++ b/BitFaster.Caching/Lru/LruItem.cs @@ -7,6 +7,7 @@ namespace BitFaster.Caching.Lru /// The type of the key. /// The type of the value. public class LruItem + where K : notnull { private volatile bool wasAccessed; private volatile bool wasRemoved; diff --git a/BitFaster.Caching/Lru/LruPolicy.cs b/BitFaster.Caching/Lru/LruPolicy.cs index 5982b6b9..cc1d93a0 100644 --- a/BitFaster.Caching/Lru/LruPolicy.cs +++ b/BitFaster.Caching/Lru/LruPolicy.cs @@ -7,6 +7,7 @@ namespace BitFaster.Caching.Lru /// Discards the least recently used items first. /// public readonly struct LruPolicy : IItemPolicy> + where K : notnull { /// public TimeSpan TimeToLive => Defaults.Infinite; diff --git a/BitFaster.Caching/Lru/NoTelemetryPolicy.cs b/BitFaster.Caching/Lru/NoTelemetryPolicy.cs index b5aaf952..7afd78e5 100644 --- a/BitFaster.Caching/Lru/NoTelemetryPolicy.cs +++ b/BitFaster.Caching/Lru/NoTelemetryPolicy.cs @@ -10,6 +10,7 @@ namespace BitFaster.Caching.Lru /// The type of the key. /// The type of the value. public struct NoTelemetryPolicy : ITelemetryPolicy + where K : notnull { /// public double HitRatio => 0.0; diff --git a/BitFaster.Caching/Lru/TLruLongTicksPolicy.cs b/BitFaster.Caching/Lru/TLruLongTicksPolicy.cs index 48868977..fb64ca3e 100644 --- a/BitFaster.Caching/Lru/TLruLongTicksPolicy.cs +++ b/BitFaster.Caching/Lru/TLruLongTicksPolicy.cs @@ -8,6 +8,7 @@ namespace BitFaster.Caching.Lru /// recently used items first, and any item that has expired. /// public readonly struct TLruLongTicksPolicy : IItemPolicy> + where K : notnull { private readonly Duration timeToLive; diff --git a/BitFaster.Caching/Lru/TelemetryPolicy.cs b/BitFaster.Caching/Lru/TelemetryPolicy.cs index 3cb94d2f..37b95742 100644 --- a/BitFaster.Caching/Lru/TelemetryPolicy.cs +++ b/BitFaster.Caching/Lru/TelemetryPolicy.cs @@ -11,6 +11,7 @@ namespace BitFaster.Caching.Lru /// The type of the value [DebuggerDisplay("Hit = {Hits}, Miss = {Misses}, Upd = {Updated}, Evict = {Evicted}")] public struct TelemetryPolicy : ITelemetryPolicy + where K : notnull { private Counter hitCount; private Counter missCount; diff --git a/BitFaster.Caching/Lru/TickCountLruItem.cs b/BitFaster.Caching/Lru/TickCountLruItem.cs index 3fae631a..956e4b7c 100644 --- a/BitFaster.Caching/Lru/TickCountLruItem.cs +++ b/BitFaster.Caching/Lru/TickCountLruItem.cs @@ -8,6 +8,7 @@ namespace BitFaster.Caching.Lru /// The type of the key. /// The type of the value. public class TickCountLruItem : LruItem + where K : notnull { /// /// Initializes a new instance of the TickCountLruItem class with the specified key and value. diff --git a/BitFaster.Caching/Lru/TimeStampedLruItem.cs b/BitFaster.Caching/Lru/TimeStampedLruItem.cs index b05fc3c1..ac60ebe4 100644 --- a/BitFaster.Caching/Lru/TimeStampedLruItem.cs +++ b/BitFaster.Caching/Lru/TimeStampedLruItem.cs @@ -8,6 +8,7 @@ namespace BitFaster.Caching.Lru /// The type of the key. /// The type of the value. public class TimeStampedLruItem : LruItem + where K : notnull { /// /// Initializes a new instance of the TimeStampedLruItem class with the specified key and value. diff --git a/BitFaster.Caching/Lru/TlruDateTimePolicy.cs b/BitFaster.Caching/Lru/TlruDateTimePolicy.cs index effdab1f..81e3a078 100644 --- a/BitFaster.Caching/Lru/TlruDateTimePolicy.cs +++ b/BitFaster.Caching/Lru/TlruDateTimePolicy.cs @@ -8,6 +8,7 @@ namespace BitFaster.Caching.Lru /// recently used items first, and any item that has expired. /// public readonly struct TLruDateTimePolicy : IItemPolicy> + where K : notnull { private readonly TimeSpan timeToLive; diff --git a/BitFaster.Caching/Lru/TlruTicksPolicy.cs b/BitFaster.Caching/Lru/TlruTicksPolicy.cs index e800cfa1..1ce6bd5a 100644 --- a/BitFaster.Caching/Lru/TlruTicksPolicy.cs +++ b/BitFaster.Caching/Lru/TlruTicksPolicy.cs @@ -13,6 +13,7 @@ namespace BitFaster.Caching.Lru /// value will wrap and time measurement will become invalid. /// public readonly struct TLruTicksPolicy : IItemPolicy> + where K : notnull { private readonly int timeToLive;