Exemplo n.º 1
0
        /// <summary>
        /// Receives the remove message from the bus.
        /// </summary>
        /// <param name="message">The message.</param>
        internal void ReceiveRemoveMessage(CacheWasUpdatedMessage message)
        {
            if (RockMessageBus.IsFromSelf(message))
            {
                // We already took care of Clearing the cache for our instance, so
                // we can ignore this message.
                RockLogger.Log.Debug(RockLogDomains.Bus, $"Cache RemoveMessage was from ourselves( {message.SenderNodeName} ). Skipping. {message.ToDebugString()}.");
                return;
            }

            if (message.Key.IsNullOrWhiteSpace())
            {
                // A Key needs to be specified
                return;
            }

            if (message.Region.IsNotNullOrWhiteSpace())
            {
                CacheManager.Remove(message.Key, message.Region);
            }
            else
            {
                CacheManager.Remove(message.Key);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Applies the Authorization cache message.
        /// </summary>
        /// <param name="message">The message.</param>
        private void ApplyCacheMessage(AuthorizationCacheWasUpdatedMessage message)
        {
            CacheWasUpdatedMessage cacheWasUpdatedMessage = new CacheWasUpdatedMessage
            {
                Key            = message.Key,
                Region         = message.Region,
                SenderNodeName = message.SenderNodeName
            };

            RockCacheManager <object> .Instance.ReceiveRemoveMessage(cacheWasUpdatedMessage);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Receives the clear message from the message bus.
        /// </summary>
        /// <param name="message">The message.</param>
        internal void ReceiveClearMessage(CacheWasUpdatedMessage message)
        {
            if (RockMessageBus.IsFromSelf(message))
            {
                // We already took care of Clearing the cache for our instance, so
                // we can ignore this message.
                RockLogger.Log.Debug(RockLogDomains.Bus, $"Cache ClearMessage was from ourselves( {message.SenderNodeName} ). Skipping. {message.ToDebugString()}.");
                return;
            }

            CacheManager.Clear();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Clears the cache instance.
        /// </summary>
        public void Clear()
        {
            /* 07-29-2021 MDP
             * We want to clear the local cache immediately for this Instance of Rock.
             * Then send a CacheWasUpdatedMessage so that other Instances of Rock know that the cache was Updated.
             * This instance of Rock will also receive this CacheWasUpdatedMessage, but we already took care of that in this instance.
             * So, if we detect CacheWasUpdatedMessage is from this Instance, we can ignore it since we already took care of it.
             */

            CacheManager.Clear();
            CacheWasUpdatedMessage.Publish <T>();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Removes a value from the cache for the specified key and region.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="region">The region.</param>
        /// <returns></returns>
        public bool Remove(string key, string region)
        {
            /* 07-29-2021 MDP
             * We want to remove this item from local cache immediately for this Instance of Rock.
             * Then send a CacheWasUpdatedMessage so that other Instances of Rock know that the cache was Updated.
             * This instance of Rock will also receive this CacheWasUpdatedMessage, but we already took care of that in this instance.
             * So, if we detect CacheWasUpdatedMessage is from this Instance, we can ignore it since we already took care of it.
             */

            CacheManager.Remove(key, region);
            CacheWasUpdatedMessage.Publish <T>(key, region);
            return(true);
        }