Rodney
If I can just throw my 2 cents in here, there's a slight bug in your code there.
The problem is you're checking the cache twice, so you introduce the possibility of a null reference error, depending on when the system flushes the cache. This normally happens in high-load situations, which increases the chances the cache will be flushed between the two steps:
Your code:
bool userInCache = (DataCache.GetCache(cacheKey) != null);
if (profileCacheSeconds > 0 && userInCache)
{
user = (UserInfo)DataCache.GetCache(cacheKey);
}
else
{
//get it from the DB
Should be:
UserInfo user = (UserInfo)DataCache.GetCache(cacheKey);
if (user == null)
{
//get it from the DB
Doing it this way means you're only pulling from the cache once, so you eliminate the possibility that it is there when the first check runs, and missing when the second check runs. It's a minor issue but one worth noting.
-Bruce