那是缓存还是缓存?
Is that caches or cache?
我正在阅读 google slide 有关渐进式 Web 应用程序的文章,其中提到缓存接口具有以下方法
cache.add()
cache.addAll()
cache..put()
cache.delete()
cache.keys()
cache.match()
cache.matchAll()
但在实际实施的进一步幻灯片中,他们有时使用 caches(带 s ),有时使用 缓存
caches.open() // whereas this method was not mentioned anywhere
caches.keys()
caches.delete()
caches.match()
cache.put () // only here using cache
另外,在 MDN
中检查是否相同
他们正在写 Cache.add、Cache.addAll 和 Cache.put(大写 c)
并使用caches.open、cache.match()等方法
我想知道 cache 和 caches 是两个不同的对象(或接口)还是我在这里缺少什么?
请提供一些资源或链接以了解更多信息。
缓存在各种用例中都非常有用。例如,当一个值的计算或检索成本很高时,您应该考虑使用缓存,并且您将不止一次地在某个输入上需要它的值。
A Cache 类似于ConcurrentMap,但又不完全相同。最根本的区别是 ConcurrentMap 会保留所有添加到它的元素,直到它们被显式删除。另一方面,缓存通常配置为自动逐出条目,以限制其内存占用。在某些情况下,LoadingCache 即使不逐出条目也很有用,因为它会自动加载缓存。
window.caches
是一个CacheStorage
interface which stores all named Cache
对象。例如 window.caches.open()
方法 returns 解析为 Cache
对象的承诺。
// Get a named Cache object from CacheStorage
window.caches.open('cachename').then(cache => {
// Work with resolved cache object (instance of Cache)
});
所以每当他们引用 caches
时,他们指的是全局 CacheStorage
接口,而 cache
是任意命名的变量,用于存储一个 Cache
是 [=25] =].
缓存准确的说就是存放缓存对象。还引用了 progressive Web apps
的 link 所附图片中的示例(Google Chrome 中的开发者工具)
要了解有关缓存的更多信息,请参阅 CacheStorage.
(因为 "You can access CacheStorage through the global caches property" 所以这是一回事。)
我正在阅读 google slide 有关渐进式 Web 应用程序的文章,其中提到缓存接口具有以下方法
cache.add()
cache.addAll()
cache..put()
cache.delete()
cache.keys()
cache.match()
cache.matchAll()
但在实际实施的进一步幻灯片中,他们有时使用 caches(带 s ),有时使用 缓存
caches.open() // whereas this method was not mentioned anywhere
caches.keys()
caches.delete()
caches.match()
cache.put () // only here using cache
另外,在 MDN
中检查是否相同他们正在写 Cache.add、Cache.addAll 和 Cache.put(大写 c)
并使用caches.open、cache.match()等方法
我想知道 cache 和 caches 是两个不同的对象(或接口)还是我在这里缺少什么?
请提供一些资源或链接以了解更多信息。
缓存在各种用例中都非常有用。例如,当一个值的计算或检索成本很高时,您应该考虑使用缓存,并且您将不止一次地在某个输入上需要它的值。
A Cache 类似于ConcurrentMap,但又不完全相同。最根本的区别是 ConcurrentMap 会保留所有添加到它的元素,直到它们被显式删除。另一方面,缓存通常配置为自动逐出条目,以限制其内存占用。在某些情况下,LoadingCache 即使不逐出条目也很有用,因为它会自动加载缓存。
window.caches
是一个CacheStorage
interface which stores all named Cache
对象。例如 window.caches.open()
方法 returns 解析为 Cache
对象的承诺。
// Get a named Cache object from CacheStorage
window.caches.open('cachename').then(cache => {
// Work with resolved cache object (instance of Cache)
});
所以每当他们引用 caches
时,他们指的是全局 CacheStorage
接口,而 cache
是任意命名的变量,用于存储一个 Cache
是 [=25] =].
缓存准确的说就是存放缓存对象。还引用了 progressive Web apps
的 link 所附图片中的示例(Google Chrome 中的开发者工具)(因为 "You can access CacheStorage through the global caches property" 所以这是一回事。)