1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-16 07:07:32 -05:00

[PM-2943] Enable Nullable Repositories in Unowned Files (#4549)

* Enable Nullable In Unowned Repos

* Update More Tests

* Move to One If

* Fix Collections

* Format

* Add Migrations

* Move Pragma Annotation

* Add Better Assert Message
This commit is contained in:
Justin Baur
2024-07-24 09:48:09 -04:00
committed by GitHub
parent b5f09c599b
commit 1e0182008b
67 changed files with 8432 additions and 119 deletions

View File

@ -4,13 +4,15 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.DependencyInjection;
#nullable enable
namespace Bit.Infrastructure.EntityFramework;
public class EntityFrameworkCache : IDistributedCache
{
#if DEBUG
// Used for debugging in tests
public Task scanTask;
public Task? scanTask;
#endif
private static readonly TimeSpan _defaultSlidingExpiration = TimeSpan.FromMinutes(20);
private static readonly TimeSpan _expiredItemsDeletionInterval = TimeSpan.FromMinutes(30);
@ -22,14 +24,14 @@ public class EntityFrameworkCache : IDistributedCache
public EntityFrameworkCache(
IServiceScopeFactory serviceScopeFactory,
TimeProvider timeProvider = null)
TimeProvider? timeProvider = null)
{
_deleteExpiredCachedItemsDelegate = DeleteExpiredCacheItems;
_serviceScopeFactory = serviceScopeFactory;
_timeProvider = timeProvider ?? TimeProvider.System;
}
public byte[] Get(string key)
public byte[]? Get(string key)
{
ArgumentNullException.ThrowIfNull(key);
@ -53,7 +55,7 @@ public class EntityFrameworkCache : IDistributedCache
return cache?.Value;
}
public async Task<byte[]> GetAsync(string key, CancellationToken token = default)
public async Task<byte[]?> GetAsync(string key, CancellationToken token = default)
{
ArgumentNullException.ThrowIfNull(key);
token.ThrowIfCancellationRequested();
@ -181,7 +183,7 @@ public class EntityFrameworkCache : IDistributedCache
ScanForExpiredItemsIfRequired();
}
private Cache SetCache(Cache cache, string key, byte[] value, DistributedCacheEntryOptions options)
private Cache SetCache(Cache? cache, string key, byte[] value, DistributedCacheEntryOptions options)
{
var utcNow = _timeProvider.GetUtcNow().DateTime;