I have a list of files, where each file contains a list of Foo
data. Now, the same piece of Foo data (eg. Id = 1
) might exist in multiple files, but the more recent piece of data would overwrite an existing one.
I'm just reading each piece of data into an in memory collection.
if !cache.HasKey(foo.Id) then Add
else cache[foo.Id].UpdatedOn < foo.UpdatedOn then Update
else do nothing
When i'm reading in the files (cause there's a few of em), I'm also using Parallel.ForEach(files, file => { .. });
I'm not sure how I do this.
I was thinking of using a ConcurrentDictionary
but I wasn't sure how to do an AddOrUpdate
with where clause thingy.
Any suggestions?