示例#1
0
        /// <summary>
        ///     Handles the Removed event of the DistributedMemoryManagerCache control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyCacheEventArgs{TKey}" /> instance containing the event data.</param>
        protected override void DistributedMemoryManagerCache_Removed(object sender, KeyCacheEventArgs <long> e)
        {
            using (var entityTypeContext = new EntityTypeContext( ))
            {
                HashSet <long> types = entityTypeContext.Get(e.Key);

                var message = new EntityFieldCacheMessage( );
                message.RemoveKeys.Add(SerializableEntityId.Create(e.Key, types));

                MessageChannel.Publish(message, PublishOptions.None, false, MergeMessages);
            }
        }
示例#2
0
        /// <summary>
        ///     Removes the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">key</exception>
        public bool Remove(EntityRelationshipCacheKey key)
        {
            using (var entityTypeContext = new EntityTypeContext( ))
            {
                IEntity entity = EntityCache.Instance.Get(key.EntityId);

                if (entity != null)
                {
                    entityTypeContext.Merge(key.EntityId, entity.TypeIds);
                }

                bool result = ProviderRemove(key);

                HashSet <long> typeIds = entityTypeContext.Get(key.EntityId);

                var message = new EntityRelationshipCacheMessage( );
                message.RemoveKeys.Add(new SerializableEntityRelationshipCacheKey(SerializableEntityId.Create(key.EntityId, typeIds), key.Direction));

                MessageChannel.Publish(message, PublishOptions.FireAndForget, false, MergeMessages);

                return(result);
            }
        }