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


C# RedisClient.ExpireAt方法代码示例

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


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

示例1: TestExpireAt

 public void TestExpireAt()
 {
     using (var mock = new FakeRedisSocket(":1\r\n", ":0\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         // 1402643208 = ISO 8601:2014-06-13T07:06:48Z
         Assert.IsTrue(redis.ExpireAt("test1", new DateTime(2014, 6, 13, 7, 6, 48)));
         Assert.AreEqual("*3\r\n$8\r\nEXPIREAT\r\n$5\r\ntest1\r\n$10\r\n1402643208\r\n", mock.GetMessage());
         Assert.IsFalse(redis.ExpireAt("test2", 1402643208));
         Assert.AreEqual("*3\r\n$8\r\nEXPIREAT\r\n$5\r\ntest2\r\n$10\r\n1402643208\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:12,代码来源:KeyTests.cs

示例2: TestExpireAt

        public void TestExpireAt()
        {
            using(var mock = new MockConnector("localhost", 9999, ":1\r\n", ":0\r\n"))
            using(var redis = new RedisClient(mock))
            {
                // 1402643208 = ISO 8601:2014-06-13T07:06:48Z
                Assert.True(redis.ExpireAt("test1", new DateTime(2014, 6, 13, 7, 6, 48, DateTimeKind.Utc)));
                Assert.Equal("*3\r\n$8\r\nEXPIREAT\r\n$5\r\ntest1\r\n$10\r\n1402643208\r\n", mock.GetMessage());
                Assert.False(redis.ExpireAt("test2", 1402643208));
                Assert.Equal("*3\r\n$8\r\nEXPIREAT\r\n$5\r\ntest2\r\n$10\r\n1402643208\r\n", mock.GetMessage());
            }

            this.RealCall(redis =>
            {
                redis.MSet(new RedisDictionary { { "key1", "value1" } });
                var now = DateTime.Now;
                Assert.True(redis.ExpireAt("key1", now.AddSeconds(10)));
                var ttl = redis.Ttl("key1");
                Assert.True(ttl <= 10);
            });
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:21,代码来源:RedisKeyTests.cs

示例3: PExpireAt

        public void PExpireAt()
        {
            using(var mock = new MockConnector("localhost", 9999, ":1\r\n", ":0\r\n"))
            using(var redis = new RedisClient(mock))
            {
                // 1402643208123 = ISO 8601:2014-06-13T07:06:48Z +123ms

                Assert.True(redis.ExpireAt("test1", new DateTime(2014, 6, 13, 7, 6, 48, 123, DateTimeKind.Utc), RedisExpireTimeUnit.PX));
                Assert.Equal("*3\r\n$9\r\nPEXPIREAT\r\n$5\r\ntest1\r\n$13\r\n1402643208123\r\n", mock.GetMessage());
                Assert.False(redis.ExpireAt("test2", 1402643208123, RedisExpireTimeUnit.PX));
                Assert.Equal("*3\r\n$9\r\nPEXPIREAT\r\n$5\r\ntest2\r\n$13\r\n1402643208123\r\n", mock.GetMessage());
            }

            this.RealCall(redis =>
            {
                redis.MSet(new RedisDictionary { { "key1", "value1" } });
                Assert.True(redis.ExpireAt("key1", DateTime.Now.AddSeconds(10), RedisExpireTimeUnit.PX));
                Assert.True(redis.Ttl("key1") <= 10 * 1000);
            });
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:20,代码来源:RedisKeyTests.cs


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