本文整理汇总了C#中BookSleeve.RedisConnection.Wait方法的典型用法代码示例。如果您正苦于以下问题:C# RedisConnection.Wait方法的具体用法?C# RedisConnection.Wait怎么用?C# RedisConnection.Wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookSleeve.RedisConnection
的用法示例。
在下文中一共展示了RedisConnection.Wait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RedisActivityMonitorTests
public RedisActivityMonitorTests()
{
redis = new RedisConnection("localhost", allowAdmin: true);
sut = new RedisActivityMonitor(redis);
redis.Wait(redis.Open());
redis.Wait(redis.Server.FlushDb(0));
}
示例2: CanNotOpenNonsenseConnection_IP
public void CanNotOpenNonsenseConnection_IP()
{
using (var conn = new RedisConnection(Config.LocalHost, 6500))
{
conn.Wait(conn.Open());
}
}
示例3: CanNotOpenNonsenseConnection
public void CanNotOpenNonsenseConnection()
{
using (var conn = new RedisConnection("127.0.0.1", 6500))
{
conn.Wait(conn.Open());
}
}
示例4: CanNotOpenNonsenseConnection_DNS
public void CanNotOpenNonsenseConnection_DNS()
{
using (var conn = new RedisConnection("doesnot.exist.ds.aasd981230d.com", 6500))
{
conn.Wait(conn.Open());
}
}
示例5: GetOpen
public RedisConnection GetOpen()
{
lock (syncConnection)
{
if (_Connection != null && !(_Connection.State == RedisConnectionBase.ConnectionState.Closed || _Connection.State == RedisConnectionBase.ConnectionState.Closing))
{
return _Connection;
}
if (_Connection == null || (_Connection.State == RedisConnectionBase.ConnectionState.Closed || _Connection.State == RedisConnectionBase.ConnectionState.Closing))
{
try
{
RoqueTrace.Source.Trace(TraceEventType.Information, "[REDIS] connecting to {0}:{1}", _Host, _Port);
_Connection = new RedisConnection(_Host, _Port, _Timeout);
var openAsync = _Connection.Open();
_Connection.Wait(openAsync);
RoqueTrace.Source.Trace(TraceEventType.Information, "[REDIS] connected");
}
catch (Exception ex)
{
RoqueTrace.Source.Trace(TraceEventType.Error, "[REDIS] error connecting to {0}:{1}, {2}", _Host, _Port, ex.Message, ex);
throw;
}
}
return _Connection;
}
}
示例6: TestPackage
public TestPackage(RedisConnection conn)
{
Redis = new RedisBooksleeveConnector(conn);
var redisFS = new Resque.FailureService(new RedisBackendFactory(Redis));
UnderTest = new Resque.Resque(new JobCreator(), redisFS, Redis);
conn.Wait(conn.Keys.Remove(0, Redis.KeyInNamespace("queue:testQueue")));
}
示例7: Application_Start
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters( GlobalFilters.Filters );
RegisterRoutes( RouteTable.Routes );
var redis = new RedisConnection( "localhost" );
redis.Wait( redis.Open() );
Application[ "RedisConnection" ] = redis;
}
示例8: should_create_queue_if_it_does_not_exist
public void should_create_queue_if_it_does_not_exist()
{
var testQueue = "testQueue";
using (var conn = new RedisConnection("localhost"))
{
conn.Open();
var package = new TestPackage(conn);
package.UnderTest.Push(testQueue, "Testing");
Assert.IsTrue(conn.Wait(conn.Keys.Exists(0, package.Redis.KeyInNamespace("queue:"+testQueue))));
}
}
示例9: Get
public List<string> Get(string prefix)
{
List<string> ret = new List<string>();
RedisConnection connection = new RedisConnection(
host: DemoSettings.CustomerRedisCache.Url,
password: DemoSettings.CustomerRedisCache.Password);
connection.Open();
var list = connection.Wait(connection.Keys.Find(0, "cust:" + prefix.Replace(' ', ':') + "*"));
for (int i = 0; i < Math.Min(5, list.Length); i++)
{
ret.Add(list[i].Substring(5).Replace(':', ' '));
}
connection.Close(false);
return ret;
}
示例10: GetOpenConnection
private static RedisConnection GetOpenConnection()
{
var connectionString = ConfigurationManager.AppSettings["REDISTOGO_URL"];
var uri = new Uri(connectionString);
var password = uri.UserInfo.Split(':').LastOrDefault();
var conn = new RedisConnection(uri.Host, uri.Port, password: password, allowAdmin: false,
syncTimeout: DefaultTimeout, ioTimeout: DefaultTimeout);
conn.Error += (sender, e) => Logger.ErrorException(e.Cause, e.Exception);
conn.Wait(conn.Open());
return conn;
}
示例11: Get
public List<string> Get(string prefix, string category)
{
List<string> ret = new List<string>();
RedisConnection connection = new RedisConnection(
host: DemoSettings.ProductsRedisCache.Url,
password: DemoSettings.ProductsRedisCache.Password);
connection.Open();
var list = connection.Wait(connection.Keys.Find(0, "prod:" + category + ":" + prefix.Replace(' ', ':') + "*"));
for (int i = 0; i < Math.Min(5, list.Length); i++)
{
string s = list[i].Substring(5);
s = s.Substring(s.IndexOf(':') + 1);
ret.Add(s.Replace(':', ' '));
}
connection.Close(false);
return ret;
}
示例12: should_add_item_to_queue
public void should_add_item_to_queue()
{
var testQueue = "testQueue";
var item = new QueuedItem()
{
@class = "Testing"
};
using (var conn = new RedisConnection("localhost"))
{
conn.Open();
var package = new TestPackage(conn);
package.UnderTest.Push(testQueue, [email protected], item.args);
var test = conn.Wait(conn.Lists.RemoveLastString(0, package.Redis.KeyInNamespace("queue:" + testQueue)));
Assert.AreEqual(item.ToJson(), test);
}
}
示例13: Main
public static void Main(string[] args)
{
var time = new DateTime(2013, 11, 11, 10, 30, 0);
var redis = new RedisConnection("localhost");
redis.Wait(redis.Open());
var activity = new RedisActivityMonitor(redis);
// Normal activity.
activity.Beacon("documents:1", time.AddSeconds(-15), 1, "John");
activity.Beacon("documents:1", time, 2, "Sue");
activity.Beacon("documents:1", time.AddSeconds(5), 3, "Mary");
PrintAll(activity, "documents:1", time.AddSeconds(23));
// Ignore duplicates.
activity.Beacon("documents:2", time, 1, "John");
activity.Beacon("documents:2", time.AddSeconds(5), 1, "John");
PrintAll(activity, "documents:2", time.AddSeconds(7));
redis.Close(abort: true);
Console.Read();
}
示例14: GetOldStyleConnection
private static RedisConnection GetOldStyleConnection(string host, int port, bool open = true, bool allowAdmin = false, bool waitForOpen = false, int syncTimeout = 5000, int ioTimeout = 5000)
{
var conn = new RedisConnection(host, port, syncTimeout: syncTimeout, ioTimeout: ioTimeout, allowAdmin: allowAdmin);
conn.Error += (s, args) =>
{
Trace.WriteLine(args.Exception.Message, args.Cause);
};
if (open)
{
var openAsync = conn.Open();
if (waitForOpen) conn.Wait(openAsync);
}
return conn;
}
示例15: TestSubscriberNameOnRemote
private void TestSubscriberNameOnRemote(bool setName)
{
string id = Config.CreateUniqueName();
using (var pub = new RedisConnection(Config.RemoteHost, allowAdmin: true))
using (var sub = new RedisSubscriberConnection(Config.RemoteHost))
{
List<string> errors = new List<string>();
EventHandler<BookSleeve.ErrorEventArgs> errorHandler = (sender, args) =>
{
lock (errors) errors.Add(args.Exception.Message);
};
pub.Error += errorHandler;
sub.Error += errorHandler;
if (setName)
{
pub.Name = "pub_" + id;
sub.Name = "sub_" + id;
}
int count = 0;
var subscribe = sub.Subscribe("foo"+id, (key,payload) => Interlocked.Increment(ref count));
Task pOpen = pub.Open(), sOpen = sub.Open();
pub.WaitAll(pOpen, sOpen, subscribe);
Assert.AreEqual(0, Interlocked.CompareExchange(ref count, 0, 0), "init message count");
pub.Wait(pub.Publish("foo" + id, "hello"));
PubSub.AllowReasonableTimeToPublishAndProcess();
var clients = setName ? pub.Wait(pub.Server.ListClients()) : null;
Assert.AreEqual(1, Interlocked.CompareExchange(ref count, 0, 0), "got message");
lock (errors)
{
foreach (var error in errors)
{
Console.WriteLine(error);
}
Assert.AreEqual(0, errors.Count, "zero errors");
}
if (setName)
{
Assert.AreEqual(1, clients.Count(x => x.Name == pub.Name), "pub has name");
Assert.AreEqual(1, clients.Count(x => x.Name == sub.Name), "sub has name");
}
}
}