hi
Iâm looking at the way Marco implemented caching, and some of the implementation decisions the guy made simply donât make sense to me, and besides feeling really dumb Iâm also afraid that perhaps Iâm missing the big picture. So I would really appreciate if someone could help me with my questions:
1)
UpdatePost() method caches the following items:
Code:
BizObject.PurgeCacheItems("forums_unapprovedposts");
BizObject.PurgeCacheItems("forums_threads");
BizObject.PurgeCacheItems("forums_threadcount");
BizObject.PurgeCacheItems("forums_thread_" + id.ToString());
BizObject.PurgeCacheItems("forums_post_" + id.ToString());
a) Shouldnât we first check whether the updated post is unapproved and only then then purge "
forums_unapprovedposts" entry from the cache?
b) Wouldnât purging "
forums_threads" make sense only if the updated post was also a main post? So why donât we first check if it is indeed a main post and then purge "
forums_threads" entries?
c) I donât see any point in purging "
forums_threadcount", since we didnât create a new thread?
2)
InsertPost() method purges:
Code:
if (approved)
{
BizObject.PurgeCacheItems("forums_threads");
BizObject.PurgeCacheItems("forums_thread_" + parentPostID.ToString());
BizObject.PurgeCacheItems("forums_threadcount");
}
else
BizObject.PurgeCacheItems("forums_unapprovedposts");
a) Again, doesnât purging "
forums_threads" and â
forums_threadcountâ only make sense if inserted post is also a main post?
3)
DeletePost() method purges entries:
Code:
BizObject.PurgeCacheItems("forums_unapprovedposts");
BizObject.PurgeCacheItems("forums_threads");
BizObject.PurgeCacheItems("forums_threadcount");
BizObject.PurgeCacheItems("forums_thread_" + id.ToString());
BizObject.PurgeCacheItems("forums_post_" + id.ToString());
a) But shouldnât we first check whether deleted post is also unapproved, since by checking this, we may not need to also purge "
forums_threads", "
forums_threadcountâ, "
forums_thread_" + id.ToString()" entries, which would save us from quite a few trips to a database?!
4)
CloseThread() method only purges â
forums_thread_" + threadPostID.ToString()" and â
forums_post_" + threadPostID.ToString()".
a)But shouldnât it also purge â
forums_threadsâ and â
forums_threadcountâ?
5) Also, wonât
MoveThread() cause non-main posts ( belonging to the thread we moved ) to contain invalid data, since their
Post.ForumID property wonât return correct result?
6) Why doesnât
GetPostCountByThread() method also cache the resulting value?
I would really appreciate some help