aboutsummaryrefslogtreecommitdiff
path: root/VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs
diff options
context:
space:
mode:
authorLibravatar vman <public@vaughnnugent.com>2022-12-28 14:15:04 -0500
committerLibravatar vman <public@vaughnnugent.com>2022-12-28 14:15:04 -0500
commit0c2fa662f60cf8b6b771fef3ff4c740eae17a83d (patch)
tree91495d460ceb12fba8cc274e77a8cbf4019c028d /VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs
parent8b5f3eebb9f8d9bd55e922a809ffa3bd52e33401 (diff)
Global cache client, asm loading, plugin local cache, and event managment
Diffstat (limited to 'VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs')
-rw-r--r--VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs8
1 files changed, 2 insertions, 6 deletions
diff --git a/VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs b/VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs
index eef79f0..c230cf5 100644
--- a/VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs
+++ b/VNLib.Plugins.Extensions.Loading.Sql/SqlDbConnectionLoader.cs
@@ -25,7 +25,6 @@
using System;
using System.Text.Json;
using System.Data.Common;
-using System.Runtime.CompilerServices;
using MySqlConnector;
@@ -45,9 +44,6 @@ namespace VNLib.Plugins.Extensions.Loading.Sql
{
public const string SQL_CONFIG_KEY = "sql";
public const string DB_PASSWORD_KEY = "db_password";
-
- private static readonly ConditionalWeakTable<PluginBase, Func<DbConnection>> LazyDbFuncTable = new();
- private static readonly ConditionalWeakTable<PluginBase, DbContextOptions> LazyCtxTable = new();
/// <summary>
@@ -61,7 +57,7 @@ namespace VNLib.Plugins.Extensions.Loading.Sql
{
plugin.ThrowIfUnloaded();
//Get or load
- return LazyDbFuncTable.GetValue(plugin, FactoryLoader);
+ return LoadingExtensions.GetOrCreateSingleton(plugin, FactoryLoader);
}
private static Func<DbConnection> FactoryLoader(PluginBase plugin)
@@ -136,7 +132,7 @@ namespace VNLib.Plugins.Extensions.Loading.Sql
public static DbContextOptions GetContextOptions(this PluginBase plugin)
{
plugin.ThrowIfUnloaded();
- return LazyCtxTable.GetValue(plugin, GetDbOptionsLoader);
+ return LoadingExtensions.GetOrCreateSingleton(plugin, GetDbOptionsLoader);
}
private static DbContextOptions GetDbOptionsLoader(PluginBase plugin)