Reputation: 411
Given a value (as a key, if you like), look up other values associated with that value, as in columns in a DB table.
I need to do hundreds, and preferably, thousands of these lookups every second.
What I do now:
200,000+ items at 2kb will certainly fit in memory easily enough, but will looking things up in it 1,000/sec+ cause other problems with the system's operation/responsiveness?
Am I even making a 'cache' the right way?
I expect the amount of data to lookup to increase greatly over time, so understanding what to look for in performance to signal switching to a suitable strategy is key.
Upvotes: 1
Views: 321
Reputation: 156554
... will looking things up in it 1,000/sec+ cause other problems with the system's operation/responsiveness?
Not as such: Dictionary<>
s and MemoryCache
s can handle hundreds of thousands of such lookups per second.
But the fact that you're doing the same thing so many times might be a code smell. You may want to consider whether you're missing an opportunity to group your data in some way, so that you're doing a lookup based on a key that is common to all the items that are being retrieved.
Regardless, you'll definitely want to batch the lookups when the time comes to query the database, because hitting the database thousands of times will mess with your performance.
Upvotes: 1