コード例 #1
0
        public bool RemoveMessage(string topic, string messageId)
        {
            TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

            if (topicStats != null)
            {
                int preUpdateSize = topicStats.InMemorySize;

                if (!topicStats.Remove(messageId))
                {
                    int postUpdateSize = topicStats.InMemorySize;

                    if (preUpdateSize != postUpdateSize)
                    {
                        _size -= preUpdateSize - postUpdateSize;
                    }
                }
                else
                {
                    _topicWiseMessageIds.Remove(topic);
                    _size -= preUpdateSize;
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: BucketStatistcs.cs プロジェクト: yongwuhou/NCache
        public OrderedDictionary GetTopicWiseMessagIds(bool includeEventMessages)
        {
            OrderedDictionary topicWiseMessages = new OrderedDictionary();

            foreach (string topic in _topicWiseMessageIds.Keys)
            {
                if (topic == null)
                {
                    continue;
                }

                if (TopicConstant.AllEventTopics.Contains(topic) && !includeEventMessages)
                {
                    continue;
                }

                TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

                if (topicStats != null)
                {
                    topicWiseMessages.Add(topic, topicStats.GetMessageIds());
                }
            }

            return(topicWiseMessages);
        }
コード例 #3
0
        public bool RemoveTopic(string topic)
        {
            TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

            if (topicStats != null)
            {
                _size -= topicStats.InMemorySize;
                _topicWiseMessageIds.Remove(topic);
                return(true);
            }
            return(false);
        }
コード例 #4
0
        public OrderedDictionary GetTopicWiseMessagIds()
        {
            OrderedDictionary topicWiseMessages = new OrderedDictionary();

            foreach (string topic in _topicWiseMessageIds.Keys)
            {
                TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

                if (topicStats != null)
                {
                    topicWiseMessages.Add(topic, topicStats.GetMessageIds());
                }
            }

            return(topicWiseMessages);
        }
コード例 #5
0
        public void AddMessage(string topic, string messageId)
        {
            TopicWiseBucketStatistics topicStats = _topicWiseMessageIds[topic] as TopicWiseBucketStatistics;

            if (topicStats == null)
            {
                topicStats = new TopicWiseBucketStatistics(topic);
                _topicWiseMessageIds.Add(topic, topicStats);
            }

            int preUpdateSize = topicStats.InMemorySize;

            topicStats.AddMessage(messageId);
            int postUpdateSize = topicStats.InMemorySize;

            if (preUpdateSize != postUpdateSize)
            {
                _size += postUpdateSize - preUpdateSize;
            }
        }