Hi,
I use caching heavily in my Smart-Thinker modules, for example UserProfiles are cached. I upgraded PokerDIY to DNN 4.9.0 yesterday and have noticed that the caching does not seem to be expiring. Running the PurgeCache Task manually does not clear it (are they not related?) and the only thing that does is to restart the application. For example, this user edited their profile and the changes are not reflected until the application is restarted.
This was working fine pre-4.9 and I could not find anything in the release notes that indicated a change in this behaviour. There are no dodgy Event Viewer messages.
Here is my code - can anyone shed any light on why this stopped working?
public UserInfo GetUserFromCacheOrDB(int portalID, int userID, int profileCacheSeconds)
{
//check if caching must be used - check if this user record is in the cache, and use it
string cacheKey = portalID.ToString() + "UserID" + userID.ToString();
UserInfo user = null;
if (profileCacheSeconds > 0)
{
user = (UserInfo)DataCache.GetCache(cacheKey);
}
if (user == null)
{
//not in cache or caching is not used, get from the DB
user = new UserController().GetUser(portalID, userID);
if (user != null && profileCacheSeconds > 0)
{
//add it to the cache with an absolute expiry time
DataCache.SetCache(cacheKey, user, DateTime.Now.AddSeconds(profileCacheSeconds));
}
}
return user;
}