本文整理汇总了VB.NET中System.Web.Configuration.CacheSection类的典型用法代码示例。如果您正苦于以下问题:VB.NET CacheSection类的具体用法?VB.NET CacheSection怎么用?VB.NET CacheSection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CacheSection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CType
' 导入命名空间
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Partial Public Class ReadWriteCache
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
Label1.Text = "Application Cache goes here."
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
' Get the application configuration file.
Dim config As System.Configuration.Configuration =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/")
Dim cacheSection As System.Web.Configuration.CacheSection =
CType(config.GetSection("system.web/caching/cache"), System.Web.Configuration.CacheSection)
' Increase the PrivateBytesLimit property to 0.
cacheSection.PrivateBytesLimit = cacheSection.PrivateBytesLimit + 10
' Increase memory limit.
cacheSection.PercentagePhysicalMemoryUsedLimit =
cacheSection.PercentagePhysicalMemoryUsedLimit + 1
' Increase poll time.
cacheSection.PrivateBytesPollTime =
cacheSection.PrivateBytesPollTime + TimeSpan.FromMinutes(1)
' Enable or disable memory collection.
cacheSection.DisableMemoryCollection =
Not cacheSection.DisableMemoryCollection
' Enable or disable cache expiration.
cacheSection.DisableExpiration =
Not cacheSection.DisableExpiration
' Save the configuration file.
config.Save(System.Configuration.ConfigurationSaveMode.Modified)
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
' Get the application configuration file.
Dim config As System.Configuration.Configuration =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/")
Dim cacheSection As System.Web.Configuration.CacheSection =
CType(config.GetSection("system.web/caching/cache"), System.Web.Configuration.CacheSection)
' Read the cache section.
Dim buffer As New System.Text.StringBuilder()
Dim currentFile As String = cacheSection.CurrentConfiguration.FilePath
Dim dExpiration As Boolean = cacheSection.DisableExpiration
Dim dMemCollection As Boolean = cacheSection.DisableMemoryCollection
Dim pollTime As TimeSpan = cacheSection.PrivateBytesPollTime
Dim phMemUse As Integer = cacheSection.PercentagePhysicalMemoryUsedLimit
Dim pvBytesLimit As Long = cacheSection.PrivateBytesLimit
Dim cacheEntry As String = String.Format("File: {0} <br/>", currentFile)
buffer.Append(cacheEntry)
cacheEntry = String.Format("Expiration Disabled: {0} <br/>", dExpiration)
buffer.Append(cacheEntry)
cacheEntry = String.Format("Memory Collection Disabled: {0} <br/>", dMemCollection)
buffer.Append(cacheEntry)
cacheEntry = String.Format("Poll Time: {0} <br/>", pollTime.ToString())
buffer.Append(cacheEntry)
cacheEntry = String.Format("Memory Limit: {0} <br/>", phMemUse.ToString())
buffer.Append(cacheEntry)
cacheEntry = String.Format("Bytes Limit: {0} <br/>", pvBytesLimit.ToString())
buffer.Append(cacheEntry)
Label1.Text = buffer.ToString()
End Sub
End Class