public CacheMultiShard(CacheShard first) { if (first == null) { throw new ArgumentNullException("first"); } count = first.Count; if (count != ShardSize) { throw new ArgumentException("First shard must be exactly full", "first"); } shards.Add(first); }
int IObjectCache.Append(object obj) { CacheShard shard; if (count % ShardSize == 0) { // last shard is full shard = new CacheShard(); shards.Add(shard); } else { shard = (CacheShard)shards[shards.Count - 1]; } shard.Append(obj, count); return(count++); // note this is post-additive; if we have 10 items, the index of the new (11th) is 10 }