I get data from external application:
class DataItem
{
public string key;
public int Attribute1;
public string Attribute2;
}
One thread store it in collection.
Other threads (3-10) query collection by key (90%) and attributes (10%).
What is the best way to implement this If I have 10, 100, 1000+ items in collection?
If you are really wanting an in-memory database then Sqlite using the managed data provider would be your best option. However, I suspect in this case you would be okay with the ConcurrenctDictionary. This collection could easily handle 1000+ items and many threads accessing it in parallel. The caveat with using this collection is that you can specify only one key for each entry in the collection. You may need to use separate collections for each attribute you want to lookup. Then again, if lookups by an attribute are infrequent enough then you could opt for enumerating the entire collection to find matching attributes without the need for separate collections.