public async Task Can_Store_and_GetById_ModelWithIdAndName()
        {
            const int modelId = 1;
            var       to      = Factory.CreateInstance(modelId);
            await redis.StoreAsync(to);

            var from = await redis.GetByIdAsync(to.GetId().ToString());

            Factory.AssertIsEqual(to, from);
        }
Exemple #2
0
        public async Task Can_Expire()
        {
            var cachedRecord = new CacheRecord
            {
                Id       = "key",
                Children =
                {
                    new CacheRecordChild {
                        Id = "childKey", Data = "data"
                    }
                }
            };

            await RedisTyped.StoreAsync(cachedRecord);

            await RedisTyped.ExpireInAsync("key", TimeSpan.FromSeconds(1));

            Assert.That(await RedisTyped.GetByIdAsync("key"), Is.Not.Null);
            await Task.Delay(2000);

            Assert.That(await RedisTyped.GetByIdAsync("key"), Is.Null);
        }
Exemple #3
0
 public async Task <T> GetByIdAsync(object id, CancellationToken token = default)
 {
     return(await redisTypedClient.GetByIdAsync(id, token));
 }