diff options
author | vnugent <public@vaughnnugent.com> | 2024-02-14 14:23:53 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-02-14 14:23:53 -0500 |
commit | 6b87785026ca57d6f41cff87ddbd066362f3cacc (patch) | |
tree | 74cddbca5eebcec7948e706bd7b742b19e55eeb6 /lib/VNLib.Plugins.Extensions.VNCache/src/VNCacheExtensions.cs | |
parent | c0e2a71b7b4081117d87c2c34c1b2afb8d511732 (diff) |
Squashed commit of the following:
commit 456ead9bc8b0f61357bae93152ad0403c4940101
Author: vnugent <public@vaughnnugent.com>
Date: Tue Feb 13 14:46:35 2024 -0500
fix: #1 shared cluster index on linux & latested core updates
commit a481d63f964a5d5204cac2e95141f37f9a28d573
Author: vnugent <public@vaughnnugent.com>
Date: Tue Jan 23 15:43:50 2024 -0500
cache extension api tweaks
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.VNCache/src/VNCacheExtensions.cs')
-rw-r--r-- | lib/VNLib.Plugins.Extensions.VNCache/src/VNCacheExtensions.cs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/VNCacheExtensions.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/VNCacheExtensions.cs index d191ab1..c434e22 100644 --- a/lib/VNLib.Plugins.Extensions.VNCache/src/VNCacheExtensions.cs +++ b/lib/VNLib.Plugins.Extensions.VNCache/src/VNCacheExtensions.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Extensions.VNCache @@ -112,26 +112,19 @@ namespace VNLib.Plugins.Extensions.VNCache /// <exception cref="ArgumentNullException"></exception> public static ScopedCache GetPrefixedCache(this IGlobalCacheProvider cache, string prefix, HashAlg digest = HashAlg.SHA1, HashEncodingMode encoding = HashEncodingMode.Base64) { - _ = cache ?? throw new ArgumentNullException(nameof(cache)); - _ = prefix ?? throw new ArgumentNullException(nameof(prefix)); + ArgumentNullException.ThrowIfNull(cache); + ArgumentException.ThrowIfNullOrEmpty(prefix); //Create simple cache key generator SimpleCacheKeyImpl keyProv = new(prefix, digest, encoding); //Create the scoped cache from the simple provider return cache.GetScopedCache(keyProv); } - private sealed class SimpleCacheKeyImpl : ICacheKeyGenerator + private sealed class SimpleCacheKeyImpl(string prefix, HashAlg digest, HashEncodingMode encoding) : ICacheKeyGenerator { - private readonly string Prefix; - private readonly HashAlg Digest; - private readonly HashEncodingMode Encoding; - - public SimpleCacheKeyImpl(string prefix, HashAlg digest, HashEncodingMode encoding) - { - Prefix = prefix; - Digest = digest; - Encoding = encoding; - } + private readonly string Prefix = prefix; + private readonly HashAlg Digest = digest; + private readonly HashEncodingMode Encoding = encoding; [MethodImpl(MethodImplOptions.AggressiveInlining)] private int ComputeBufferSize(string id) => id.Length + Prefix.Length; |