mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[PM-5518] Sql-backed IDistributedCache (#3791)
* Sql-backed IDistributedCache * sqlserver cache table * remove unused using * setup EF entity * cache indexes * add back cipher * revert SetupEntityFramework change * ef cache * EntityFrameworkCache * IServiceScopeFactory for db context * implement EntityFrameworkCache * move to _serviceScopeFactory * move to config file * ef migrations * fixes * datetime and error codes * revert migrations * migrations * format * static and namespace fix * use time provider * Move SQL migration and remove EF one for the moment * Add clean migration of just the new table * Formatting * Test Custom `IDistributedCache` Implementation * Add Back Logging * Remove Double Logging * Skip Test When Not EntityFrameworkCache * Format --------- Co-authored-by: Matt Bishop <mbishop@bitwarden.com> Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
2671
util/MySqlMigrations/Migrations/20240702142224_DistributedCache.Designer.cs
generated
Normal file
2671
util/MySqlMigrations/Migrations/20240702142224_DistributedCache.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,42 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.MySqlMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class DistributedCache : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "varchar(449)", maxLength: 449, nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Value = table.Column<byte[]>(type: "longblob", nullable: true),
|
||||
ExpiresAtTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
SlidingExpirationInSeconds = table.Column<long>(type: "bigint", nullable: true),
|
||||
AbsoluteExpiration = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cache", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cache_ExpiresAtTime",
|
||||
table: "Cache",
|
||||
column: "ExpiresAtTime");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cache");
|
||||
}
|
||||
}
|
@ -755,6 +755,33 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.ToTable("ProviderPlan", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Cache", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasMaxLength(449)
|
||||
.HasColumnType("varchar(449)");
|
||||
|
||||
b.Property<DateTime?>("AbsoluteExpiration")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime>("ExpiresAtTime")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<long?>("SlidingExpirationInSeconds")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<byte[]>("Value")
|
||||
.HasColumnType("longblob");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasAnnotation("SqlServer:Clustered", true);
|
||||
|
||||
b.HasIndex("ExpiresAtTime")
|
||||
.HasAnnotation("SqlServer:Clustered", false);
|
||||
|
||||
b.ToTable("Cache", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Bit.Infrastructure.EntityFramework.Models.Collection", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
Reference in New Issue
Block a user