November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Regarding alternative 1: this can be done using EPiServer.Common.Queries.QueryHandler.Instance.RemoveQueryResultCache(myquery);
I have kludged my way around this using the RemoveQueryResultCache suggestion. I incorporated this into a IInitializationModule:
[InitializableModule]
public class ForumQueryCacheInitialization : IInitializableModule
{
public static RoomQuery RecentRoomsQuery;
public void Initialize(InitializationEngine context)
{
ForumHandler.Instance.TopicAdded += (sender, args) =>
{
if (RecentRoomsQuery != null)
{
QueryHandler.Instance.RemoveQueryResultCache(RecentRoomsQuery);
}
};
}
public void Uninitialize(InitializationEngine context)
{
}
public void Preload(string[] parameters)
{
}
}
Then in the code actually executing the query I ensure that ForumQueryCacheInitialization.RecentRoomsQuery is updated everytime it is queried, e.g.
// KLUDGE: Force the cache to empty for RecentRoomQuery
ForumQueryCacheInitialization.RecentRoomsQuery = roomQuery;
It seems a bit ugly but I am trying to get a clean fix via EPiServer support.
Hi Lance - did you get anywhere with EPiServer support? I'm having to implement the same fudge for a very similar issue:
I create the topic, if I try to query for it, it's not retured, remove the query result from the cache, query again and it's returned.
When executing the following query:
and then rendering the results in a template (in my case a Razor view):
it appears that the results of the query are cached (for an indeterminate amount of time) but the derived value for "Date of Last Post" is not, e.g.
(code modified from Rooms.ascx.cs GetDateOfLatestPost(RoomBase room) method).
The result is that after a topic update, my displayed list shows the rooms in the same order as before the update, yet the "Last Updated" field IS up-to-date, meaning my list looks out of order.
So the question is, is there any way to:
1. Flush the cache for my RoomQuery manually?
2. Cache the LastChangedTopic with a dependency on the RoomQuery cache key?