예제 #1
0
 public static IServiceCollection AddDapperCachingInRedis <TCacheKeyBuilder>(this IServiceCollection service, RedisConfiguration config) where TCacheKeyBuilder : ICacheKeyBuilder
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     service.AddSingleton(typeof(ICacheKeyBuilder), typeof(TCacheKeyBuilder));
     return(service.AddDapperCachingInRedis(new CacheConfiguration
     {
         AllMethodsEnableCache = config.AllMethodsEnableCache,
         Expire = config.Expire,
         KeyPrefix = config.KeyPrefix
     }, new CSRedisClient(config.ConnectionString)));
 }
예제 #2
0
 public static IServiceCollection AddDapperCachingInRedis(this IServiceCollection service, RedisConfiguration config)
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     return(service.AddDapperCachingInRedis(new CacheConfiguration
     {
         AllMethodsEnableCache = config.AllMethodsEnableCache,
         Expire = config.Expire,
         KeyPrefix = config.KeyPrefix
     }, new CSRedisClient(config.ConnectionString)));
 }
예제 #3
0
        public static ContainerBuilder AddDapperCachingForRedis(this ContainerBuilder service, RedisConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            service.RegisterType <DefaultCacheKeyBuilder>().As <ICacheKeyBuilder>().SingleInstance();
            service.RegisterInstance(new CacheConfiguration
            {
                AllMethodsEnableCache = config.AllMethodsEnableCache,
                Expire    = config.Expire,
                KeyPrefix = config.KeyPrefix
            }).SingleInstance();

            service.RegisterInstance(new RedisClient(config.ConnectionString)).SingleInstance();
            service.RegisterType <RedisCacheProvider>().As <ICacheProvider>().SingleInstance();
            service.RegisterType <DataSerializer>().As <IDataSerializer>().SingleInstance();
            return(service);
        }
 public static ContainerBuilder AddDapperCachingInRedis <TCacheKeyBuilder>(this ContainerBuilder service, RedisConfiguration config) where TCacheKeyBuilder : ICacheKeyBuilder
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     service.RegisterType <TCacheKeyBuilder>().As <ICacheKeyBuilder>().SingleInstance();
     service.RegisterInstance(new CacheConfiguration
     {
         AllMethodsEnableCache = config.AllMethodsEnableCache,
         Expire = config.Expire
     }).SingleInstance();
     RedisHelper.Initialization(new CSRedisClient(config.ConnectionString));
     service.RegisterType <RedisCacheProvider>().As <ICacheProvider>().SingleInstance();
     service.RegisterType <DataSerializer>().As <IDataSerializer>().SingleInstance();
     return(service);
 }
 public static IServiceCollection AddDapperCachingInRedis <TCacheKeyBuilder>(this IServiceCollection service, RedisConfiguration config) where TCacheKeyBuilder : ICacheKeyBuilder
 {
     if (config == null)
     {
         throw new ArgumentNullException(nameof(config));
     }
     service.AddSingleton(typeof(ICacheKeyBuilder), typeof(TCacheKeyBuilder));
     service.AddSingleton(new CacheConfiguration
     {
         AllMethodsEnableCache = config.AllMethodsEnableCache,
         Expire = config.Expire
     });
     RedisHelper.Initialization(new CSRedisClient(config.ConnectionString));
     service.AddSingleton <ICacheProvider, RedisCacheProvider>();
     service.AddSingleton <IDataSerializer, DataSerializer>();
     return(service);
 }