Example #1
0
        public void AddOrUpdate(TObject item)
        {
            TKey key      = _keySelector.GetKey(item);
            var  previous = _cache.Lookup(key);

            _queue.Add(previous.HasValue
                               ? new Change <TObject, TKey>(ChangeReason.Update, key, item, previous)
                               : new Change <TObject, TKey>(ChangeReason.Add, key, item));
            _cache.AddOrUpdate(item, key);
        }
Example #2
0
        public void AddOrUpdate(TObject item)
        {
            if (_keySelector == null)
            {
                throw new KeySelectorException("A key selector must be specified");
            }

            var key = _keySelector.GetKey(item);

            _cache.AddOrUpdate(item, key);
        }
        public override int SelectChannel(SerializationDelegate <StreamRecord <TData> > record)
        {
            TKey key;

            try
            {
                key = keySelector.GetKey(record.Instance.Value);
            }
            catch (Exception e)
            {
                throw new RuntimeException($"Could not extract key from {record.Instance}", e);
            }

            return(partitioner.Partition(key, NumberOfChannels));
        }