-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for mysqlconnector
1 parent
3e82369
commit 7b54483
Showing
26 changed files
with
1,374 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/ScaledDomains.Extensions.Caching.MySql.Core/DatabaseConsts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ScaledDomains.Extensions.Caching.MySql; | ||
|
||
internal static class DatabaseConsts | ||
{ | ||
internal const int IdColumnSize = 767; | ||
} |
2 changes: 0 additions & 2 deletions
2
...ions.Caching.MySql/IDatabaseOperations.cs → ...Caching.MySql.Core/IDatabaseOperations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
src/ScaledDomains.Extensions.Caching.MySql.Core/InternalsVisibleTo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("ScaledDomains.Extensions.Caching.MySql")] | ||
[assembly: InternalsVisibleTo("ScaledDomains.Extensions.Caching.MySql.MySqlConnector")] | ||
[assembly: InternalsVisibleTo("ScaledDomains.Extensions.Caching.MySql.Tests")] | ||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
...dDomains.Extensions.Caching.MySql.Core/ScaledDomains.Extensions.Caching.MySql.Core.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks> | ||
<LangVersion>Latest</LangVersion> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="../../README.md" Pack="true" PackagePath="/" /> | ||
</ItemGroup> | ||
|
||
</Project> |
File renamed without changes.
File renamed without changes.
404 changes: 404 additions & 0 deletions
404
src/ScaledDomains.Extensions.Caching.MySql.Core/packages.lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
243 changes: 243 additions & 0 deletions
243
src/ScaledDomains.Extensions.Caching.MySql.MySqlConnector/DatabaseOperations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
using System; | ||
using System.Data; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Caching.Distributed; | ||
using Microsoft.Extensions.Options; | ||
using MySqlConnector; | ||
|
||
namespace ScaledDomains.Extensions.Caching.MySql | ||
{ | ||
internal sealed class DatabaseOperations : IDatabaseOperations | ||
{ | ||
private readonly SqlCommands _sqlCommands; | ||
private readonly ISystemClock _systemClock; | ||
private readonly string _connectionString; | ||
|
||
public DatabaseOperations(IOptions<MySqlServerCacheOptions> options, ISystemClock systemClock) | ||
{ | ||
if (options is null || options.Value is null) | ||
{ | ||
throw new ArgumentNullException(nameof(options)); | ||
} | ||
|
||
_systemClock = systemClock ?? throw new ArgumentNullException(nameof(systemClock)); | ||
|
||
_connectionString = options.Value.ConnectionString; | ||
var connectionStringBuilder = new MySqlConnectionStringBuilder(_connectionString); | ||
_sqlCommands = new SqlCommands(connectionStringBuilder.Database, options.Value.TableName); | ||
} | ||
|
||
public byte[]? GetCacheItem(string key) | ||
{ | ||
var utcNow = _systemClock.UtcNow; | ||
|
||
var cmdText = _sqlCommands.GetCacheItem; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
command.Parameters.Add(new MySqlParameter("@UtcNow", MySqlDbType.Timestamp) { Value = utcNow.UtcDateTime }); | ||
|
||
connection.Open(); | ||
|
||
byte[]? result = null; | ||
|
||
using var reader = command.ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult | CommandBehavior.SequentialAccess); | ||
|
||
if (reader.Read()) | ||
{ | ||
result = reader.GetFieldValue<byte[]>(0); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public async Task<byte[]?> GetCacheItemAsync(string key, CancellationToken token = default) | ||
{ | ||
token.ThrowIfCancellationRequested(); | ||
|
||
var utcNow = _systemClock.UtcNow; | ||
|
||
var cmdText = _sqlCommands.GetCacheItem; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
command.Parameters.Add(new MySqlParameter("@UtcNow", MySqlDbType.Timestamp) { Value = utcNow.UtcDateTime }); | ||
|
||
await connection.OpenAsync(token).ConfigureAwait(false); | ||
|
||
byte[]? result = null; | ||
|
||
using var reader = await command.ExecuteReaderAsync(CommandBehavior.SingleRow | CommandBehavior.SingleResult | CommandBehavior.SequentialAccess, token).ConfigureAwait(false); | ||
|
||
if (await reader.ReadAsync(token).ConfigureAwait(false)) | ||
{ | ||
result = await reader.GetFieldValueAsync<byte[]>(0, token).ConfigureAwait(false); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public void SetCacheItem(string key, byte[] value, DistributedCacheEntryOptions options) | ||
{ | ||
var utcNow = _systemClock.UtcNow; | ||
|
||
var absoluteExpiration = GetAbsoluteExpiration(utcNow, options); | ||
ValidateOptions(options.SlidingExpiration, absoluteExpiration); | ||
|
||
var cmdText = _sqlCommands.SetCacheItem; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
command.Parameters.Add(new MySqlParameter("@Value", MySqlDbType.Blob) { Value = value }); | ||
command.Parameters.Add(new MySqlParameter("@UtcNow", MySqlDbType.Timestamp) { Value = utcNow.UtcDateTime }); | ||
command.Parameters.Add(new MySqlParameter("@SlidingExpiration", MySqlDbType.Time) { Value = (object?)options.SlidingExpiration ?? DBNull.Value }); | ||
command.Parameters.Add(new MySqlParameter("@AbsoluteExpiration", MySqlDbType.Timestamp) { Value = (object?)absoluteExpiration?.UtcDateTime ?? DBNull.Value }); | ||
|
||
connection.Open(); | ||
|
||
command.ExecuteNonQuery(); | ||
} | ||
|
||
public async Task SetCacheItemAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default) | ||
{ | ||
token.ThrowIfCancellationRequested(); | ||
|
||
var utcNow = _systemClock.UtcNow; | ||
|
||
var absoluteExpiration = GetAbsoluteExpiration(utcNow, options); | ||
ValidateOptions(options.SlidingExpiration, absoluteExpiration); | ||
|
||
var cmdText = _sqlCommands.SetCacheItem; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
command.Parameters.Add(new MySqlParameter("@Value", MySqlDbType.Blob) { Value = value }); | ||
command.Parameters.Add(new MySqlParameter("@UtcNow", MySqlDbType.Timestamp) { Value = utcNow.UtcDateTime }); | ||
command.Parameters.Add(new MySqlParameter("@SlidingExpiration", MySqlDbType.Time) { Value = (object?)options.SlidingExpiration ?? DBNull.Value }); | ||
command.Parameters.Add(new MySqlParameter("@AbsoluteExpiration", MySqlDbType.Timestamp) { Value = (object?)absoluteExpiration?.UtcDateTime ?? DBNull.Value }); | ||
|
||
await connection.OpenAsync(token).ConfigureAwait(false); | ||
|
||
await command.ExecuteNonQueryAsync(token).ConfigureAwait(false); | ||
} | ||
|
||
public void RefreshCacheItem(string key) | ||
{ | ||
var cmdText = _sqlCommands.RefreshCacheItem; | ||
var utcNow = _systemClock.UtcNow; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
command.Parameters.Add(new MySqlParameter("@UtcNow", MySqlDbType.Timestamp) { Value = utcNow.UtcDateTime }); | ||
|
||
connection.Open(); | ||
|
||
command.ExecuteNonQuery(); | ||
} | ||
|
||
public async Task RefreshCacheItemAsync(string key, CancellationToken token = default) | ||
{ | ||
token.ThrowIfCancellationRequested(); | ||
|
||
var cmdText = _sqlCommands.RefreshCacheItem; | ||
var utcNow = _systemClock.UtcNow; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
command.Parameters.Add(new MySqlParameter("@UtcNow", MySqlDbType.Timestamp) { Value = utcNow.UtcDateTime }); | ||
|
||
await connection.OpenAsync(token).ConfigureAwait(false); | ||
|
||
await command.ExecuteNonQueryAsync(token).ConfigureAwait(false); | ||
} | ||
|
||
public void DeleteCacheItem(string key) | ||
{ | ||
var cmdText = _sqlCommands.DeleteCacheItem; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
|
||
connection.Open(); | ||
|
||
command.ExecuteNonQuery(); | ||
} | ||
|
||
public async Task DeleteCacheItemAsync(string key, CancellationToken token = default) | ||
{ | ||
token.ThrowIfCancellationRequested(); | ||
|
||
var cmdText = _sqlCommands.DeleteCacheItem; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.VarString, DatabaseConsts.IdColumnSize) { Value = key }); | ||
|
||
await connection.OpenAsync(token).ConfigureAwait(false); | ||
|
||
await command.ExecuteNonQueryAsync(token).ConfigureAwait(false); | ||
} | ||
|
||
public async Task DeleteExpiredCacheItemsAsync(CancellationToken token = default) | ||
{ | ||
token.ThrowIfCancellationRequested(); | ||
|
||
var utcNow = _systemClock.UtcNow; | ||
|
||
var cmdText = _sqlCommands.DeleteExpiredCacheItems; | ||
|
||
using var connection = new MySqlConnection(_connectionString); | ||
using var command = new MySqlCommand(cmdText, connection); | ||
|
||
command.Parameters.Add(new MySqlParameter("@UtcNow", MySqlDbType.Timestamp) { Value = utcNow.UtcDateTime }); | ||
|
||
await connection.OpenAsync(token).ConfigureAwait(false); | ||
|
||
await command.ExecuteNonQueryAsync(token).ConfigureAwait(false); | ||
} | ||
|
||
private static DateTimeOffset? GetAbsoluteExpiration(DateTimeOffset utcNow, DistributedCacheEntryOptions options) | ||
{ | ||
if (options.AbsoluteExpirationRelativeToNow.HasValue) | ||
{ | ||
return utcNow.Add(options.AbsoluteExpirationRelativeToNow.Value); | ||
} | ||
|
||
if (options.AbsoluteExpiration.HasValue) | ||
{ | ||
if (options.AbsoluteExpiration.Value <= utcNow) | ||
{ | ||
throw new InvalidOperationException("The absolute expiration value must be in the future."); | ||
} | ||
|
||
return options.AbsoluteExpiration.Value; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private static void ValidateOptions(TimeSpan? slidingExpiration, DateTimeOffset? absoluteExpiration) | ||
{ | ||
if (!slidingExpiration.HasValue && !absoluteExpiration.HasValue) | ||
{ | ||
throw new InvalidOperationException("Either absolute or sliding expiration must be provided."); | ||
} | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/ScaledDomains.Extensions.Caching.MySql.MySqlConnector/InternalsVisibleTo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("ScaledDomains.Extensions.Caching.MySql.Tests")] | ||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] |
61 changes: 61 additions & 0 deletions
61
...edDomains.Extensions.Caching.MySql.MySqlConnector/MySqlServerCachingServicesExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using Microsoft.Extensions.Caching.Distributed; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace ScaledDomains.Extensions.Caching.MySql | ||
{ | ||
/// <summary> | ||
/// Extension methods for setting up MySQL Server distributed cache services in an <see cref="IServiceCollection" />. | ||
/// </summary> | ||
public static class MySqlServerCachingServicesExtensions | ||
{ | ||
/// <summary> | ||
/// Adds MySQL Server distributed caching services to the specified <see cref="IServiceCollection" />. | ||
/// </summary> | ||
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param> | ||
/// <param name="setupAction">An <see cref="Action{SqlServerCacheOptions}"/> to configure the provided <see cref="MySqlServerCacheOptions"/>.</param> | ||
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns> | ||
public static IServiceCollection AddDistributedMySqlServerCache(this IServiceCollection services, Action<MySqlServerCacheOptions> setupAction) | ||
{ | ||
if (services == null) | ||
{ | ||
throw new ArgumentNullException(nameof(services)); | ||
} | ||
|
||
if (setupAction == null) | ||
{ | ||
throw new ArgumentNullException(nameof(setupAction)); | ||
} | ||
|
||
services.AddOptions(); | ||
AddDistributedMySqlServerCache(services); | ||
services.Configure(setupAction); | ||
|
||
return services; | ||
} | ||
|
||
/// <summary> | ||
/// Adds MySQL Server distributed caching services to the specified <see cref="IServiceCollection" />. | ||
/// </summary> | ||
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param> | ||
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns> | ||
public static IServiceCollection AddDistributedMySqlServerCache(this IServiceCollection services) | ||
{ | ||
if (services == null) | ||
{ | ||
throw new ArgumentNullException(nameof(services)); | ||
} | ||
|
||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IValidateOptions<MySqlServerCacheOptions>, ValidateMySqlServerCacheOptions>()); | ||
services.TryAddSingleton<ISystemClock, SystemClock>(); | ||
services.TryAddSingleton<IDatabaseOperations, DatabaseOperations>(); | ||
services.AddSingleton<IDistributedCache, MySqlServerCache>(); | ||
|
||
services.AddHostedService<MySqlServerCacheMaintenanceService>(); | ||
|
||
return services; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...Caching.MySql.MySqlConnector/ScaledDomains.Extensions.Caching.MySql.MySqlConnector.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<LangVersion>Latest</LangVersion> | ||
<Nullable>Enable</Nullable> | ||
<PackageDescription>ScaledDomains.Extensions.Caching.MySql.MySqlConnector is a free, open source distributed cache implementation using MySql as datastore using MySqlConnector.</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" /> | ||
<PackageReference Include="MySqlConnector" Version="2.3.6" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="../../README.md" Pack="true" PackagePath="/" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ScaledDomains.Extensions.Caching.MySql.Core\ScaledDomains.Extensions.Caching.MySql.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
46 changes: 46 additions & 0 deletions
46
src/ScaledDomains.Extensions.Caching.MySql.MySqlConnector/SqlCommands.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace ScaledDomains.Extensions.Caching.MySql | ||
{ | ||
internal sealed class SqlCommands | ||
{ | ||
internal SqlCommands(string schemaName, string tableName) | ||
{ | ||
var fullName = $"`{schemaName}`.`{tableName}`"; | ||
|
||
GetCacheItem = string.Format(UpdateCacheItemFormat + GetCacheItemFormat, fullName); | ||
SetCacheItem = string.Format(SetCacheItemFormat, fullName); | ||
RefreshCacheItem = string.Format(UpdateCacheItemFormat, fullName); | ||
DeleteCacheItem = string.Format(DeleteCacheItemFormat, fullName); | ||
DeleteExpiredCacheItems = string.Format(DeleteExpiredCacheItemsFormat, fullName); | ||
} | ||
|
||
private const string GetCacheItemFormat = | ||
"SELECT Value FROM {0} WHERE Id = @Id AND ExpiresAt >= @UtcNow; "; | ||
|
||
private const string UpdateCacheItemFormat = | ||
"UPDATE {0} SET ExpiresAt = (CASE WHEN (SlidingExpiration IS NUll) THEN AbsoluteExpiration ELSE ADDTIME(@UtcNow, SlidingExpiration) END) " + | ||
"WHERE Id = @Id AND ExpiresAt >= @UtcNow AND SlidingExpiration IS NOT NULL AND (AbsoluteExpiration IS NULL OR AbsoluteExpiration >= ExpiresAt); "; | ||
|
||
private const string SetCacheItemFormat = | ||
"INSERT INTO {0} (Id, Value, ExpiresAt, SlidingExpiration, AbsoluteExpiration) VALUES (@Id, @Value, CASE WHEN (@SlidingExpiration IS NUll) THEN @AbsoluteExpiration ELSE ADDTIME(@UtcNow, @SlidingExpiration) END, @SlidingExpiration, @AbsoluteExpiration) " + | ||
"ON DUPLICATE KEY UPDATE " + | ||
"Value = @Value, " + | ||
"ExpiresAt = (CASE WHEN (@SlidingExpiration IS NUll) THEN @AbsoluteExpiration ELSE ADDTIME(@UtcNow, @SlidingExpiration) END), "+ | ||
"SlidingExpiration = @SlidingExpiration, "+ | ||
"AbsoluteExpiration = @AbsoluteExpiration;"; | ||
|
||
private const string DeleteCacheItemFormat = | ||
"DELETE FROM {0} WHERE Id = @Id"; | ||
|
||
public const string DeleteExpiredCacheItemsFormat = "DELETE FROM {0} WHERE ExpiresAt < @UtcNow"; | ||
|
||
internal readonly string GetCacheItem; | ||
|
||
internal readonly string SetCacheItem; | ||
|
||
internal readonly string RefreshCacheItem; | ||
|
||
internal readonly string DeleteCacheItem; | ||
|
||
internal readonly string DeleteExpiredCacheItems; | ||
} | ||
} |
458 changes: 458 additions & 0 deletions
458
src/ScaledDomains.Extensions.Caching.MySql.MySqlConnector/packages.lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters