SqlDataSource.CacheKeyDependency SqlDataSource.CacheKeyDependency SqlDataSource.CacheKeyDependency SqlDataSource.CacheKeyDependency Property

定义

获取或设置一个用户定义的键依赖项,该键依赖项链接到数据源控件创建的所有数据缓存对象。Gets or sets a user-defined key dependency that is linked to all data cache objects that are created by the data source control. 当键到期时,所有缓存对象都显式到期。All cache objects are explicitly expired when the key is expired.

public:
 virtual property System::String ^ CacheKeyDependency { System::String ^ get(); void set(System::String ^ value); };
public virtual string CacheKeyDependency { get; set; }
member this.CacheKeyDependency : string with get, set
Public Overridable Property CacheKeyDependency As String

属性值

一个键,它标识所有由 SqlDataSource 创建的缓存对象。A key that identifies all cache objects created by the SqlDataSource.

注解

SqlDataSource控件支持数据缓存。The SqlDataSource control supports data caching. 在缓存数据时, Select方法从缓存而不是基础数据库中检索数据。While data is cached, the Select method retrieves data from the cache rather than from the underlying database. 缓存过期后, 该方法Select将从基础数据库中检索数据, 然后再次缓存数据。When the cache expires, the Select method retrieves data from the underlying database, and then caches the data again.

可以将CacheKeyDependency属性设置为在SqlDataSource由控件创建的所有缓存项与键之间创建依赖关系。You can set the CacheKeyDependency property to create a dependency between all cache entries that are created by the SqlDataSource control and the key. 通过使密钥过期, 你可以通过编程方式随时终止所有缓存条目。You can programmatically expire all the cache entries at any time by expiring the key.

SqlDataSource 只有DataSet在模式下, 控件才能缓存数据。The SqlDataSource control can cache data only when in the DataSet mode. 如果NotSupportedException Select 控件设置DataReader为值, 并且还启用了缓存, 则方法会引发异常。 SqlDataSourceA NotSupportedException exception is thrown by the Select method, if the SqlDataSource control is set to the DataReader value and caching is also enabled.

SelectCommandConnectionString和属性的每个组合创建唯一的缓存条目。SelectParametersA unique cache entry is created for every combination of the SelectCommand, ConnectionString, and SelectParameters properties. SqlDataSource控件从同一基础数据库加载相同数据的方案中, 多个控件可以使用相同的缓存条目。Multiple SqlDataSource controls can use the same cache entries in scenarios where the controls load the same data from the same underlying database.

重要

使用 Microsoft Windows 身份验证下的客户端模拟时, 将在第一个用户访问数据时缓存数据。When you are using client impersonation under Microsoft Windows authentication, the data is cached when the first user accesses the data. 如果其他用户请求相同的数据, 则从缓存中检索数据。If another user requests the same data, the data is retrieved from the cache. 通过对数据库进行另一次调用以验证用户对数据的访问权限, 不会检索数据。The data is not retrieved by making another call to the database to verify the user's access to the data. 如果希望有多个用户访问数据, 并且希望数据库的安全配置验证每个数据的检索, 请不要使用缓存。If you expect more than one user to access the data, and you want each retrieval to the data to be verified by the security configurations for the database, do not use caching.

适用于

另请参阅