/// <summary> /// Redis建立连接池 /// </summary> private void CreateManagerByRedis() { // 读取Redis主机IP配置信息 // 有密码的格式:redis:[email protected]:6379 // 无密码的格式:127.0.0.1:6379 string[] redisMasterHosts = readWriteHosts.Split(','); // 如果Redis服务器是主从配置,则还需要读取Redis Slave机的IP配置信息 string[] redisSlaveHosts = null; if (!string.IsNullOrWhiteSpace(readOnlyHosts)) { redisSlaveHosts = readOnlyHosts.Split(','); } var redisClientManagerConfig = new RedisClientManagerConfig { MaxWritePoolSize = maxWritePoolSize, DefaultDb = defaultDb, AutoStart = true }; Manager = new PooledRedisClientManager(redisMasterHosts, redisSlaveHosts, redisClientManagerConfig) { PoolTimeout = 2000, ConnectTimeout = 1000 }; }
public RedisServerEvents(IRedisPubSubServer redisPubSub) { this.RedisPubSub = redisPubSub; this.clientsManager = redisPubSub.ClientsManager; redisPubSub.OnInit = OnInit; redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex); redisPubSub.OnMessage = HandleMessage; WaitBeforeNextRestart = TimeSpan.FromMilliseconds(2000); local = new MemoryServerEvents { NotifyJoin = HandleOnJoin, NotifyLeave = HandleOnLeave, NotifyHeartbeat = HandleOnHeartbeat, Serialize = HandleSerialize, }; var appHost = HostContext.AppHost; var feature = appHost != null ? appHost.GetPlugin<ServerEventsFeature>() : null; if (feature != null) { Timeout = feature.IdleTimeout; HouseKeepingInterval = feature.HouseKeepingInterval; OnSubscribe = feature.OnSubscribe; OnUnsubscribe = feature.OnUnsubscribe; NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions; } }
public RedisServerEvents(IRedisPubSubServer redisPubSub) { this.RedisPubSub = redisPubSub; this.clientsManager = redisPubSub.ClientsManager; redisPubSub.OnInit = OnInit; redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex); redisPubSub.OnMessage = HandleMessage; KeepAliveRetryAfterMs = 2000; local = new MemoryServerEvents { NotifyJoin = HandleOnJoin, NotifyLeave = HandleOnLeave, NotifyHeartbeat = HandleOnHeartbeat, Serialize = HandleSerialize, }; var appHost = HostContext.AppHost; var feature = appHost != null ? appHost.GetPlugin<ServerEventsFeature>() : null; if (feature != null) { Timeout = feature.IdleTimeout; OnSubscribe = feature.OnSubscribe; OnUnsubscribe = feature.OnUnsubscribe; NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions; } }
private static void UseClient(IRedisClientsManager manager, int clientNo) { var cacheManager = (IRedisClientCacheManager)manager; var host = ""; try { using (var client = cacheManager.GetReadOnlyCacheClient()) { host = ((IRedisClient)client).Host; Log("Client '{0}' is using '{1}'", clientNo, host); var testClientKey = "test:" + host + ":" + clientNo; client.Set(testClientKey, testData); var result = client.Get<string>(testClientKey) ?? ""; Log("\t{0} => {1} len {2} {3} len", testClientKey, testData.Length, testData.Length == result.Length ? "==" : "!=", result.Length); } } catch (NullReferenceException ex) { Log("NullReferenceException StackTrace: \n" + ex.StackTrace); } catch (Exception ex) { Log("\t[ERROR@{0}]: {1} => {2}", host, ex.GetType().Name, ex.Message); } }
public RedisTransientMessageFactory(int retryAttempts, TimeSpan? requestTimeOut, IRedisClientsManager clientsManager) { this.ClientsManager = clientsManager ?? new BasicRedisClientManager(); MessageService = new RedisTransientMessageService( retryAttempts, requestTimeOut, this); }
public EventStoreProjector(IEventStoreConnection connection, ITinyMessengerHub hub, IRedisClientsManager clientsManager) { _connection = connection; _clientsManager = clientsManager; _hub = hub; }
private static void UseClientAsync(IRedisClientsManager manager, int clientNo) { using (var client = manager.GetReadOnlyClient()) { UseClient(client, clientNo); } }
public ServiceStackRedis() { var connectionString = ConfigurationManager.AppSettings.Get("cache:redis"); if (String.IsNullOrWhiteSpace(connectionString)) { throw new Exception("AppSettings \"redis\" missing"); } _redisFactory = new BasicRedisClientManager(connectionString) { ConnectTimeout = 100 }; }
public static void ExecAs <T>(this IRedisClientsManager redisManager, Action <IRedisTypedClient <T> > lambda) { using (var redis = redisManager.GetClient()) { lambda(redis.As <T>()); } }
public ImageProcessor(IRedisClientsManager manager, TimeSpan timeout, Weights weights) { this.manager = manager; this.Timeout = timeout; this.Weights = weights; this.PlaytimeExpirey = TimeSpan.FromSeconds(30); }
public static void Exec(this IRedisClientsManager redisManager, Action <IRedisClient> lambda) { using (var redis = redisManager.GetClient()) { lambda(redis); } }
public static bool Exec(this IRedisClientsManager redisManager, Func <IRedisClient, bool> lambda) { using (var redis = redisManager.GetClient()) { return(lambda(redis)); } }
///<summary> /// Constructs a RedisCounter instance using rCMan as redis clients manager and cKey as the counter key. ///</summary> public RedisCounter(IRedisClientsManager rCMan, string cKey) { _RCManager = rCMan; Key = cKey; // set the counter initial value }
public static List <T> ExecAs <T>(this IRedisClientsManager redisManager, Func <IRedisTypedClient <T>, List <T> > lambda) { using (var redis = redisManager.GetClient()) { return(lambda(redis.As <T>())); } }
internal static IRedisClientsManager InitRedisClientManager(string clusterName, string clusterNodes, string redisConnectionString) { lock (SyncObj) { if (_redisClientsManager == null) { if (string.IsNullOrWhiteSpace(clusterName) || string.IsNullOrWhiteSpace(clusterNodes)) { _redisClientsManager = new RedisManagerPool(redisConnectionString); } else { var sentinelHosts = clusterNodes.Split(','); var sentinel = new RedisSentinel(sentinelHosts, clusterName); sentinel.HostFilter = host => redisConnectionString.Fmt(host); sentinel.RedisManagerFactory = (master, slaves) => new PooledRedisClientManager(master, slaves); _redisClientsManager = sentinel.Start(); } } } return(_redisClientsManager); }
public RedisDB() { if (redisManager == null) { redisManager = new PooledRedisClientManager(DbSelected, RedisConStr); } }
public WebCacheInstance() { //initialize ProdDefs = new List <ProdDef>(); Quotes = new List <Quote>(); mapper = MapperConfig.GetAutoMapperConfiguration().CreateMapper(); _redisClientsManager = YJYGlobal.PooledRedisClientsManager; //get value from Redis using (var redisClient = _redisClientsManager.GetClient()) { try { ProdDefs = redisClient.As <ProdDef>().GetAll(); Quotes = redisClient.As <Quote>().GetAll(); } catch (Exception e) { YJYGlobal.LogExceptionAsInfo(e); } } //set timer _timerProdDef = new Timer(UpdateProdDefs, null, _updateIntervalProdDef, TimeSpan.FromMilliseconds(-1)); _timerQuote = new Timer(UpdateQuotes, null, _updateIntervalQuote, TimeSpan.FromMilliseconds(-1)); }
public CachedRedisApiRepository(IRedisClientsManager redisClientManager, IApiRepository <T> innerRepository) { _redisClientManager = redisClientManager; _cacheClient = _redisClientManager.GetCacheClient(); _innerRepository = innerRepository; }
public RedisCache(string regionName, IDictionary<string, string> properties, RedisCacheElement element, IRedisClientsManager clientManager) { this.serializer = new ObjectSerializer(); this.clientManager = clientManager.ThrowIfNull("clientManager"); RegionName = regionName.ThrowIfNull("regionName"); expirySeconds = element != null ? (int)element.Expiration.TotalSeconds : PropertiesHelper.GetInt32(NHibernate.Cfg.Environment.CacheDefaultExpiration, properties, DefaultExpiry); log.DebugFormat("using expiration : {0} seconds", expirySeconds); var regionPrefix = PropertiesHelper.GetString(NHibernate.Cfg.Environment.CacheRegionPrefix, properties, null); log.DebugFormat("using region prefix : {0}", regionPrefix); CacheNamePrefix = element != null ? element.CachePrefix : string.Empty; var namespacePrefix = CacheNamePrefix + RegionName; if (!String.IsNullOrWhiteSpace(regionPrefix)) { namespacePrefix = regionPrefix + ":" + namespacePrefix; } CacheNamespace = new RedisNamespace(namespacePrefix); SyncGeneration(); }
public RedisQueue( ISerializer serializer, IRedisClientsManager clientManager, IQueueKeyNameProvider keyNameProvider ) : this(serializer, clientManager, keyNameProvider, 60) { }
public ThrottlingHandler(IRedisClientsManager clientsManager, Func <string, long> maxRequestsForUserIdentifier, TimeSpan period, string message) { _clientsManager = clientsManager; _maxRequestsForUserIdentifier = maxRequestsForUserIdentifier; _period = period; _message = message; }
private void OnFailover(IRedisClientsManager clientsManager) { try { if (masterClient != null) { //New thread-safe client with same connection info as connected master using (var currentlySubscribedClient = ((RedisClient)masterClient).CloneClient()) { currentlySubscribedClient.PublishMessage(QueueNames.TopicIn, WorkerStatus.ResetCommand); } } else { Restart(); } } catch (Exception ex) { if (this.ErrorHandler != null) { this.ErrorHandler(ex); } Log.Warn("Error trying to UnSubscribeFromChannels in OnFailover. Restarting...", ex); Restart(); } }
private static void UseClientAsync(IRedisClientsManager manager, int clientNo) { using (var client = manager.GetClient()) { UseClient(client, clientNo); } }
public RedisCache(string regionName, IDictionary <string, string> properties, RedisCacheElement element, IRedisClientsManager clientManager) { this.serializer = new ObjectSerializer(); this.clientManager = clientManager.ThrowIfNull("clientManager"); this.RegionName = regionName.ThrowIfNull("regionName"); this.expirySeconds = element != null ? (int)element.Expiration.TotalSeconds : PropertiesHelper.GetInt32(Cfg.Environment.CacheDefaultExpiration, properties, DefaultExpiry); log.DebugFormat("using expiration : {0} seconds", this.expirySeconds); var regionPrefix = PropertiesHelper.GetString(Cfg.Environment.CacheRegionPrefix, properties, null); log.DebugFormat("using region prefix : {0}", regionPrefix); var namespacePrefix = CacheNamePrefix + this.RegionName; if (!String.IsNullOrWhiteSpace(regionPrefix)) { namespacePrefix = regionPrefix + ":" + namespacePrefix; } this.CacheNamespace = new RedisNamespace(namespacePrefix); this.SyncGeneration(); }
public RepositoryProxy(IDbConnectionFactory dbConnectionFactory, IRedisClientsManager redisClientsManager) { DbConnectionFactory= dbConnectionFactory; RedisClientsManager= redisClientsManager; CreateCommand(); CreateRedisClient(); }
public RedisClientFactory( IRedisClientsManager redisClientsManager, IRedisClientsManagerAsync redisClientsManagerAsync) { _manager = redisClientsManager; _managerAsync = redisClientsManagerAsync; }
public RedisMessageHandlerWorker( IRedisClientsManager clientsManager, IMessageHandler messageHandler, string queueName, Action<IMessageHandlerBackgroundWorker, Exception> errorHandler) : base(messageHandler, queueName, errorHandler) { this.clientsManager = clientsManager; }
public RedisMessageQueueClient( IRedisClientsManager clientsManager, Action onPublishedCallback) { this.onPublishedCallback = onPublishedCallback; this.clientsManager = clientsManager; this.MaxSuccessQueueSize = 100; }
public RedisServerEvents(IRedisPubSubServer redisPubSub) { this.RedisPubSub = redisPubSub; this.clientsManager = redisPubSub.ClientsManager; redisPubSub.OnInit = OnInit; redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex); redisPubSub.OnMessage = HandleMessage; WaitBeforeNextRestart = TimeSpan.FromMilliseconds(2000); local = new MemoryServerEvents { NotifyJoin = HandleOnJoin, NotifyLeave = HandleOnLeave, NotifyUpdate = HandleOnUpdate, NotifyHeartbeat = HandleOnHeartbeat, Serialize = HandleSerialize, }; var appHost = HostContext.AppHost; var feature = appHost != null?appHost.GetPlugin <ServerEventsFeature>() : null; if (feature != null) { Timeout = feature.IdleTimeout; HouseKeepingInterval = feature.HouseKeepingInterval; OnSubscribe = feature.OnSubscribe; OnUnsubscribe = feature.OnUnsubscribe; NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions; } }
public static AssetRedis SetAssestPoint(IRedisClientsManager redisClientManager, Guid Id, AssetRedis asset) { var cacheKey = Id.ToString(); var redis = redisClientManager.GetClient(); var timeInServer = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time")); var currentAsset = redis.Get <AssetRedis>(cacheKey); if (currentAsset is null) { asset.StartTime = timeInServer; asset.CurrentLocation = asset.Location; redis.Set <AssetRedis>(cacheKey, asset); // redis.ExpireEntryIn(cacheKey, TimeSpan.FromMinutes(30)); } else { currentAsset.CurrentLocation = asset.Location; currentAsset.Location += ", " + asset.Location; // var timeToLive = redis.GetTimeToLive(cacheKey); redis.Set(cacheKey, currentAsset); // redis.ExpireEntryIn(cacheKey, (TimeSpan)timeToLive); } // return redis.Get<AssetRedis>(cacheKey); return(null); }
public RedisErrorLoggerFeature(IRedisClientsManager redisManager) { if (redisManager == null) throw new ArgumentNullException("redisManager"); this.redisManager = redisManager; }
private static void UseClientAsync(IRedisClientsManager manager, int clientNo, string testData) { using (var client = manager.GetReadOnlyClient()) { UseClient(client, clientNo, testData); } }
public RedisConnectionPool(string redisConnectionString, long database, RedisLuaScriptManager luaScriptManager) { // Init the pooledRedisClient Manager RedisClientManagerConfig config = new RedisClientManagerConfig(); config.DefaultDb = database; config.MaxReadPoolSize = RedisConnectionPool.DEFAULT_MAX_READ_POOL_SIZE; config.MaxWritePoolSize = RedisConnectionPool.DEFAULT_MAX_WRITE_POOL_SIZE; this.redisManagerPool = new PooledRedisClientManager( new string[] { redisConnectionString }, new string[] { redisConnectionString }, config); this.RequestBatchSize = RedisConnectionPool.DEFAULT_BATCH_SIZE; this.WindowMicroSec = RedisConnectionPool.DEFAULT_WINDOW_MICRO_SEC; this.Active = true; this.redisRequestQueue = new Queue <RedisRequest>(this.RequestBatchSize); this.redisResponseVisitor = new RedisResponseVisitor(); this.txEntryVisitor = new RedisTxEntryRequestVisitor(luaScriptManager); this.versionEntryVisitor = new RedisVersionEntryRequestVisitor(luaScriptManager); this.spinLock = new SpinLock(); lastFlushTime = DateTime.Now.Ticks / 10; }
public NinjectDependencyResolver() { ClientsManager = new PooledRedisClientManager(RedisUri); this.kernel = new StandardKernel(); this.AddBindings(); }
static RedisHelper() { try { RedisClientManagerConfig RedisConfig = new RedisClientManagerConfig(); RedisConfig.AutoStart = true; RedisConfig.MaxReadPoolSize = 60; RedisConfig.MaxWritePoolSize = 60; var hostWrite = System.Configuration.ConfigurationManager.AppSettings["RedisServerWrite"]; var arryWrite = hostWrite.Split(';').ToList(); var hostRead = System.Configuration.ConfigurationManager.AppSettings["RedisServerRead"]; var arryRead = hostWrite.Split(';').ToList(); if (arryWrite.Count > 0 && arryRead.Count > 0) { prcm = new PooledRedisClientManager(arryWrite, arryRead, RedisConfig); redisClient = prcm.GetClient(); } else { throw new Exception("连接服务器失败,请检查配置文件"); } } catch { throw new Exception("连接服务器失败,请检查配置文件"); } }
public RedisClientManagerFacade(IRedisClientsManager redisManager) { this.redisManager = redisManager; #if NET472 || NETCORE this.redisManagerAsync = (IRedisClientsManagerAsync)redisManager; #endif }
private void HandleFailover(IRedisClientsManager clientsManager) { try { if (OnFailover != null) { OnFailover(this); } if (masterClient != null) { //New thread-safe client with same connection info as connected master using (var currentlySubscribedClient = ((RedisClient)masterClient).CloneClient()) { Interlocked.CompareExchange(ref doOperation, Operation.Reset, doOperation); Channels.Each(x => currentlySubscribedClient.PublishMessage(x, Operation.ControlCommand)); } } else { Restart(); } } catch (Exception ex) { if (this.OnError != null) { this.OnError(ex); } Log.Warn("Error trying to UnSubscribeFromChannels in OnFailover. Restarting...", ex); Restart(); } }
public RedisTransientMessageFactory(int retryAttempts, TimeSpan?requestTimeOut, IRedisClientsManager clientsManager) { this.ClientsManager = clientsManager ?? new BasicRedisClientManager(); MessageService = new RedisTransientMessageService( retryAttempts, requestTimeOut, this); }
public void Execute(string ipAddress, int noOfThreads = 64) { clientsManager = new PooledRedisClientManager(ipAddress); redisCollection = new RedisCachedCollection <string, string>( clientsManager, "Threads: " + 64); var StartedAt = DateTime.UtcNow; Interlocked.Increment(ref running); "Starting HashCollectionStressTests with {0} threads".Print(noOfThreads); var threads = new List <Thread>(); for (int i = 0; i < noOfThreads; i++) { threads.Add(new Thread(WorkerLoop)); } threads.ForEach(t => t.Start()); "Press Enter to Stop...".Print(); Console.ReadLine(); Interlocked.Decrement(ref running); "Writes: {0}, Reads: {1}".Print(writeCount, readCount); "{0} EndedAt: {1}".Print(GetType().Name, DateTime.UtcNow.ToLongTimeString()); "{0} TimeTaken: {1}s".Print(GetType().Name, (DateTime.UtcNow - StartedAt).TotalSeconds); "\nPress Enter to Quit...".Print(); Console.ReadLine(); }
public override void Initialize(string name, NameValueCollection config) { if (String.IsNullOrWhiteSpace(name)) { name = "AspNetSession"; } this.name = name; var sessionConfig = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState"); this.sessionTimeoutMinutes = (int)sessionConfig.Timeout.TotalMinutes; lock (locker) { if (clientManagerStatic == null) { var host = config["host"]; var clientType = config["clientType"]; this.clientManager = this.CreateClientManager(clientType, host); this.manageClientManagerLifetime = false; } else { this.clientManager = clientManagerStatic; this.manageClientManagerLifetime = false; } } base.Initialize(name, config); }
public static void Run(IRedisClientsManager clientsManager) { Log.Information("-- Increment --"); var key = "key2"; var redisNativeClient = clientsManager.GetClient() as IRedisNativeClient; using (var redis = redisNativeClient) { redis.Del(key); long value = redis.Incr(key); Log.Information("Increment key: {key}. New value: {value}", key, value); } using (var redis = redisNativeClient) { long value = redis.Decr(key); Log.Information("Decrement key: {key}. New value: {value}", key, value); } using (var redis = redisNativeClient) { var incrBy = 5; long value = redis.IncrBy(key, incrBy); Log.Information("Increment key: {key} with value: {incrBy}. New value: {value}", key, incrBy, value); } }
public void TestFixtureSetUp() { redisManager = new BasicRedisClientManager(); mqService = new RedisMqServer(redisManager, 2, null); redisManager.Exec(r => r.FlushAll()); using (var mqPublisher = mqService.MessageFactory.CreateMessageProducer()) { var i = 0; mqPublisher.Publish(new MessageType1 { Name = "msg-" + i++ }); mqPublisher.Publish(new MessageType2 { Name = "msg-" + i++ }); mqPublisher.Publish(new MessageType2 { Name = "msg-" + i++ }); mqPublisher.Publish(new MessageType3 { Name = "msg-" + i++ }); mqPublisher.Publish(new MessageType3 { Name = "msg-" + i++ }); mqPublisher.Publish(new MessageType3 { Name = "msg-" + i++ }); } }
public static void Run(IRedisClientsManager clientsManager) { Log.Information("-- Sorted Sets --"); var key = "set3"; var redisNativeClient = clientsManager.GetClient() as IRedisNativeClient; using (var redis = redisNativeClient) { redis.Del(key); for (int i = 0; i < 4; i++) { var value = $"item {i}"; redis.ZAdd(key, i, value.GetBytes()); Log.Information("SetId: {key} Add value: {value} with score: {score}", key, value, i); } } using (var redis = redisNativeClient) { var min = 1; var max = 2; byte[][] values = redis.ZRangeByScore(key, min, max, null, null); foreach (var value in values) { Log.Information("SetId: {key} From {from} to {to} value: {count}", key, min, max, value.GetString()); } } }
private readonly IRedisClientsManager clientsManager; //Thread safe redis client/conn factory public RedisQueueHandlerWorker(IRedisClientsManager clientsManager, RedisMqServer mqServer, string queueName, Action<IQueueHandlerBackgroundWorker, Exception> errorHandler) : base(queueName, errorHandler) { if (clientsManager == null) throw new ArgumentNullException("clientsManager"); if (mqServer == null) throw new ArgumentNullException("mqServer"); this.clientsManager = clientsManager; this.MqServer = mqServer; }
public AudioAlarmRedisRepository(IKeyGenerator<Guid> keygenerator, IRedisClientsManager manager) { if (keygenerator == null) throw new ArgumentNullException(nameof(keygenerator)); if (manager == null) throw new ArgumentNullException(nameof(manager)); this.keygenerator = keygenerator; this.manager = manager; }
public static void SetClientManager(IRedisClientsManager clientManager) { if (clientManagerStatic != null) { throw new InvalidOperationException("Redis Client Manager只能配置一次."); } clientManagerStatic = clientManager.ThrowIfNull(); }
public static string RegisterLuaScript(IRedisClientsManager clientManager) { using (var client = clientManager.GetClient()) { string scriptSha1 = client.LoadLuaScript(GetLuaScript()); return scriptSha1; } }
public MessageHandlerWorker( IRedisClientsManager clientsManager, IMessageHandler messageHandler, string queueName, Action<MessageHandlerWorker, Exception> errorHandler) { this.clientsManager = clientsManager; this.messageHandler = messageHandler; this.QueueName = queueName; this.errorHandler = errorHandler; }
/// <summary> /// Sets the client manager to be used for the session state provider. /// This client manager's lifetime will not be managed by the RedisSessionStateProvider. /// However, if this is not set, a client manager will be created and /// managed by the RedisSessionStateProvider. /// </summary> /// <param name="clientManager"></param> public static void SetClientManager(IRedisClientsManager clientManager) { if (clientManager == null) throw new ArgumentNullException(); if (clientManagerStatic != null) { throw new InvalidOperationException("The client manager can only be configured once."); } clientManagerStatic = clientManager; }
/// <summary> /// Constructor /// </summary> public ConfigurationSvc(IRedisClientsManager redisManager, ILoggerFactory loggerFactory) : base(loggerFactory) { this.redisManager = redisManager; string tmp = ConfigurationManager.AppSettings["BHSConfigKeyPrefix"]; configKeyPrefix = (!string.IsNullOrEmpty(tmp)) ? tmp : "BHS:ConfigKey:"; configKeyPrefix = StringUtils.MustEndWith(configKeyPrefix, ":"); logger.Info("Using " + configKeyPrefix + " as prefix for configuration keys in Redis"); }
public QueueManager( ISerializer serializer, IRedisClientsManager clientManager, IQueueKeyNameProvider keyNameProvider) { _serializer = serializer; _clientManager = clientManager; _keyNameProvider = keyNameProvider; _log = log4net.LogManager.GetLogger(typeof(QueueManager)); }
/// <summary> /// Constructor /// </summary> public IdGeneratorSvc(IRedisClientsManager redisManager, IConfigurationSvc configurationSvc, ILoggerFactory loggerFactory) { this.redisManager = redisManager; logger = loggerFactory.GetLogger(GetType()); idKeyPrefix = configurationSvc.GetStringConfig("IdGenerator:$Internal$:KeyPrefix", "BHS:IdGenKey:"); idKeyPrefix = StringUtils.MustEndWith(idKeyPrefix, ":"); logger.Info("Using " + idKeyPrefix + " as prefix for id generation keys in Redis"); }
public RateLimitFeatureTests() { redisManager = A.Fake<IRedisClientsManager>(); limitProvider = A.Fake<ILimitProvider>(); keyGenerator = A.Fake<ILimitKeyGenerator>(); var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization()); limit = fixture.Create<Limits>(); A.CallTo(() => limitProvider.GetLimits(A<IRequest>.Ignored)).Returns(limit); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); this.clientManager = new PooledRedisClientManager("localhost:6379"); RedisSessionStateStoreProvider.SetClientManager(this.clientManager); }
protected void Dispose(bool disposing) { if (disposing) { if (_redisClientsManager != null) { _redisClientsManager.Dispose(); _redisClientsManager = null; } } }
public RedisPubSubServer(IRedisClientsManager clientsManager, params string[] channels) { this.ClientsManager = clientsManager; this.Channels = channels; var failoverHost = clientsManager as IRedisFailover; if (failoverHost != null) { failoverHost.OnFailover.Add(HandleFailover); } }
/// <summary> /// /// </summary> /// <param name="keygenerator"></param> /// <param name="eventrepository"></param> /// <param name="manager"></param> public CalendarRedisRepository(IKeyGenerator<Guid> keygenerator, IEventRepository eventrepository, IRedisClientsManager manager) { if (keygenerator == null) throw new ArgumentNullException(nameof(keygenerator)); this.keygenerator = keygenerator; if (eventrepository == null) throw new ArgumentNullException(nameof(eventrepository)); this.eventrepository = eventrepository; if (manager == null) throw new ArgumentNullException(nameof(manager)); this.manager = manager; }
protected void Application_Start() { ClientsManager = new PooledRedisClientManager(RedisUri); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ConfigureDependencyResolver(GlobalConfiguration.Configuration); }
public EventRedisRepository( IKeyGenerator<Guid> keygenerator, IAudioAlarmRepository aalarmrepository, IDisplayAlarmRepository dalarmrepository, IEmailAlarmRepository ealarmrepository, IRedisClientsManager manager) { this.keygenerator = keygenerator; this.ealarmrepository = ealarmrepository; this.dalarmrepository = dalarmrepository; this.aalarmrepository = aalarmrepository; this.manager = manager; }
public TrackingRedisClientsManager(IRedisClientsManager redisClientsManager) { if (redisClientsManager == null) { throw new ArgumentNullException("redisClientsManager"); } this.redisClientsManager = redisClientsManager; Logger.DebugFormat("Constructed"); var timer = new Timer(state => this.DumpState()); timer.Change(TimeSpan.FromSeconds(30), TimeSpan.FromMinutes(1)); }