services.AddIdentityServer() .AddInMemoryIdentityResources(Config.GetIdentityResources()) .AddInMemoryApiResources(Config.GetApis()) .AddInMemoryClients(Config.GetClients()) .AddTestUsers(Config.GetUsers()) .AddOperationalStore(options => { options.EnableTokenCleanup = true; options.TokenCleanupInterval = 3600; });
services.AddIdentityServer() .AddInMemoryIdentityResources(Config.GetIdentityResources()) .AddInMemoryApiResources(Config.GetApis()) .AddInMemoryClients(Config.GetClients()) .AddOperationalStore(options => { options.ConfigureDbContext = builder => builder.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), sql => sql.MigrationsAssembly(typeof(Startup).Assembly.FullName)); options.EnableTokenCleanup = true; options.TokenCleanupInterval = 3600; });In this example, the `Entity Framework` store is used to persist operational data. The `ConfigureDbContext` option is used to configure the database connection string and migration assembly. The `EnableTokenCleanup` option is set to `true` to enable automatic removal of expired tokens, and the `TokenCleanupInterval` option is set to 3600 seconds (1 hour). Overall, the OperationalStoreOptions class in the IdentityServer4 package library provides convenient options for configuring persistent storage for operational data.