nsICache 编辑

The nsICache is a namespace for various cache constants. It does not represent an actual object.

netwerk/cache/public/nsICache.idlScriptable Please add a summary to this article.   Last changed in Gecko 1.9 (Firefox 3)

Inherits from: nsISupports

Constants

ConstantValueDescription
ACCESS_NONE0ACCESS GRANTED - No descriptor is provided.
ACCESS_READ1ACCESS REQUESTED - I only want to READ, if there isn't an entry just fail.

ACCESS GRANTED - You can READ from this descriptor.

ACCESS_WRITE2ACCESS REQUESTED - I have something new I want to WRITE into the cache, make me a new entry and doom the old one, if any.

ACCESS GRANTED - You must WRITE to this descriptor because the cache entry was just created for you.

ACCESS_READ_WRITE3ACCESS REQUESTED - I want to READ, but I'm willing to update an existing entry if necessary, or create a new one if none exists.

ACCESS GRANTED - You can READ the descriptor to determine if it's valid, you may WRITE if it needs updating.

STORE_ANYWHERE0The storage policy of a cache entry determines the device(s) to which it belongs. See nsICacheSession and nsICacheEntryDescriptor for more details.

Allows the cache entry to be stored in any device. The cache service decides which cache device to use based on "some resource management calculation."

STORE_IN_MEMORY1The storage policy of a cache entry determines the device(s) to which it belongs. See nsICacheSession and nsICacheEntryDescriptor for more details.

Requires the cache entry to reside in non-persistent storage. That is typically in system RAM.

STORE_ON_DISK2The storage policy of a cache entry determines the device(s) to which it belongs. See nsICacheSession and nsICacheEntryDescriptor for more details.

Requires the cache entry to reside in persistent storage. That is typically on a system's hard disk.

STORE_ON_DISK_AS_FILE3The storage policy of a cache entry determines the device(s) to which it belongs. See nsICacheSession and nsICacheEntryDescriptor for more details.

Requires the cache entry to reside in persistent storage, and in a separate file.

STORE_OFFLINE4The storage policy of a cache entry determines the device(s) to which it belongs. See nsICacheSession and nsICacheEntryDescriptor for more details.

Requires the cache entry to reside in persistent, reliable storage for offline use.

NOT_STREAM_BASED0All entries for a cache session are stored as streams of data or as objects. This constant specify that cache session is not a stream based entry when calling nsICacheService.createSession() method.
STREAM_BASED1All entries for a cache session are stored as streams of data or as objects. This constant specify that cache session is a stream based entry when calling nsICacheService.createSession() method.
NON_BLOCKING0The synchronous OpenCacheEntry() may be blocking or non-blocking. If a cache entry is waiting to be validated by another cache descriptor (so no new cache descriptors for that key can be created), OpenCacheEntry() will return NS_ERROR_CACHE_WAIT_FOR_VALIDATION in non-blocking mode. If the cache entry is validated, then a descriptor for that entry will be created and returned. If the cache entry was doomed, then a descriptor will be created for a new cache entry for the key.
BLOCKING1The synchronous OpenCacheEntry() may be blocking or non-blocking. In blocking mode, it will wait until the cache entry for the key has been validated or doomed. If the cache entry is validated, then a descriptor for that entry will be created and returned. If the cache entry was doomed, then a descriptor will be created for a new cache entry for the key.
Note: If you think that you might need to modify cached data or meta data, then you must open a cache entry requesting WRITE access. Only one cache entry descriptor, per cache entry, will be granted WRITE access.

Usually, you will request READ_WRITE access in order to first test the meta data and informational fields to determine if a write, that is going to the net, may actually be necessary. If you determine that it is not, then you would mark the cache entry as valid (using MarkValid) and then simply read the data from the cache.

A descriptor granted WRITE access has exclusive access to the cache entry up to the point at which it marks it as valid. Once the cache entry has been "validated", other descriptors with READ access may be opened to the cache entry.

If you make a request for READ_WRITE access to a cache entry, the cache service will downgrade your access to READ if there is already a cache entry descriptor open with WRITE access.

If you make a request for only WRITE access to a cache entry and another descriptor with WRITE access is currently open, then the existing cache entry will be 'doomed', and you will be given a descriptor (with WRITE access only) to a new cache entry.

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

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

发布评论

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

词条统计

浏览:108 次

字数:7724

最后编辑:8年前

编辑次数:0 次

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