Just found a nasty little bug in the
VB code!
I'm in the process of writing a new Forum from scratch and could not come up with an effective way of caching the threads ViewCount, so I fired up the original TBH site to see how Marco dealt with it. Basically TBH updates the threads ViewCount field in the database every time the thread is viewed. However, the thread's cache is never purged when the ViewCount is updated, so I could not figure out how the ShowThreads page is reporting the proper ViewCount if the cache is stale. After several hours of head banging I finally discovered that the Forums cache was never working in the
VB version. Consequently the Forum data is loaded from the DB for every page load.
The problem is a missing "Not" operator in the following BaseForum.
vb method:
Code:
Protected Shared Sub CacheData(ByVal key As String, ByVal data As Object)
If Settings.EnableCaching AndAlso Not IsNothing(data) Then
BizObject.Cache.Insert(key, data, Nothing, DateTime.Now.AddSeconds(Settings.CacheDuration), TimeSpan.Zero)
End If
End Sub
Without the "Not" the Forum data is never cached. Unfortunately, once the cache is fixed the thread's ViewCount will not display properly.
I know others have reworked the forum code and I would be interested to know how you dealt with the ViewCount issue.