mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Added redis caching libraries and implemented for user by id caching.
This commit is contained in:
@ -18,6 +18,8 @@ using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Repos = Bit.Core.Repositories.SqlServer;
|
||||
using System.Text;
|
||||
using StackExchange.Redis.Extensions.Core;
|
||||
using StackExchange.Redis.Extensions.Protobuf;
|
||||
//using Loggr.Extensions.Logging;
|
||||
|
||||
namespace Bit.Api
|
||||
@ -55,9 +57,16 @@ namespace Bit.Api
|
||||
ConfigurationBinder.Bind(Configuration.GetSection("GlobalSettings"), globalSettings);
|
||||
services.AddSingleton(s => globalSettings);
|
||||
|
||||
// Caching
|
||||
ISerializer serializer = new ProtobufSerializer();
|
||||
services.AddSingleton(s => serializer);
|
||||
ICacheClient cacheClient = new StackExchangeRedisCacheClient(serializer,
|
||||
globalSettings.Cache.ConnectionString, globalSettings.Cache.Database);
|
||||
services.AddSingleton(s => cacheClient);
|
||||
|
||||
// Repositories
|
||||
services.AddSingleton<IUserRepository>(s => new Repos.UserRepository(globalSettings.SqlServer.ConnectionString));
|
||||
services.AddSingleton<ICipherRepository>(s => new Repos.CipherRepository(globalSettings.SqlServer.ConnectionString));
|
||||
services.AddSingleton<IUserRepository, Repos.UserRepository>();
|
||||
services.AddSingleton<ICipherRepository, Repos.CipherRepository>();
|
||||
|
||||
// Context
|
||||
services.AddScoped<CurrentContext>();
|
||||
|
@ -1,18 +1,22 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"siteName": "bitwarden",
|
||||
"baseVaultUri": "http://localhost:4001",
|
||||
"jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)",
|
||||
"sqlServer": {
|
||||
"connectionString": "SECRET"
|
||||
},
|
||||
"mail": {
|
||||
"apiKey": "SECRET",
|
||||
"replyToEmail": "do-not-reply@bitwarden.com"
|
||||
},
|
||||
"loggr": {
|
||||
"logKey": "SECRET",
|
||||
"apiKey": "SECRET"
|
||||
}
|
||||
"globalSettings": {
|
||||
"siteName": "bitwarden",
|
||||
"baseVaultUri": "http://localhost:4001",
|
||||
"jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)",
|
||||
"sqlServer": {
|
||||
"connectionString": "SECRET"
|
||||
},
|
||||
"mail": {
|
||||
"apiKey": "SECRET",
|
||||
"replyToEmail": "do-not-reply@bitwarden.com"
|
||||
},
|
||||
"loggr": {
|
||||
"logKey": "SECRET",
|
||||
"apiKey": "SECRET"
|
||||
},
|
||||
"cache": {
|
||||
"connectionString": "SECRET.COM:6380,password=SECRET,ssl=True,abortConnect=False",
|
||||
"database": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user