当前位置: 首页>>代码示例>>C#>>正文


C# IRedisClient.Set方法代码示例

本文整理汇总了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));
        }
开发者ID:JerryForNet,项目名称:RedisAdminUI,代码行数:11,代码来源:PopulateRedisWithDataService.cs

示例2: SetKey

 private void SetKey(IRedisClient client, int count)
 {
     for(int i = 1; i <= count; i++)
     {
         client.Set("key" + i, count);
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:7,代码来源:RedisStreamTests.cs

示例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));
			}
		}
开发者ID:stevegraygh,项目名称:ServiceStack.Redis,代码行数:13,代码来源:RedisClientTests.cs

示例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);
			}
		}
开发者ID:charles-cai,项目名称:ServiceStack.Redis,代码行数:13,代码来源:RedisClientTests.cs

示例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());
            }

        }
//.........这里部分代码省略.........
开发者ID:nhatkycon,项目名称:xetui,代码行数:101,代码来源:RedisBlog.aspx.cs


注:本文中的IRedisClient.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。