Recently I am facing an issue in which when ever user open a website some of the static control like slider hit our database. So what I have to do I need to prevent that hit and get data from Cache.
One more thing is that we support multiple language in our website its means when user login as English user he get data in English and when Chinese he will get Chinese and so on , So I need implement multiple language caching.
time define in web.config file
Dim CacheTime As String = ConfigurationManager.AppSettings("CacheTime")
languageId in which i get language of user
If Cache("HomePage" & languageId.ToString()) IsNot Nothing Then
ds = DirectCast(Cache("HomePage" & languageId.ToString()), DataSet)
Else
ds = GetHomePageContent(Me.languageId)
Cache.Insert("HomePage" & languageId.ToString(), ds, Nothing, DateTime.Now.AddSeconds(Convert.ToInt32(CacheTime)), System.Web.Caching.Cache.NoSlidingExpiration)
End If
One more thing is that we support multiple language in our website its means when user login as English user he get data in English and when Chinese he will get Chinese and so on , So I need implement multiple language caching.
time define in web.config file
Dim CacheTime As String = ConfigurationManager.AppSettings("CacheTime")
languageId in which i get language of user
If Cache("HomePage" & languageId.ToString()) IsNot Nothing Then
ds = DirectCast(Cache("HomePage" & languageId.ToString()), DataSet)
Else
ds = GetHomePageContent(Me.languageId)
Cache.Insert("HomePage" & languageId.ToString(), ds, Nothing, DateTime.Now.AddSeconds(Convert.ToInt32(CacheTime)), System.Web.Caching.Cache.NoSlidingExpiration)
End If
No comments:
Post a Comment