November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
I ended up with the following, but it seems to be a giant CPU hog and kind of overloads the SQL server, so I'm going to back to the old solution with a stored procedure.
public static EntryCollection GetLatestPublishedEntriesByCategory(ICategory category, int maxCount)
{
var query = new EntryQuery
{
Blog = new BlogCriterion
{
BlogType = new BlogTypeCriterion { Operator = ComparisonOperator.Equals, Value = BlogType.UserBlog }
},
Categories = new CategoryCollectionCriterion
{
Containing = new CategoryCriterion
{
ID = new IntegerCriterion { Operator = ComparisonOperator.Equals, Value = category.ID }
}
},
PublicationStart = new DateTimeCriterion { Operator = ComparisonOperator.LessThan, Value = DateTime.Now }
};
query.OrderBy.Add(new CriterionSortOrder(query.PublicationStart, SortingDirection.Descending));
int totalItems;
var blogEntries = QueryHandler.Instance.GetQueryResult<Entry, EntryCollection>(query, null, 1, maxCount, out totalItems);
return blogEntries;
}
I had to revert back to the stored procedure because the query caused way, WAY too high a load on the database server. Now I just cache the results forever until there are changes to blogs and/or blog entries.
Hi,
I have a problem I hope someone can help me with...
I have a user control which lists the X latest published blog entries, selected from all blogs on the site. When you click on the entries in the list, you get to the blog page, listing the latest entries for that particular blog, sorted in descending order. The user control fetches the list of the latest blog entries using a SQL stored procedure, and caches the id:s of the entries for 5 minutes. The blog page relies on EPiServer Community's internal caching functions.
The problem I have is that this is a load balanced environment, currently running 3 web servers. If user A publishes a new blog entry on server 1 (and that server sends out a cache invalidation message), and user B is sent to server 2 or 3 and loads the page containing the "latest blog entries" user control, and then clicks the blog entry just published by user A, the page doesn't show the latest blog entry.
I haven't been able to determine exactly when this happens, it doesn't happen all the time (it happens every now and then, or at least the users only reports it every now and then).
My guess is that sometimes the cache invalidation messages gets lost, or it might take longer than usual for them to be sent out/processed, so the cache on the other servers aren't invalidated properly, and thus the servers might show outdated information.
Is there a better way of getting the latest blog entries than using a stored procedure, preferably using the same cached data as the BlogHandler.GetEntries() uses (or that gets invalidated at the same time)?
The users of the site gets very confused when they see a list of latest blog entries, but are unable to see the entry in the blog.
/Paddy