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

39 lines
1.1 KiB
C#

11 months ago
using CacheInterface;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapr.AspNetCore;
using Microsoft.Extensions.Caching.Memory;
using Google.Protobuf.WellKnownTypes;
using CommonExtend;
using Dapr.Client;
using Microsoft.Extensions.Logging;
using System.Text.Json;
namespace CacheService
{
public static class CacheServiceExtend
{
public static IServiceCollection InitRedisCacheService(this IServiceCollection services, string url)
{
services.AddSingleton<ICacheService, RedisCacheService>((_services) =>
{
return new RedisCacheService(_services, url);
});
return services;
}
public static IServiceCollection InitMemoryCacheService(this IServiceCollection services)
{
services.AddSingleton<ICacheService, MemoryCacheService>((_services) =>
{
return new MemoryCacheService(_services);
});
return services;
}
}
}