private static ISet <BackplaneMessage> CreateMany(byte[] owner)
        {
            var messages = new HashSet <BackplaneMessage>();
            var key      = Guid.NewGuid().ToString();
            var region   = Guid.NewGuid().ToString();

            // test hash compare works too, result hashset should still have 41 messages only!
            for (var m = 0; m < 10000; m++)
            {
                for (var i = 0; i < 10; i++)
                {
                    messages.Add(BackplaneMessage.ForChanged(owner, key + i, CacheItemChangedEventAction.Update));
                    messages.Add(BackplaneMessage.ForChanged(owner, key + i, region, CacheItemChangedEventAction.Add));
                }

                messages.Add(BackplaneMessage.ForClear(owner));

                for (var i = 0; i < 10; i++)
                {
                    messages.Add(BackplaneMessage.ForClearRegion(owner, region + i));
                }
                for (var i = 0; i < 10; i++)
                {
                    messages.Add(BackplaneMessage.ForRemoved(owner, key + i, region));
                }
            }

            return(messages);
        }
        public void BackplaneMessage_HashClear()
        {
            // arrange
            var owner = new byte[] { 1, 2, 3, 4 };
            var msg   = BackplaneMessage.ForClear(owner);
            var msg2  = BackplaneMessage.ForClear(owner);

            // act
            msg.GetHashCode().Should().Be(msg2.GetHashCode());
        }
        public void BackplaneMessage_EqualsOtherClear()
        {
            // arrange
            var owner = new byte[] { 1, 2, 3, 4 };
            var msg   = BackplaneMessage.ForClear(owner);
            var msg2  = BackplaneMessage.ForClear(owner);

            // act
            msg.Equals(msg2).Should().BeTrue();
        }
        public void BackplaneMessage_Clear()
        {
            // arrange
            var owner = new byte[] { 1, 2, 3, 4 };
            var msg   = BackplaneMessage.ForClear(owner);

            // act
            var serialized   = BackplaneMessage.Serialize(msg);
            var deserialized = BackplaneMessage.Deserialize(serialized).First();

            // assert
            deserialized.Key.Should().Be(null);
            deserialized.Region.Should().Be(null);
            deserialized.ChangeAction.Should().Be(CacheItemChangedEventAction.Invalid);
            deserialized.Action.Should().Be(BackplaneAction.Clear);
            deserialized.OwnerIdentity.ShouldBeEquivalentTo(owner);
            deserialized.ShouldBeEquivalentTo(msg);
        }
Exemple #5
0
        static BackplaneMessageBenchmarkMultiple()
        {
            var messages = new List <BackplaneMessage>();

            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForChanged(_ownderBytes, "somerandomkey" + i, CacheItemChangedEventAction.Update));
                messages.Add(BackplaneMessage.ForChanged(_ownderBytes, "somerandomkey" + i, "withregion", CacheItemChangedEventAction.Add));
            }
            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForClear(_ownderBytes));
            }
            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForClearRegion(_ownderBytes, "somerandomregion" + i));
            }
            for (var i = 0; i < 10; i++)
            {
                messages.Add(BackplaneMessage.ForRemoved(_ownderBytes, "somerandomkey" + i, "withregion"));
            }
            _multiple = messages.ToArray();
        }
Exemple #6
0
 /// <summary>
 /// Notifies other cache clients about a cache clear.
 /// </summary>
 public override void NotifyClear()
 {
     this.PublishMessage(BackplaneMessage.ForClear(this.identifier));
 }
Exemple #7
0
 /// <summary>
 /// Notifies other cache clients about a cache clear.
 /// </summary>
 public override Task NotifyClearAsync()
 {
     return(PublishMessageAsync(BackplaneMessage.ForClear(_identifier)));
 }