本文整理汇总了C#中BookSleeve.RedisConnection.Close方法的典型用法代码示例。如果您正苦于以下问题:C# RedisConnection.Close方法的具体用法?C# RedisConnection.Close怎么用?C# RedisConnection.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookSleeve.RedisConnection
的用法示例。
在下文中一共展示了RedisConnection.Close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
var connection = new RedisConnection("127.0.0.1", allowAdmin: true);
connection.Open();
connection.Server.FlushDb(0);
connection.Close(false);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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();
}
示例5: getTopKeys
private List<string> getTopKeys(string category, int top)
{
List<string> ret = new List<string>();
RedisConnection connection = new RedisConnection(DemoSettings.ProductsRedisCache.Url,
password: DemoSettings.ProductsRedisCache.Password);
connection.Open();
var list = connection.SortedSets.Range(0, "rate:" + category, start: 0, stop: top, ascending: false).Result;
foreach (var item in list)
ret.Add(Encoding.ASCII.GetString(item.Key));
connection.Close(false);
return ret;
}
示例6: getProducts
private List<Product> getProducts(string category, double start, double end)
{
var products = new List<Product>();
var connection = new RedisConnection(DemoSettings.ProductsRedisCache.Url,
password: DemoSettings.ProductsRedisCache.Password);
connection.Open();
var list = connection.SortedSets.Range(0, "cat:" + category, min: start, max: end, ascending: false).Result;
foreach (var item in list)
{
string[] parts = Encoding.ASCII.GetString(item.Key).Split(':');
if (parts.Length == 5)
products.Add(new Product
{
Category = parts[0],
Name = parts[2],
Price = (int)(double.Parse(parts[3]) * 100) / 100.0,
Rate = int.Parse(parts[4])
});
}
connection.Close(false);
return products;
}
示例7: PrimeProuctCache
private static void PrimeProuctCache(TextWriter log)
{
if (!ConfirmOperation("YOUR CACHE WILL BE FLUSHED! ALL EXISTING INDEXES WILL BE REPLACED! Are you sure?", log))
return;
var client = CloudStorageAccount.CreateCloudTableClient();
var table = client.GetTableReference(DemoSettings.Storage.ProductsTableName);
var query = from product in table.CreateQuery<Product>() select product;
var connection = new RedisConnection(DemoSettings.ProductsRedisCache.Url, allowAdmin: true, password: DemoSettings.ProductsRedisCache.Password);
connection.Open();
connection.Server.FlushDb(0);
foreach (var c in query)
{
string key = string.Format("{0}:{1}:{2}:{3}:{4}", c.PartitionKey, c.RowKey, c.Name, c.Price, c.Rate);
log.WriteLine("{0}:{1}", key, c.Name);
connection.SortedSets.Add(0, "cat:" + c.Category, key, c.Price);
connection.SortedSets.Add(0, "rate:" + c.Category, key, c.Rate);
connection.Strings.Set(0, "prod:" + c.Category + ":" + c.Name.Replace(' ', ':'), key);
}
connection.Close(false);
}