public void Execute(string ipAddress) { Manager = new RedisManagerPool(ipAddress); StartedAt = DateTime.UtcNow; var q = new Timer { Interval = 1000 }; q.Elapsed += OnInterval; q.Enabled = true; using (PubSubServer = new RedisPubSubServer(Manager, Channel) { OnStart = () => { Console.WriteLine("OnStart: #" + Interlocked.Increment(ref StartCount)); }, OnHeartbeatSent = () => { Console.WriteLine("OnHeartbeatSent: #" + Interlocked.Increment(ref HeartbeatsSent)); }, OnHeartbeatReceived = () => { Console.WriteLine("OnHeartbeatReceived: #" + Interlocked.Increment(ref HeartbeatsReceived)); }, OnMessage = (channel, msg) => { Console.WriteLine("OnMessage: @" + channel + ": " + msg); }, OnStop = () => { Console.WriteLine("OnStop: #" + Interlocked.Increment(ref StopCount)); }, OnError = ex => { Console.WriteLine("OnError: #" + Interlocked.Increment(ref ErrorCount) + " ERROR: " + ex); }, OnFailover = server => { Console.WriteLine("OnFailover: #" + Interlocked.Increment(ref FailoverCount)); }, OnDispose = () => { Console.WriteLine("OnDispose: #" + Interlocked.Increment(ref DisposeCount)); }, OnUnSubscribe = channel => { Console.WriteLine("OnUnSubscribe: #" + Interlocked.Increment(ref UnSubscribeCount) + " channel: " + channel); }, }) { Console.WriteLine("PubSubServer StartedAt: " + StartedAt.ToLongTimeString()); PubSubServer.Start(); "Press Enter to Quit...".Print(); Console.ReadLine(); Console.WriteLine("PubSubServer EndedAt: " + DateTime.UtcNow.ToLongTimeString()); Console.WriteLine("PubSubServer TimeTaken: " + (DateTime.UtcNow - StartedAt).TotalSeconds + "s"); } }
public RedisStatusUpdater(Core.Spider spider, ISpiderStatus spiderStatus) { _spider = spider; _spiderStatus = spiderStatus; string host = ConfigurationManager.AppSettings["redishost"]; _password = ConfigurationManager.AppSettings["redishostpass"]; if (!string.IsNullOrEmpty(host)) { _pool = new RedisManagerPool(host); } }
public override void Configure(Container container) { var appSettings = new AppSettings(); var clientsManager = new RedisManagerPool(appSettings.Get("RedisConnectionString", "redis://localhost:6379")); container.Register<IRedisClientsManager>(c => clientsManager); container.Register<IPasswordGenerator>( new RngPasswordGenerator() { PasswordLength = appSettings.Exists("PasswordLength") ? appSettings.Get<uint>("PasswordLength") : 16 }); container.Register<IOneTimePasswordRepository>(c => new RedisOneTimePasswordRepository() { ClientsManager = clientsManager, PasswordExpiryInSeconds = appSettings.Get<uint>("PasswordExpiryInSeconds", 30) }); }
public void Does_set_all_properties_on_Client_using_ClientsManagers() { var connStr = "redis://*****:*****@host:1?ssl=true&db=0&connectTimeout=2&sendtimeout=3&receiveTimeout=4&idletimeoutsecs=5&NamespacePrefix=prefix."; var expected = "{Host:host,Port:1,Ssl:True,Client:nunit,Password:pass,Db:0,ConnectTimeout:2,SendTimeout:3,ReceiveTimeout:4,IdleTimeOutSecs:5,NamespacePrefix:prefix.}" .FromJsv<RedisEndpoint>(); using (var pooledManager = new RedisManagerPool(connStr)) { AssertClientManager(pooledManager, expected); } using (var pooledManager = new PooledRedisClientManager(connStr)) { AssertClientManager(pooledManager, expected); } using (var basicManager = new BasicRedisClientManager(connStr)) { AssertClientManager(basicManager, expected); } }
public static string GetFormRedis(string key) { using (var redisManager = new RedisManagerPool("192.168.27.128")) using (var redis = redisManager.GetClient()) { return redis.Get<string>(key); } }
public static bool StoryToReids(string key, string str) { using (var redisManager = new RedisManagerPool("192.168.27.128")) using (var redis = redisManager.GetClient()) { Console.WriteLine(" story string length is "+str.Length); return redis.Set(key, str); } }
static void Main(string[] args) { LogManager.LogFactory = new Log4NetFactory("log4net.config"); // ******************** // set REDIS CONFIGS // ******************** RedisConfig.DefaultConnectTimeout = 1 * 1000; RedisConfig.DefaultSendTimeout = 1 * 1000; RedisConfig.DefaultReceiveTimeout = 1 * 1000; RedisConfig.DefaultRetryTimeout = 15 * 1000; RedisConfig.DefaultIdleTimeOutSecs = 240; RedisConfig.BackOffMultiplier = 10; RedisConfig.BufferLength = 1450; RedisConfig.BufferPoolMaxSize = 500000; RedisConfig.VerifyMasterConnections = true; RedisConfig.HostLookupTimeoutMs = 1000; RedisConfig.DeactivatedClientsExpiry = TimeSpan.FromSeconds(15); RedisConfig.DisableVerboseLogging = false; var redisManager = new RedisManagerPool("localhost:56565?connectTimeout=1000"); // how many test items to create var items = 5; // how long to try popping var waitForSeconds = 30; // name of list var listID = "testlist"; var startedAt = DateTime.Now; LogManager.LogFactory.GetLogger("redistest").Info("--------------------------"); LogManager.LogFactory.GetLogger("redistest").Info("push {0} items to a list, then try pop for {1} seconds. repeat.".Fmt(items, waitForSeconds)); LogManager.LogFactory.GetLogger("redistest").Info("--------------------------"); using (var redis = redisManager.GetClient()) { do { // add items to list for (int i = 1; i <= items; i++) { redis.PushItemToList(listID, "item {0}".Fmt(i)); } do { var item = redis.BlockingPopItemFromList(listID, null); // log the popped item. if BRPOP timeout is null and list empty, I do not expect to print anything LogManager.LogFactory.GetLogger("redistest").InfoFormat("{0}", item.IsNullOrEmpty() ? " list empty " : item); System.Threading.Thread.Sleep(1000); } while (DateTime.Now - startedAt < TimeSpan.FromSeconds(waitForSeconds)); LogManager.LogFactory.GetLogger("redistest").Info("--------------------------"); LogManager.LogFactory.GetLogger("redistest").Info("completed first loop"); LogManager.LogFactory.GetLogger("redistest").Info("--------------------------"); } while (DateTime.Now - startedAt < TimeSpan.FromSeconds(2*waitForSeconds)); LogManager.LogFactory.GetLogger("redistest").Info("--------------------------"); LogManager.LogFactory.GetLogger("redistest").Info("completed outer loop"); } }
public RedisSchedulerManager(string host, string password) { _pool = new RedisManagerPool(host); _password = password; }
private RedisScheduler(RedisManagerPool pool, string password) { _password = password; _pool = pool; DuplicateRemover = this; }