aboutsummaryrefslogtreecommitdiff
path: root/plugins/ObjectCacheServer/src/Endpoints
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-03-09 01:48:38 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-03-09 01:48:38 -0500
commitcd1daadaeaa6ffbaaef3ed25452decd90d01fdfc (patch)
tree51252a42ccf3f6eb860e42d83f064a7247d7ebf7 /plugins/ObjectCacheServer/src/Endpoints
parent5edcd9b03532823c71fd337e39b7f03fe2ea174e (diff)
Omega cache, session, and account provider complete overhaul
Diffstat (limited to 'plugins/ObjectCacheServer/src/Endpoints')
-rw-r--r--plugins/ObjectCacheServer/src/Endpoints/CacheConfiguration.cs11
-rw-r--r--plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs21
-rw-r--r--plugins/ObjectCacheServer/src/Endpoints/ICacheStore.cs6
3 files changed, 21 insertions, 17 deletions
diff --git a/plugins/ObjectCacheServer/src/Endpoints/CacheConfiguration.cs b/plugins/ObjectCacheServer/src/Endpoints/CacheConfiguration.cs
index e9584b6..f7adeb3 100644
--- a/plugins/ObjectCacheServer/src/Endpoints/CacheConfiguration.cs
+++ b/plugins/ObjectCacheServer/src/Endpoints/CacheConfiguration.cs
@@ -1,11 +1,11 @@
/*
-* Copyright (c) 2022 Vaughn Nugent
+* Copyright (c) 2023 Vaughn Nugent
*
* Library: VNLib
* Package: ObjectCacheServer
-* File: ConnectEndpoint.cs
+* File: CacheConfiguration.cs
*
-* ConnectEndpoint.cs is part of ObjectCacheServer which is part of the larger
+* CacheConfiguration.cs is part of ObjectCacheServer which is part of the larger
* VNLib collection of libraries and utilities.
*
* ObjectCacheServer is free software: you can redistribute it and/or modify
@@ -49,6 +49,9 @@ namespace VNLib.Data.Caching.ObjectCache.Server
[JsonPropertyName("max_cache")]
- public int MaxCacheEntries { get; set; } = 10000;
+ public uint MaxCacheEntries { get; set; } = 10000;
+
+ [JsonPropertyName("buckets")]
+ public uint BucketCount { get; set; } = 10;
}
}
diff --git a/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs b/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs
index 9a1ece0..1a7331d 100644
--- a/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs
+++ b/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs
@@ -45,7 +45,6 @@ using VNLib.Plugins.Essentials;
using VNLib.Plugins.Extensions.Loading;
using VNLib.Plugins.Essentials.Endpoints;
using VNLib.Plugins.Essentials.Extensions;
-using System.Text.Json.Serialization;
namespace VNLib.Data.Caching.ObjectCache.Server
{
@@ -56,7 +55,7 @@ namespace VNLib.Data.Caching.ObjectCache.Server
private static readonly TimeSpan AuthTokenExpiration = TimeSpan.FromSeconds(30);
private readonly string AudienceLocalServerId;
- private readonly ObjectCacheStore Store;
+ private readonly BlobCacheLIstener Store;
private readonly PluginBase Pbase;
private readonly ConcurrentDictionary<string, AsyncQueue<ChangeEvent>> StatefulEventQueue;
@@ -81,7 +80,7 @@ namespace VNLib.Data.Caching.ObjectCache.Server
DisableCrossSiteDenied = true
};
- public ConnectEndpoint(PluginBase plugin, IReadOnlyDictionary<string, JsonElement> config)
+ public ConnectEndpoint(PluginBase plugin, IConfigScope config)
{
string? path = config["path"].GetString();
@@ -106,7 +105,7 @@ namespace VNLib.Data.Caching.ObjectCache.Server
StatefulEventQueue = new(StringComparer.OrdinalIgnoreCase);
//Init the cache store
- Store = InitializeCache((ObjectCacheServerEntry)plugin, CacheConfig.MaxCacheEntries);
+ Store = InitializeCache((ObjectCacheServerEntry)plugin, CacheConfig.BucketCount, CacheConfig.MaxCacheEntries);
/*
* Generate a random guid for the current server when created so we
@@ -118,7 +117,7 @@ namespace VNLib.Data.Caching.ObjectCache.Server
_ = plugin.ObserveWork(this, 100);
}
- private static ObjectCacheStore InitializeCache(ObjectCacheServerEntry plugin, int maxCache)
+ private static BlobCacheLIstener InitializeCache(ObjectCacheServerEntry plugin, uint buckets, uint maxCache)
{
if(maxCache < 2)
{
@@ -131,8 +130,10 @@ namespace VNLib.Data.Caching.ObjectCache.Server
plugin.Log.Information("Suggestion: You may want a larger cache size, you have less than 200 items in cache");
}
+ plugin.Log.Verbose("Creating cache store with {bc} buckets, with {mc} items/bucket", buckets, maxCache);
+
//Endpoint only allows for a single reader
- return new (maxCache, plugin.Log, plugin.CacheHeap, true);
+ return new (buckets, maxCache, plugin.Log, plugin.CacheHeap, true);
}
/// <summary>
@@ -491,16 +492,16 @@ namespace VNLib.Data.Caching.ObjectCache.Server
private sealed class CacheStore : ICacheStore
{
- private readonly ObjectCacheStore _cache;
+ private readonly BlobCacheLIstener _cache;
- public CacheStore(ObjectCacheStore cache)
+ public CacheStore(BlobCacheLIstener cache)
{
_cache = cache;
}
ValueTask ICacheStore.AddOrUpdateBlobAsync<T>(string objectId, string? alternateId, GetBodyDataCallback<T> bodyData, T state, CancellationToken token)
{
- return _cache.AddOrUpdateBlobAsync(objectId, alternateId, bodyData, state, token);
+ return _cache.Cache.AddOrUpdateObjectAsync(objectId, alternateId, bodyData, state, default, token);
}
void ICacheStore.Clear()
@@ -510,7 +511,7 @@ namespace VNLib.Data.Caching.ObjectCache.Server
ValueTask<bool> ICacheStore.DeleteItemAsync(string id, CancellationToken token)
{
- return _cache.DeleteItemAsync(id, token);
+ return _cache.Cache.DeleteObjectAsync(id, token);
}
}
}
diff --git a/plugins/ObjectCacheServer/src/Endpoints/ICacheStore.cs b/plugins/ObjectCacheServer/src/Endpoints/ICacheStore.cs
index 3776269..f911af9 100644
--- a/plugins/ObjectCacheServer/src/Endpoints/ICacheStore.cs
+++ b/plugins/ObjectCacheServer/src/Endpoints/ICacheStore.cs
@@ -1,11 +1,11 @@
/*
-* Copyright (c) 2022 Vaughn Nugent
+* Copyright (c) 2023 Vaughn Nugent
*
* Library: VNLib
* Package: ObjectCacheServer
-* File: ConnectEndpoint.cs
+* File: ICacheStore.cs
*
-* ConnectEndpoint.cs is part of ObjectCacheServer which is part of the larger
+* ICacheStore.cs is part of ObjectCacheServer which is part of the larger
* VNLib collection of libraries and utilities.
*
* ObjectCacheServer is free software: you can redistribute it and/or modify