Camera Information System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
598 B

using StackExchange.Redis;
namespace Cis.Core;
public static class CacheSetup
{
/// <summary>
/// Redis 缓存注册
/// </summary>
/// <param name="services"></param>
public static void AddCache(this IServiceCollection services)
{
services.AddSingleton<IDatabase>(options =>
{
var redisOptions = App.GetOptions<RedisOptions>();
ConnectionMultiplexer multiplexer = ConnectionMultiplexer.Connect(redisOptions.ConnectionString);
IDatabase cache = multiplexer.GetDatabase();
return cache;
});
}
}