//private readonly ILogger<CacheProvider> _looger; public CacheProvider(IEasyCachingProviderFactory easyCachingProviderFactory, ISerializer serializer /*, ILogger<CacheProvider> logger*/) { this._cachingProvider = easyCachingProviderFactory; this._provider = this._cachingProvider.GetRedisProvider("redis"); this._serializer = serializer; //this._looger = logger; }
public MessageController(ILuisService luis, IAnswerService answerService, IUnknownService issueService, IRedisCachingProvider redis, DingTalkHelper ddHelper, IDepartmentService departmentService, IPermissionService permissionService, IConfiguration configuration, IFeedbackService feedbackService, IAppSettings settings, ILogger <MessageController> logger, KnowledgeMapContext mapContext, DingDingApprovalService dingDingApprovalService) { _logger = logger; _settings = settings; _ddHelper = ddHelper; _configuration = configuration; _ddApprovalService = dingDingApprovalService; _luis = luis; _answerService = answerService; _issueService = issueService; _departService = departmentService; _redis = redis; _feedbackService = feedbackService; _permissionService = permissionService; _httpClient = HttpClientFactory.Create(); _mapContext = mapContext; }
public CfgAppService(IMapper mapper , IEfRepository <SysCfg> cfgRepository , ISystemManagerService systemManagerService , IEasyCachingProviderFactory factory) { _mapper = mapper; _cfgRepository = cfgRepository; _systemManagerService = systemManagerService; _redis = factory.GetRedisProvider(EasyCachingConsts.RemoteCaching); }
/// <summary> /// Initializes a new instance of the <see cref="FilterEasyCachingRedis"/> class. /// </summary> /// <param name="name"></param> /// <param name="provider">The <see cref="IRedisCachingProvider"/>.</param> /// <param name="redisKey">The redisKey.</param> /// <param name="expectedElements">The expected elements.</param> /// <param name="errorRate">The error rate.</param> /// <param name="hashFunction">The hash function.</param> public FilterEasyCachingRedis(string name, IRedisCachingProvider provider, string redisKey, int expectedElements, double errorRate, HashFunction hashFunction) : base(name, expectedElements, errorRate, hashFunction) { if (string.IsNullOrWhiteSpace(redisKey)) { throw new ArgumentException(nameof(redisKey)); } _provider = provider ?? throw new ArgumentNullException(nameof(provider)); _redisKey = redisKey; }
public AuthController( ILogger <AuthController> logger, IHttpClientFactory httpClientFactory, IEasyCachingProvider provider, IEasyCachingProviderFactory providerFactory ) { _logger = logger; _httpClientFactory = httpClientFactory; this._provider = provider; this._redisProvider = providerFactory.GetRedisProvider("redis1"); }
public ArtificialServices(IRedisCachingProvider redis, ILogger <ArtificialServices> logger, IServiceRecordService record, IChatService chat, IHubContext <ArtificialServicesHub> hub) { _redis = redis; _logger = logger; _hub = hub; _record = record; _chat = chat; }
public StatisticsMatchIntentCountTask(IRedisCachingProvider redis, IConfiguration configuration, ILogger <StatisticsMatchIntentCountTask> logger) { _redis = redis; _logger = logger; var connection = configuration.GetConnectionString("DefaultConnection"); var options = new DbContextOptionsBuilder <MoMoDbContext>() .UseNpgsql(connection) .Options; _dbContext = new MoMoDbContext(options); }
public ValuesController( ILogger <ValuesController> logger, IHttpClientFactory httpClientFactory, IEasyCachingProvider provider, IEasyCachingProviderFactory providerFactory, BookServices bookService ) { _logger = logger; _httpClientFactory = httpClientFactory; this._provider = provider; this._redisProvider = providerFactory.GetRedisProvider("redis1"); _bookService = bookService; }
public ChatController(TokenValidationParameters validationParameters, IChatService chat, DingTalkHelper ddHelper, IRedisCachingProvider redis, IServiceRecordService record, IOptions <DTalkConfig> options) { _ddHelper = ddHelper; _record = record; _redis = redis; _validationParameters = validationParameters; _chat = chat; _ddConfig = options.Value ?? throw new ArgumentNullException(nameof(_ddConfig)); }
public EasyCachingCacheManager(IOptionsSnapshot <EasyCachingOptions> options, IServiceProvider serviceProvider) { serviceProvider.NotNull(nameof(serviceProvider)); _options = options.NotNull(nameof(options)).Value; //Initialize cache provider based on ProviderType (InMemory/Redis or Hybrid) switch (_options.ProviderType) { case CachingProviderType.InMemory: _easyCachingProvider = serviceProvider.GetRequiredService <IEasyCachingProvider>(); break; case CachingProviderType.Redis: _easyCachingProvider = serviceProvider.GetRequiredService <IEasyCachingProvider>(); _redisCachingProvider = serviceProvider.GetRequiredService <IRedisCachingProvider>(); break; case CachingProviderType.Disabled: default: throw new InvalidOperationException("Caching is disabled."); } }
public ProviderFactoryTests() { IServiceCollection services = new ServiceCollection(); services.AddEasyCaching(option => { option.UseRedis(config => { config.DBConfig = new RedisDBOptions { AllowAdmin = true }; config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6380)); config.DBConfig.Database = 12; }, "redis1"); option.UseCSRedis(config => { config.DBConfig = new CSRedisDBOptions { ConnectionStrings = new System.Collections.Generic.List <string> { "127.0.0.1:6388,defaultDatabase=12,poolsize=10" } }; }, "redis2"); }); IServiceProvider serviceProvider = services.BuildServiceProvider(); var factory = serviceProvider.GetService <IEasyCachingProviderFactory>(); _e1 = factory.GetCachingProvider("redis1"); _e2 = factory.GetCachingProvider("redis2"); _r1 = factory.GetRedisProvider("redis1"); _r2 = factory.GetRedisProvider("redis2"); }
public MultiRedisController(IEasyCachingProviderFactory factory) { this._redis1 = factory.GetRedisProvider("redis1"); this._redis2 = factory.GetRedisProvider("redis2"); }
/// <summary> /// 初始化一个<see cref="CacheManager"/>类型的实例 /// </summary> /// <param name="provider">EasyCaching缓存提供器</param> public EasyCacheManager(IEasyCachingProvider provider, IRedisCachingProvider redisCachingProvider) { _provider = provider; _redisCachingProvider = redisCachingProvider; }
public ShipmentOrderUniqueNumberGenerator( //IShipmentOrderRepository shipmentOrderRepository, IRedisCachingProvider redisCachingProvider) : base(redisCachingProvider) { //_shipmentOrderRepository = shipmentOrderRepository; }
public static void StartService() { try { // XTrace.UseConsole(true,false); #region init dynamic type = (new Program()).GetType(); string currentDirectory = Path.GetDirectoryName(type.Assembly.Location); var services = new ServiceCollection(); var builder = new ConfigurationBuilder() .SetBasePath(currentDirectory) .AddJsonFile("appsettings.json", true, reloadOnChange: true); var configuration = builder.Build(); services.AddSingleton <IConfiguration>(configuration); Logger.Create(configuration, new LoggerFactory(), "Dtsc.NodeService"); var redisConn = configuration.GetSection("AppSettings").GetSection("Dtsc").GetValue <string>("RedisConn", "127.0.0.1"); var redisPort = configuration.GetSection("AppSettings").GetSection("Dtsc").GetValue <int>("RedisPort", 6379); var redisPwd = configuration.GetSection("AppSettings").GetSection("Dtsc").GetValue <string>("RedisPwd", "****"); var nodeId = configuration.GetSection("AppSettings").GetValue <int>("NodeId", 0); JobHelper.JobPath = configuration.GetSection("AppSettings").GetValue <string>("JobPath", "\\Yunt.Jobs"); XTrace.Log.Level = (LogLevel)configuration.GetSection("AppSettings").GetValue <int>("LogLevel", 3); var performanceInverval = configuration.GetSection("AppSettings").GetValue <int>("PerformanceInverval", 60); if (redisConn.IsNullOrWhiteSpace() || redisPwd.IsNullOrWhiteSpace() || nodeId == 0) { //todo 可写入初始配置 Logger.Error($"[Device]:appsettings not entirely!"); Logger.Error($"please write Device service's settings into appsettings! \n exp:\"Device\":{{\"RedisConn\":\"***\"," + $"\"MySqlConn\":\"***\"}}"); new TbError() { Createtime = DateTime.Now.TimeSpan(), JobID = 0, Msg = $"Error:appsettings not entirely" }.SaveAsync(); } services.AddDefaultRedisCache(option => { option.RedisServer.Add(new HostItem() { Host = redisConn + ":" + redisPort }); option.SingleMode = true; option.Password = redisPwd; }); _redisProvider = ServiceProviderServiceExtensions.GetService <IRedisCachingProvider>(services.BuildServiceProvider()); //#if DEBUG XTrace.UseConsole(); //#endif #endregion var ip = HostHelper.GetExtenalIpAddress(); var node = TbNode.Find("ID", nodeId); if (node != null) { if (!ip.IsNullOrWhiteSpace()) { node.Ip = ip; } node.SaveAsync(); } //恢复所有运行job ResumeJob(nodeId); using (var p = Process.GetCurrentProcess()) { //断线重连 while (true) { if (_isStop) { return; } try { if (_timer == null) { _timer = new TimerX(obj => { ListenCmd(nodeId); }, null, 500, 100); } if (_performanceTimer == null) { _performanceTimer = new TimerX(obj => { Performance(p, performanceInverval, nodeId); }, null, 1000, performanceInverval * 1000); } } catch (Exception e) { _timer?.Dispose(); _performanceTimer?.Dispose(); new TbError() { Createtime = DateTime.Now.TimeSpan(), JobID = 0, Msg = $"Error:{e.Message},错误详情,请查看节点服务日志!" }.SaveAsync(); Logger.Exception(e); } } } } catch (Exception e) { new TbError() { Createtime = DateTime.Now.TimeSpan(), JobID = 0, Msg = $"Error:{e.Message},错误详情,请查看节点服务日志!" }.SaveAsync(); Logger.Exception(e); } }
public AreaController(ILoggerFactory loggerFactory, IRedisCachingProvider provider) { _logger = loggerFactory.CreateLogger <AreaController>(); _provider = provider; }
/// <summary> /// 初始化一个<see cref="VerifyCodeService"/>类型的新实例 /// </summary> public VerifyCodeService(IEasyCachingProviderFactory factory) { _cache = factory.GetRedisProvider("redis2"); }
protected AbstractNumberGenerator(IRedisCachingProvider provider) { _redisCachingProvider = provider; }
public EasyCachingRedisCache(IRedisCachingProvider provider) { _provider = provider; }
public CalculatiionController(ILoggerFactory loggerFactory, IRedisCachingProvider provider) { _logger = loggerFactory.CreateLogger <CalculatiionController>(); _provider = provider; }