public async Task Can_GetKeysByPattern() { if (!(Cache is ICacheClientExtended)) { return; } JsConfig.ExcludeTypeInfo = true; for (int i = 0; i < 5; i++) { IAuthSession session = new CustomAuthSession { Id = "sess-" + i, UserAuthId = i.ToString(), Custom = "custom" + i }; var sessionKey = SessionFeature.GetSessionKey(session.Id); await Cache.SetAsync(sessionKey, session, SessionFeature.DefaultSessionExpiry); await Cache.SetAsync("otherkey" + i, i); } var sessionPattern = IdUtils.CreateUrn <IAuthSession>(""); Assert.That(sessionPattern, Is.EqualTo("urn:iauthsession:")); #if !NETFX var sessionKeys = await Cache.GetKeysStartingWithAsync(sessionPattern).ToListAsync(); Assert.That(sessionKeys.Count, Is.EqualTo(5)); Assert.That(sessionKeys.All(x => x.StartsWith("urn:iauthsession:"))); var allSessions = await Cache.GetAllAsync <IAuthSession>(sessionKeys); Assert.That(allSessions.Values.Count(x => x != null), Is.EqualTo(sessionKeys.Count)); var allKeys = (await Cache.GetAllKeysAsync().ToListAsync()).ToList(); Assert.That(allKeys.Count, Is.EqualTo(10)); #endif JsConfig.Reset(); }