Web.Config文件中的WebPartCache元素

Web Part的开发者能够使用Web Part cache来存储属性值, 加速数据的取出. web part cache中的值按照单个part方式, 或者是单个用户的方式来存储, 指定的方式是调用PartCacheReadPartCacheWrite 方法.

 

你能够决定使用的cache的类型- 要么是SharePoint 数据库, 要么是ASP.NET缓存对象- 通过配置web.config文件中的WebPartCache元素. 可能的值如下:

  • None 禁止缓存.
  • Database 使用SharePoint数据库做缓存
  • CacheObject 使用ASP.NET Cache object进行缓存(默认).

举个例子, 若要使用SharePoint 数据库做缓存, 你需要创建下面的web.config的entry:

<SharePoint>
  <WebPartCache Storage="Database"/>
</SharePoint>

 

缓存细节

=========

你可以使用WebPart class的PartCacheWritePartCacheRead来管理缓存, 还有PartCacheInvalidate方法来似的部分或全部的web part cache变为非法的(比如说, 如果web part的一个属性变了). 为了在运行时获得缓存的信息, 你需要使用CacheType属性.

 

寻找cache entry的方法是使用一个键值, 这允许任意数目的name-value pair被存储在cache中.

 

使用SharePoint Database

================

During cache storage in in the database, the following occurs:

  • If parts are not personalized, Personal cache entries (a call to the PartCacheWrite method with storage set to Storage.personal) are not stored.
  • If parts are Personal (added to the page in personal view), the Shared and Personal cache entries are stored in the same place. If the PartCacheInvalidate method is called with a storage value of Shared or Personal, all the cache is cleared.

When using the database for storage, both the Shared and Personal cache are limited to 2 MB. If this limit is exceeded, no error is displayed, but the cache entry will be lost. Additionally, if the storage type is Personal, it is charged against the user's quota.

 

Any object placed in the database cache must be marked as serializable (System.SerializableAttribute).

 

使用ASP.NET cache object

=================

ASP.NET also provides caching functionality that the Web Part can use through the Cache object.

 

Caches stored using ASP.NET are limited by the size allowed by the Cache object. For more information about the Cache class, see the System.Web.Caching namespace.

 

Note  Static Web Parts can only use caching if WebPartCacheStorage is set to CacheObject. No exception is raised if the setting is Database, but no cache entry is stored. Changes to the .aspx file cause the Web Part cache to get purged for static Web Parts.

 

资料来源:

Web Parts and Caching

http://msdn.microsoft.com/en-us/library/dd585600%28office.11%29.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值