GeezerVison is showing github.com — Changed database info cache key · roji/Npgsql@cffa5f5
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<Project Sdk="Microsoft.NET.Sdk"> | | 2 | + <PropertyGroup> | | 3 | + <Authors>Yoh Deadfall, Shay Rojansky</Authors> | | 4 | + <Description>NetTopologySuite plugin for Npgsql, allowing mapping of PostGIS geometry types to NetTopologySuite types.</Description> | | 5 | + <PackageTags>npgsql postgresql postgres postgis nts ado ado.net database sql</PackageTags> | | 6 | + <TargetFramework>netstandard2.0</TargetFramework> | | 7 | + <TargetFramework Condition="'$(DeveloperBuild)' == 'True'">net5.0</TargetFramework> | | 8 | + <NoWarn>$(NoWarn);NU5104</NoWarn> | | 9 | + </PropertyGroup> | | 10 | + <ItemGroup> | | 11 | + <PackageReference Include="NetTopologySuite.IO.PostGIS" /> | | 12 | + </ItemGroup> | | 13 | + <ItemGroup> | | 14 | + <ProjectReference Include="../Npgsql/Npgsql.csproj" /> | | 15 | + </ItemGroup> | | 16 | +</Project> |
Collapse file Copy file name to clipboardExpand all lines: src/Npgsql.NetTopologySuite/Npgsql.NetTopologySuite.csproj +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | <Authors>Yoh Deadfall, Shay Rojansky</Authors> | 4 | 4 | <Description>NetTopologySuite plugin for Npgsql, allowing mapping of PostGIS geometry types to NetTopologySuite types.</Description> | 5 | 5 | <PackageTags>npgsql postgresql postgres postgis nts ado ado.net database sql</PackageTags> | 6 | | - <TargetFramework>netstandard2.0</TargetFramework> | 7 | | - <TargetFramework Condition="'$(DeveloperBuild)' == 'True'">net5.0</TargetFramework> | | 6 | + <TargetFrameworks>net5.0</TargetFrameworks> | | 7 | + <TargetFrameworks Condition="'$(DeveloperBuild)' != 'True'">net461;netstandard2.0</TargetFrameworks> | 8 | 8 | <NoWarn>$(NoWarn);NU5104</NoWarn> | 9 | 9 | </PropertyGroup> | 10 | 10 | <ItemGroup> | |
Collapse file Copy file name to clipboardExpand all lines: src/Npgsql/NpgsqlConnector.cs +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -347,6 +347,7 @@ internal NpgsqlConnector(NpgsqlConnection connection) | 347 | 347 |
| 348 | 348 | string Host => Settings.Host!; | 349 | 349 | int Port => Settings.Port; | | 350 | + string Database => Settings.Database!; | 350 | 351 | string KerberosServiceName => Settings.KerberosServiceName; | 351 | 352 | SslMode SslMode => Settings.SslMode; | 352 | 353 | int ConnectionTimeout => Settings.Timeout; | @@ -522,7 +523,8 @@ internal async ValueTask LoadDatabaseInfo(bool forceReload, NpgsqlTimeout timeou | 522 | 523 | // being set up (even if its empty) | 523 | 524 | TypeMapper = new ConnectorTypeMapper(this); | 524 | 525 |
| 525 | | - if (forceReload || !NpgsqlDatabaseInfo.Cache.TryGetValue(ConnectionString, out var database)) | | 526 | + var key = (Host, Port, Database, Settings.ServerCompatibilityMode == ServerCompatibilityMode.NoTypeLoading); | | 527 | + if (forceReload || !NpgsqlDatabaseInfo.Cache.TryGetValue(key, out var database)) | 526 | 528 | { | 527 | 529 | var hasSemaphore = async | 528 | 530 | ? await DatabaseInfoSemaphore.WaitAsync(timeout.TimeLeft, cancellationToken) | @@ -534,9 +536,9 @@ internal async ValueTask LoadDatabaseInfo(bool forceReload, NpgsqlTimeout timeou | 534 | 536 |
| 535 | 537 | try | 536 | 538 | { | 537 | | - if (forceReload || !NpgsqlDatabaseInfo.Cache.TryGetValue(ConnectionString, out database)) | | 539 | + if (forceReload || !NpgsqlDatabaseInfo.Cache.TryGetValue(key, out database)) | 538 | 540 | { | 539 | | - NpgsqlDatabaseInfo.Cache[ConnectionString] = database = await NpgsqlDatabaseInfo.Load(Connection, | | 541 | + NpgsqlDatabaseInfo.Cache[key] = database = await NpgsqlDatabaseInfo.Load(Connection, | 540 | 542 | timeout, async); | 541 | 543 | } | 542 | 544 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/Npgsql/NpgsqlDatabaseInfo.cs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,8 +15,8 @@ public abstract class NpgsqlDatabaseInfo | 15 | 15 | { | 16 | 16 | #region Fields | 17 | 17 |
| 18 | | - internal static readonly ConcurrentDictionary<string, NpgsqlDatabaseInfo> Cache | 19 | | - = new ConcurrentDictionary<string, NpgsqlDatabaseInfo>(); | | 18 | + internal static readonly ConcurrentDictionary<(string Host, int Port, string Database, bool NoTypeLoading), NpgsqlDatabaseInfo> Cache | | 19 | + = new ConcurrentDictionary<(string Host, int Port, string Database, bool NoTypeLoading), NpgsqlDatabaseInfo>(); | 20 | 20 |
| 21 | 21 | static volatile INpgsqlDatabaseInfoFactory[] Factories = new INpgsqlDatabaseInfoFactory[] | 22 | 22 | { | |
|