Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Caching/SqlServer/src/DatabaseOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public void DeleteCacheItem(string key)
}
}

public virtual byte[] GetCacheItem(string key)
public virtual byte[]? GetCacheItem(string key)
{
return GetCacheItem(key, includeValue: true);
}

public virtual async Task<byte[]> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken))
public virtual async Task<byte[]?> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken))
{
token.ThrowIfCancellationRequested();

Expand Down Expand Up @@ -194,7 +194,7 @@ public virtual void SetCacheItem(string key, byte[] value, DistributedCacheEntry
}
}

protected virtual byte[] GetCacheItem(string key, bool includeValue)
protected virtual byte[]? GetCacheItem(string key, bool includeValue)
{
var utcNow = SystemClock.UtcNow;

Expand All @@ -208,7 +208,7 @@ protected virtual byte[] GetCacheItem(string key, bool includeValue)
query = SqlQueries.GetCacheItemWithoutValue;
}

byte[] value = null;
byte[]? value = null;
using (var connection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(query, connection))
{
Expand Down Expand Up @@ -238,7 +238,7 @@ protected virtual byte[] GetCacheItem(string key, bool includeValue)
return value;
}

protected virtual async Task<byte[]> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
protected virtual async Task<byte[]?> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
{
token.ThrowIfCancellationRequested();

Expand All @@ -254,7 +254,7 @@ protected virtual byte[] GetCacheItem(string key, bool includeValue)
query = SqlQueries.GetCacheItemWithoutValue;
}

byte[] value = null;
byte[]? value = null;
using (var connection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(query, connection))
{
Expand Down
4 changes: 2 additions & 2 deletions src/Caching/SqlServer/src/IDatabaseOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace Microsoft.Extensions.Caching.SqlServer;

internal interface IDatabaseOperations
{
byte[] GetCacheItem(string key);
byte[]? GetCacheItem(string key);

Task<byte[]> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken));
Task<byte[]?> GetCacheItemAsync(string key, CancellationToken token = default(CancellationToken));

