/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false. /// </returns> public bool Equals(RedisPubSubCacheMessage <TKey> other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Action == other.Action && Keys.SequenceEqual(other.Keys)); }
/// <summary> /// Merge two Redis messages. /// </summary> /// <param name="existingMessage"> /// The existing message, which changes should be merged into. /// </param> /// <param name="newMessage"> /// The new message being merged into <paramref name="existingMessage"/>. /// </param> public static void MergeAction <TKey>(RedisPubSubCacheMessage <TKey> existingMessage, RedisPubSubCacheMessage <TKey> newMessage) { if (existingMessage == null) { throw new ArgumentNullException("existingMessage"); } if (newMessage == null) { throw new ArgumentNullException("newMessage"); } if (existingMessage.Action == RedisPubSubCacheMessageAction.Clear || newMessage.Action == RedisPubSubCacheMessageAction.Clear) { existingMessage.Action = RedisPubSubCacheMessageAction.Clear; existingMessage.Keys = new TKey[0]; } else { existingMessage.Action = RedisPubSubCacheMessageAction.Remove; existingMessage.Keys = existingMessage.Keys.Union(newMessage.Keys).ToArray(); } }