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


C# RedisClient.Del方法代码示例

本文整理汇总了C#中RedisClient.Del方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.Del方法的具体用法?C# RedisClient.Del怎么用?C# RedisClient.Del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedisClient的用法示例。


在下文中一共展示了RedisClient.Del方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDel

        public void TestDel()
        {
            using(var mock = new MockConnector("localhost", 9999, ":3\r\n"))
            using(var redis = new RedisClient(mock))
            {
                Assert.Equal(3, redis.Del("test"));
                Assert.Equal("*2\r\n$3\r\nDEL\r\n$4\r\ntest\r\n", mock.GetMessage());
            }

            this.RealCall(redis =>
            {
                redis.MSet(new RedisDictionary { { "key1", "value1" }, { "key2", "value2" } });
                Assert.Equal(2, redis.Del("key1", "key2"));
            });
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:15,代码来源:RedisKeyTests.cs

示例2: ValidateTransfer

        public string ValidateTransfer(string sourceAppId, string userId, string transferId, string transferToken)
        {
            var red = new RedisClient<string>();
            var result = red.Get("transfertoken:" + transferId);
            if (!string.IsNullOrEmpty(result))
            {
                var redResult = red.Del("transfertoken:" + transferId);

                var redapp = new RedisClient<AppRegistry>();
                redapp.Select(1);
                var app = redapp.Get(HttpContext.Current.Items["AppId"] as string);

                var str = "UserId=" + userId + "&TransferId=" + transferId + "&Salt=" + app.AppSecret ;
                str = Hash.GetHash(str, Hash.HashType.SHA256);

                if (transferToken != str)
                {
                    throw new FaultException<UnauthorizedAccessException>(new UnauthorizedAccessException("token yanlış"));
                }

                string sessionguid = Guid.NewGuid().ToString();
                var redis = new RedisClient<Common.SessionRegistry>();
                var appId = HttpContext.Current.Items["AppId"] as string;
                redis.Set(sessionguid, new SessionRegistry() { SessionCookie = sessionguid, AppId = appId, UserId = userId });
                return sessionguid;
            }
            return null;
        }
开发者ID:endulus,项目名称:oynamalar,代码行数:28,代码来源:AuthService.svc.cs

示例3: Delete

        public void Delete(Tile tile)
        {
            var client = new RedisClient();
            client.Del(new TileKeys().GetTileKey(tile.Id));

            new DataIdManager ().Remove (tile);
        }
开发者ID:CompulsiveCoder,项目名称:TileSim,代码行数:7,代码来源:TileDeleter.cs

示例4: Delete

        public void Delete(Guid personId)
        {
            var client = new RedisClient ();
            var key = new PeopleKeys ().GetPersonKey (personId);

            if (client.Exists (key))
                client.Del (key);
        }
开发者ID:CompulsiveCoder,项目名称:TileSim,代码行数:8,代码来源:PersonDeleter.cs

示例5: TestDel

 public void TestDel()
 {
     using (var mock = new FakeRedisSocket(":3\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual(3, redis.Del("test"));
         Assert.AreEqual("*2\r\n$3\r\nDEL\r\n$4\r\ntest\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:KeyTests.cs

示例6: Can_change_db_at_runtime

 public void Can_change_db_at_runtime()
 {
     using (var redis = new RedisClient(TestConfig.SingleHost, TestConfig.RedisPort, db: 1))
     {
         var val = Environment.TickCount;
         var key = "test" + val;
         try
         {
             redis.Set(key, val);
             redis.ChangeDb(2);
             Assert.That(redis.Get<int>(key), Is.EqualTo(0));
             redis.ChangeDb(1);
             Assert.That(redis.Get<int>(key), Is.EqualTo(val));
             redis.Dispose();
         }
         finally
         {
             redis.ChangeDb(1);
             redis.Del(key);
         }
     }
 }
开发者ID:nataren,项目名称:NServiceKit.Redis,代码行数:22,代码来源:RedisClientTests.cs

示例7: RedisTestKeys

 public RedisTestKeys(RedisClient redis, params string[] keys)
 {
     _redis = redis;
     _keys = keys;
     _redis.Del(keys);
 }
开发者ID:richard-green,项目名称:csredis,代码行数:6,代码来源:RedisTestKeys.cs

示例8: Run

        public override void Run()
        {
            var personnels = Personnel.GetSamplePersonnels();
              var client = new RedisClient();

              var listKey = "personnels";

              // setup sample data
              client.Pipeline(c =>
              {
            client.Del(listKey);

            foreach (var person in personnels) {
              var idStr = person.Id.ToString();

              c.LPush(listKey, idStr);
              c.HSet(idStr, "name", person.Name);
              c.HSet(idStr, "email", person.Email);
              c.HIncrBy(idStr, "age", person.Age);
              c.HIncrBy(idStr, "salary", person.Salary);
              c.HSet(idStr, "json", person.ToJson());
            }
              });

              while (true) {
            WriteLine("0. List personnels sorted by yearly income.");
            WriteLine("1. List personnels sorted by age.");
            WriteLine("2. List personnels sorted by id descending.");
            WriteLine("3. List personnels sorted by name.");
            WriteLine("4. List all personnel emails.");

            string[] result;
            var parseResult = true;

            switch (ReadLine()) {
            case "0": {
              result = client.Sort(listKey,
              byPattern: "*->salary",
              getPattern: new[] { "*->json" });
            } break;

            case "1": {
              parseResult = true;
              result = client.Sort(listKey,
              byPattern: "*->age",
              getPattern: new[] { "*->json" });
            } break;

            case "2": {
              parseResult = true;
              result = client.Sort(listKey,
              descending: true,
              getPattern: new[] { "*->json" });
            } break;

            case "3": {
              result = client.Sort(listKey,
              byPattern: "*->name",
              alpha: true,
              getPattern: new[] { "*->json" });
            } break;

            case "4": {
              result = client.Sort(listKey,
              byPattern: "nosort", // non-existent key
              getPattern: new[] { "*->email" });
              parseResult = false;
            } break;

            default: continue;
            }

            if (parseResult)
              result = result
            .Select(json => Personnel.FromJson(json).ToString())
            .ToArray();

            WriteLine("\r\nResults:");
            Array.ForEach(result, WriteLine);
            WriteLine("\r\n");
              }
        }
开发者ID:johanhelsing,项目名称:sider,代码行数:82,代码来源:SortSample.cs


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