nsICacheSession 编辑

netwerk/cache/public/nsICacheSession.idlScriptable Handles open synchronous and asynchronous cache entry operations along with evicting cache entries and checking for cache devices instantiation according to the session storage policies. Inherits from: nsISupports Last changed in Gecko 14 (Firefox 14 / Thunderbird 14 / SeaMonkey 2.11)

Method overview

void asyncOpenCacheEntry(in ACString key, in nsCacheAccessMode accessRequested, in nsICacheListener listener, [optional] in boolean noWait);
void evictEntries();
PRBool isStorageEnabled();
nsICacheEntryDescriptor openCacheEntry(in ACString key, in nsCacheAccessMode accessRequested, in boolean blockingMode);
void doomEntry(in ACString key, in nsICacheListener listener);

Attributes

AttributeTypeDescription
doomEntriesIfExpiredPRBoolExpired entries will be doomed or evicted if this attribute is set to true. If false, expired entries will be returned (useful for offline mode and clients, such as HTTP, that can update the valid lifetime of cached content). This attribute defaults to true.

Methods

asyncOpenCacheEntry()

This method gives an asynchronous cache access. Does not block the calling thread. Instead, the listener will be notified when the descriptor is available.

void asyncOpenCacheEntry(
  in ACString key,
  in nsCacheAccessMode accessRequested,
  in nsICacheListener listener,
  [optional] in boolean noWait
);
Parameters
key
The key for cache entry.
accessRequested
The requested access.
listener
The cache listener to be notified.
noWait
Do not wait for the cache entry when it is in use and waits for validation.

doomEntry()

Asynchronously dooms an entry specified by the key.

void doomEntry(
  in ACString key,
  in nsICacheListener listener
);
Parameters
key
The key for cache entry.
listener
The cache listener to be notified (may be null).

evictEntries()

This method evicts all entries for this session's clientID according to its storagePolicy.

void evictEntries();
Parameters

None.

isStorageEnabled()

This method checks if the cache devices implied by the session storage policy are currently enabled for instantiation if they don't already exist.

PRBool isStorageEnabled();
Parameters

None.

Return value

Returns whether any of the cache devices implied by the session storage policy are currently enabled for instantiation or not, depending on their existence.

openCacheEntry()

This method gives a synchronous cache access. It returns a unique descriptor each time it is called, even if the same key is specified. When called by multiple threads for WRITE access, only one writable descriptor will be granted. If blockingMode is set to false, it will return NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than block when another descriptor has been given WRITE access but hasn't validated the entry yet.

Note: If at all possible, you should use asyncOpenCacheEntry() instead of calling openCacheEntry(), in order to avoid blocking on I/O on the calling thread. This will streamline overall application performance.

A cache session can only give out one descriptor with WRITE access to a given cache entry at a time. Until the client calls MarkValid on its descriptor, other attempts to open the same cache entry will block.

nsICacheEntryDescriptor openCacheEntry(
  in ACString key,
  in nsCacheAccessMode accessRequested,
  in boolean blockingMode
);
Parameters
key
The key for cache entry.
accessRequested
The requested access.
blockingMode
True or False value to turn blocking mode for calling the thread to ON/OFF respectively.
Return value

Returns a unique descriptor each time it is called.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:76 次

字数:7085

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文