void RefreshCacheItem(string key);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Distributed cache implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache using Microsoft SQL Server.</Description>
Expand All @@ -9,7 +9,6 @@
<NoWarn>$(NoWarn);PKG0001</NoWarn>
<IsPackable>true</IsPackable>
<IsShipping>true</IsShipping>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Caching/SqlServer/src/MonoDatabaseOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public MonoDatabaseOperations(
{
}

protected override byte[] GetCacheItem(string key, bool includeValue)
protected override byte[]? GetCacheItem(string key, bool includeValue)
{
var utcNow = SystemClock.UtcNow;

Expand All @@ -32,7 +32,7 @@ protected override byte[] GetCacheItem(string key, bool includeValue)
query = SqlQueries.GetCacheItemWithoutValue;
}

byte[] value = null;
byte[]? value = null;
using (var connection = new SqlConnection(ConnectionString))
{
var command = new SqlCommand(query, connection);
Expand Down Expand Up @@ -60,7 +60,7 @@ protected override byte[] GetCacheItem(string key, bool includeValue)
return value;
}

protected override async Task<byte[]> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
protected override async Task<byte[]?> GetCacheItemAsync(string key, bool includeValue, CancellationToken token = default(CancellationToken))
{
token.ThrowIfCancellationRequested();

Expand All @@ -76,7 +76,7 @@ protected override byte[] GetCacheItem(string key, bool includeValue)
query = SqlQueries.GetCacheItemWithoutValue;
}

byte[] value = null;
byte[]? value = null;
using (var connection = new SqlConnection(ConnectionString))
{
var command = new SqlCommand(query, connection);
Expand Down
36 changes: 18 additions & 18 deletions src/Caching/SqlServer/src/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#nullable enable
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Get(string key) -> byte[]
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.GetAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<byte[]>
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Refresh(string key) -> void
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RefreshAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Remove(string key) -> void
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RemoveAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Set(string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options) -> void
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SetAsync(string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
~Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SqlServerCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions> options) -> void
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.get -> string
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.set -> void
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.get -> string
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.set -> void
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.get -> Microsoft.Extensions.Internal.ISystemClock
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string
~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void
~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions> setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Get(string! key) -> byte[]?
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.GetAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<byte[]?>!
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Refresh(string! key) -> void
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RefreshAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Remove(string! key) -> void
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RemoveAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Set(string! key, byte[]! value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions! options) -> void
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SetAsync(string! key, byte[]! value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions! options, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
Microsoft.Extensions.Caching.SqlServer.SqlServerCache.SqlServerCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions!>! options) -> void
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.get -> string?
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.ConnectionString.set -> void
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.get -> string?
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SchemaName.set -> void
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.get -> Microsoft.Extensions.Internal.ISystemClock!
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string?
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void
static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions!>! setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
Microsoft.Extensions.Caching.SqlServer.SqlServerCache
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions
Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.DefaultSlidingExpiration.get -> System.TimeSpan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static SqlParameterCollection AddCacheItemId(this SqlParameterCollection
return parameters.AddWithValue(Columns.Names.CacheItemId, SqlDbType.NVarChar, CacheItemIdColumnWidth, value);
}

public static SqlParameterCollection AddCacheItemValue(this SqlParameterCollection parameters, byte[] value)
public static SqlParameterCollection AddCacheItemValue(this SqlParameterCollection parameters, byte[]? value)
{
if (value != null && value.Length < DefaultValueColumnWidth)
{
Expand Down Expand Up @@ -74,7 +74,7 @@ public static SqlParameterCollection AddWithValue(
this SqlParameterCollection parameters,
string parameterName,
SqlDbType dbType,
object value)
object? value)
{
var parameter = new SqlParameter(parameterName, dbType);
parameter.Value = value;
Expand All @@ -88,7 +88,7 @@ public static SqlParameterCollection AddWithValue(
string parameterName,
SqlDbType dbType,
int size,
object value)
object? value)
{
var parameter = new SqlParameter(parameterName, dbType, size);
parameter.Value = value;
Expand Down
4 changes: 2 additions & 2 deletions src/Caching/SqlServer/src/SqlServerCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public SqlServerCache(IOptions<SqlServerCacheOptions> options)
}

/// <inheritdoc />
public byte[] Get(string key)
public byte[]? Get(string key)
{
if (key == null)
{
Expand All @@ -107,7 +107,7 @@ public byte[] Get(string key)
}

/// <inheritdoc />
public async Task<byte[]> GetAsync(string key, CancellationToken token = default(CancellationToken))
public async Task<byte[]?> GetAsync(string key, CancellationToken token = default(CancellationToken))
{
if (key == null)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Caching/SqlServer/src/SqlServerCacheOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SqlServerCacheOptions : IOptions<SqlServerCacheOptions>
/// <summary>
/// An abstraction to represent the clock of a machine in order to enable unit testing.
/// </summary>
public ISystemClock SystemClock { get; set; }
public ISystemClock SystemClock { get; set; } = new SystemClock();

/// <summary>
/// The periodic interval to scan and delete expired items in the cache. Default is 30 minutes.
Expand All @@ -25,17 +25,17 @@ public class SqlServerCacheOptions : IOptions<SqlServerCacheOptions>
/// <summary>
/// The connection string to the database.
/// </summary>
public string ConnectionString { get; set; }
public string? ConnectionString { get; set; }

/// <summary>
/// The schema name of the table.
/// </summary>
public string SchemaName { get; set; }
public string? SchemaName { get; set; }

/// <summary>
/// Name of the table where the cache items are stored.
/// </summary>
public string TableName { get; set; }
public string? TableName { get; set; }

/// <summary>
/// The default sliding expiration set for a cache entry if neither Absolute or SlidingExpiration has been set explicitly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<IsPackable>true</IsPackable>
<IsShipping>true</IsShipping>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
40 changes: 20 additions & 20 deletions src/Caching/StackExchangeRedis/src/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#nullable enable
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Get(string key) -> byte[]
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<byte[]>
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.RedisCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions> optionsAccessor) -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Refresh(string key) -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.RefreshAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Remove(string key) -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.RemoveAsync(string key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Set(string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options) -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.SetAsync(string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.Configuration.get -> string
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.Configuration.set -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConfigurationOptions.get -> StackExchange.Redis.ConfigurationOptions
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConfigurationOptions.set -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConnectionMultiplexerFactory.get -> System.Func<System.Threading.Tasks.Task<StackExchange.Redis.IConnectionMultiplexer>>
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConnectionMultiplexerFactory.set -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.InstanceName.get -> string
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.InstanceName.set -> void
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ProfilingSession.get -> System.Func<StackExchange.Redis.Profiling.ProfilingSession>
~Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ProfilingSession.set -> void
~static Microsoft.Extensions.DependencyInjection.StackExchangeRedisCacheServiceCollectionExtensions.AddStackExchangeRedisCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions> setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Get(string! key) -> byte[]?
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<byte[]?>!
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.RedisCache(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions!>! optionsAccessor) -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Refresh(string! key) -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.RefreshAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Remove(string! key) -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.RemoveAsync(string! key, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Set(string! key, byte[]! value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions! options) -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.SetAsync(string! key, byte[]! value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions! options, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.Configuration.get -> string?
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.Configuration.set -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConfigurationOptions.get -> StackExchange.Redis.ConfigurationOptions?
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConfigurationOptions.set -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConnectionMultiplexerFactory.get -> System.Func<System.Threading.Tasks.Task<StackExchange.Redis.IConnectionMultiplexer!>!>?
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ConnectionMultiplexerFactory.set -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.InstanceName.get -> string?
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.InstanceName.set -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ProfilingSession.get -> System.Func<StackExchange.Redis.Profiling.ProfilingSession!>?
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions.ProfilingSession.set -> void
static Microsoft.Extensions.DependencyInjection.StackExchangeRedisCacheServiceCollectionExtensions.AddStackExchangeRedisCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions!>! setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Dispose() -> void
Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions
Expand Down
Loading