本文整理汇总了C#中IRedisClient.Set方法的典型用法代码示例。如果您正苦于以下问题:C# IRedisClient.Set方法的具体用法?C# IRedisClient.Set怎么用?C# IRedisClient.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRedisClient
的用法示例。
在下文中一共展示了IRedisClient.Set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadBasicStrings
protected void LoadBasicStrings(IRedisClient redis)
{
int A = 'A';
int Z = 'Z';
var letters = (Z - A + 1).Times(i => ((char)(i + A)).ToString());
var numbers = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
var pos = 0;
letters.Each(x => redis.Set("string:letters/" + x, x));
numbers.Each(x => redis.Set("string:numbers/" + pos++, x));
}
示例2: SetKey
private void SetKey(IRedisClient client, int count)
{
for(int i = 1; i <= count; i++)
{
client.Set("key" + i, count);
}
}
示例3: IncrementKeyInsideLock
private void IncrementKeyInsideLock(String key, String lockKey, int clientNo, IRedisClient client)
{
using (client.AcquireLock(lockKey))
{
Debug.WriteLine(String.Format("client {0} acquired lock", clientNo));
var val = client.Get<int>(key);
Thread.Sleep(200);
client.Set(key, val + 1);
Debug.WriteLine(String.Format("client {0} released lock", clientNo));
}
}
示例4: IncrementKeyInsideLock
private static void IncrementKeyInsideLock(int clientNo, IRedisClient client)
{
using (client.AcquireLock("testlock"))
{
Console.WriteLine("client {0} acquired lock", clientNo);
var val = client.Get<int>("key");
Thread.Sleep(200);
client.Set("key", val + 1);
Console.WriteLine("client {0} released lock", clientNo);
}
}
示例5: InitBlog
public void InitBlog(SqlConnection con, IRedisClient redis)
{
const string itemKey = "urn:blog:{0}";
const string itemList = "urn:blog:list:{0}";
var blogRedis = new BlogRedis(redis);
var memberRedis = new MemberRedis(redis);
var nhomRedis = new NhomRedis(redis);
var xeRedis = new XeRedis(redis);
var member = new Member();
var xe = new Xe();
var nhom = new Nhom();
var nguoiTao = new Member();
//STEP:1
//var blog = BlogDal.SelectAll().FirstOrDefault();
//redis.Set(string.Format(itemKey,blog.Id), blog);
//STEP:2
var list = BlogDal.SelectAll();
var all = redis.Lists[string.Format(itemList, "all")];
var approved = redis.Lists[string.Format(itemList, "approved")];
var unApproved = redis.Lists[string.Format(itemList, "unApproved")];
var topNhatKy = redis.Lists[string.Format(itemList, "blog")];
var topHanhTrinh = redis.Lists[string.Format(itemList, "hanhTrinh")];
var topNhomBlog = redis.Lists[string.Format(itemList, "nhomBlog")];
var topNhomForum = redis.Lists[string.Format(itemList, "nhomForum")];
foreach (var item in list)
{
var key = string.Format(itemKey, item.Id);
var thich = ThichDal.SelectByPidLoai(item.RowId, 3);
foreach (var thich1 in thich)
{
item.NguoiThich.Insert(0, thich1.Username);
}
var anhs = AnhDal.SelectByPId(DAL.con(), item.RowId.ToString(), 100);
foreach (var anh in anhs)
{
item.AnhList.Insert(0, anh.Id);
}
var binhLuanList = BinhLuanDal.PagerByPRowId(con, "a", false, item.RowId.ToString(), 1000).List;
foreach (var binhLuan in binhLuanList)
{
item.BinhLuanIds.Insert(0, binhLuan.Id);
}
switch (item.Loai)
{
case 1:
member = memberRedis.GetByRowId(item.PID_ID);
topHanhTrinh.Push(item.Id.ToString(CultureInfo.InvariantCulture));
if (member != null)
{
item.Url = string.Format("{0}/blogs/{1}/", member.Url, item.Id);
item.UrlEdit = string.Format("{0}/blogs/edit/{1}/", member.Url, item.Id);
}
break;
case 2:
xe = xeRedis.GetByRowId(item.PID_ID);
if (xe != null)
{
item.Url = string.Format("{0}blogs/{1}/", xe.XeUrl, item.Id);
item.UrlEdit = string.Format("{0}blogs/edit/{1}/", xe.XeUrl, item.Id);
}
topNhatKy.Push(item.Id.ToString());
break;
case 3:
nhom = nhomRedis.GetByRowId(item.PID_ID);
if (nhom != null)
{
item.Url = string.Format("{0}blogs/{1}/", nhom.Url, item.Id);
item.UrlEdit = string.Format("{0}blogs/edit/{1}/", nhom.Url, item.Id);
}
topNhomBlog.Push(item.Id.ToString());
break;
case 4:
nhom = nhomRedis.GetByRowId(item.PID_ID);
if (nhom != null)
{
item.Url = string.Format("{0}forum/{1}/", nhom.Url, item.Id);
item.UrlEdit = string.Format("{0}blogs/edit/{1}/", nhom.Url, item.Id);
}
topNhomForum.Push(item.Id.ToString());
break;
}
redis.Set(key, item);
redis.Set(string.Format(itemKey, item.RowId), item.Id);
all.Push(item.Id.ToString());
if (item.Publish)
{
approved.Push(item.Id.ToString());
}
else
{
unApproved.Push(item.Id.ToString());
}
}
//.........这里部分代码省略.........