コード例 #1
0
 internal override bool IsUserInCache(string userToken, string userTenant, out string cacheKey, out FailFastUserCacheValue cacheValue, out BlockedReason blockedReason)
 {
     cacheKey      = null;
     cacheValue    = null;
     blockedReason = BlockedReason.None;
     if (!FailFastUserCache.FailFastEnabled)
     {
         return(false);
     }
     Logger.EnterFunction(ExTraceGlobals.FailFastCacheTracer, "PrimaryFailFastUserCache.IsUserBlocked.");
     if (base.TryGetValue(userToken, out cacheValue) && cacheValue.IsValid)
     {
         blockedReason = BlockedReason.BySelf;
         cacheKey      = userToken;
         Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "User key {0} exist. CachedValue: {1}", new object[]
         {
             userToken,
             cacheValue.ToString()
         });
         return(true);
     }
     if (!string.IsNullOrEmpty(userTenant))
     {
         string text = "Tenant:C8E2A9F6-0E7A-4bcc-95A0-9CE1BCA7EE68:" + userTenant;
         if (base.TryGetValue(text, out cacheValue) && cacheValue.IsValid)
         {
             cacheKey      = text;
             blockedReason = BlockedReason.ByTenant;
             Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "Tenant Key {0} exist. CachedValue: {1}", new object[]
             {
                 text,
                 cacheValue.ToString()
             });
             return(true);
         }
     }
     if (base.TryGetValue("AllUsers:D3511BCA-379C-4a38-97E5-0FDA0C231C33", out cacheValue) && cacheValue.IsValid)
     {
         blockedReason = BlockedReason.ByServer;
         cacheKey      = "AllUsers:D3511BCA-379C-4a38-97E5-0FDA0C231C33";
         Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "All User Key {0} exist. CacheValue: {1}", new object[]
         {
             "AllUsers:D3511BCA-379C-4a38-97E5-0FDA0C231C33",
             cacheValue.ToString()
         });
         return(true);
     }
     Logger.ExitFunction(ExTraceGlobals.FailFastCacheTracer, "PrimaryFailFastUserCache.IsUserBlocked.");
     return(false);
 }
コード例 #2
0
 private void OnCacheValueBeRemoved(string key, FailFastUserCacheValue cacheValue, RemoveReason reason)
 {
     Logger.TraceInformation(ExTraceGlobals.FailFastCacheTracer, "Remove value from the cache. Key: {0}. CacheValue: {1}. Reason: {2}", new object[]
     {
         key,
         cacheValue.ToString(),
         reason
     });
     FailFastModule.RemotePowershellPerfCounter.FailFastUserCacheSize.RawValue = (long)base.Count;
 }