首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • go实现redis集群和单机快速切换

    *CacheStorage func DB() *CacheStorage { return cacheStorage} // cache storage//// 优先级: redisCluster > redis > local type CacheStorage struct { local *gcache.Cache redis *redis.Client = &CacheStorage{ local: gcache.New(), } if rdbc := newClusterClient(redisConfig); rdbc = nil { cacheStorage.cluster = rdbc log.Info("using redis cluster") } else if = nil { cacheStorage.redis = rdb log.Info("using redis single") } else {

    34810编辑于 2025-02-09
  • 来自专栏centosDai

    前端性能优化(三)——浏览器九大缓存方法

    8、cacheStorage cacheStorage 表示 cache对象的存储。该接口提供 serviceWorker 或其他类型的工作线程或window范围访问的所有命名缓存的主目录。 CacheStorage常见方法: CacheStorage.match() - 检查给定的 Request 对象是否是 CacheStorage 对象跟踪的 Cache 对象中的键,返回Promise CacheStorage.has() - 返回一个 Promise,它解析为与 cacheName 相匹配的 Cache 对象。 CacheStorage.delete() - 删除cache对象 CacheStorage.keys() - 含有keys中字符串的任意一个,则返回一个promise对象。 cacheStorage.has() - 如果包含cache对象,则返回一个promise对象。

    2.3K30发布于 2021-10-01
  • 来自专栏centosDai

    前端性能优化(三)——浏览器九大缓存方法

    8、cacheStorage cacheStorage 表示 cache对象的存储。该接口提供 serviceWorker 或其他类型的工作线程或window范围访问的所有命名缓存的主目录。 CacheStorage常见方法: CacheStorage.match() - 检查给定的 Request 对象是否是 CacheStorage 对象跟踪的 Cache 对象中的键,返回Promise CacheStorage.has() - 返回一个 Promise,它解析为与 cacheName 相匹配的 Cache 对象。 CacheStorage.delete() - 删除cache对象 CacheStorage.keys() - 含有keys中字符串的任意一个,则返回一个promise对象。 cacheStorage.has() - 如果包含cache对象,则返回一个promise对象。

    1.6K30编辑于 2021-11-30
  • 来自专栏centosDai

    前端性能优化(三)——浏览器九大缓存方法

    8、cacheStorage cacheStorage 表示 cache对象的存储。该接口提供 serviceWorker 或其他类型的工作线程或window范围访问的所有命名缓存的主目录。 CacheStorage常见方法: CacheStorage.match() - 检查给定的 Request 对象是否是 CacheStorage 对象跟踪的 Cache 对象中的键,返回Promise CacheStorage.has() - 返回一个 Promise,它解析为与 cacheName 相匹配的 Cache 对象。 CacheStorage.delete() - 删除cache对象 CacheStorage.keys() - 含有keys中字符串的任意一个,则返回一个promise对象。 cacheStorage.has() - 如果包含cache对象,则返回一个promise对象。

    2.4K20发布于 2021-09-30
  • 来自专栏charlieroro

    go 语言的一个赋值操作

    Replace([]interface{}, string) error Resync() error } type cache struct { // cacheStorage bears the burden of thread safety for the cache cacheStorage ThreadSafeStore // keyFunc is used to

    67920发布于 2020-03-23
  • 来自专栏前端小兵成长营

    项目实战|基础请求封装

    ${qs.stringify(query)}` : url if (this.cacheStorage) { if (this.cacheStorage.getItem(key) ) { return Promise.resolve(this.cacheStorage.getItem(key)) } else { return this.preSend({ url: key, headers, method: 'GET' }).then(data => { this.cacheStorage.setItem

    68133发布于 2020-10-14
  • 来自专栏也许吧

    【腾讯云前端性能优化大赛】两种非常规性能优化手段

    delete tag.attributes.src tag.attributes.async = false } tag.innerHTML = \`// From CacheStorage inlineTag(tag, innerHTML)) ) } else { console.info(\`From CacheStorage 当浏览器运行到这段代码时,带有特定标识符的 js、css 文件通过 cache.add() API 下载,并储存到 CacheStorage 中,接着把下载到的代码通过 script 标签注入到 HTML ).then(r => r); }) ); } }); 此方案为使用 Service Worker 技术中对 fetch 方法的监听,当 fetch 请求失败时,自动使用 CacheStorage

    4K132编辑于 2021-12-30
  • 来自专栏k8s技术圈

    client-go 之 Indexer 的理解

    是一个线程安全的存储 cacheStorage ThreadSafeStore // keyFunc 用于计算对象键 keyFunc KeyFunc } 我们可以看到这个 cache 包含一个 = nil { return KeyError{obj, err} } // 将对象添加到底层的 ThreadSafeStore 中 c.cacheStorage.Add(key, obj) = nil { return KeyError{obj, err} } c.cacheStorage.Update(key, obj) return nil } // 删除cache中的对象 (c *cache) List() []interface{} { return c.cacheStorage.List() } // 得到cache中所有的对象键 func (c *cache) () Indexers { return c.cacheStorage.GetIndexers() } // 得到对象obj与indexName索引器关联的所有对象 func (c *cache)

    2.9K30发布于 2020-09-04
  • 来自专栏TA码字

    K8s源码分析(25)-Store组件和Indexer组件

    client-go/tools/cache/store.go type KeyFunc func(obj interface{}) (string, error) type cache struct { cacheStorage = nil { return KeyError{obj, err} } c.cacheStorage.Add(key, obj) return nil } func (c *cache //k8s.io/client-go/tools/cache/store.go func NewStore(keyFunc KeyFunc) Store { return &cache{ cacheStorage map and a lock. func NewIndexer(keyFunc KeyFunc, indexers Indexers) Indexer { return &cache{ cacheStorage

    58920编辑于 2022-10-30
  • 来自专栏实战docker

    client-go的Indexer三部曲之三:源码阅读

    就是真正保存数据的地方,第二个keyFunc,就是往Indexers中添加记录的时候,为该记录生成对象主键的方法 type cache struct { // cacheStorage bears the burden of thread safety for the cache cacheStorage ThreadSafeStore // keyFunc is used to make the NewIndexer方法的入参来设置的, func NewIndexer(keyFunc KeyFunc, indexers Indexers) Indexer { return &cache{ cacheStorage func (c *cache) IndexKeys(indexName, indexKey string) ([]string, error) { return c.cacheStorage.IndexKeys (indexName, indexKey) } 打开c.cacheStorage.IndexKeys方法,如下所示,没有任何意外,只要找到Index就算成功了 func (c *threadSafeMap

    42220编辑于 2023-07-10
  • 来自专栏Web大前端

    PWA进阶:离线存储与推送通知的高级技巧

    资源更新检测:使用CacheStorage.keys()和CacheStorage.delete()方法,定期检查并清除过期的缓存。

    1.4K10编辑于 2024-05-19
  • 来自专栏柒八九技术收纳盒

    Web性能优化之Worker线程(下)

    CacheStorage 对象 ❝CacheStorage 对象是映射到 Cache 对象的字符串「键/值存储」 ❞ CacheStorage 提供的 API 类似于「异步 Map」。 CacheStorage 的接口通过全局对象的 caches 属性暴露出来。 console.log(caches); // CacheStorage {} CacheStorage 中的每个缓存可以通过给 caches.open()传入相应「字符串键」取得。 Cache 对象跟 CacheStorage 一样,类似于「异步 Map」。 Cache 键可以是 URL 字符串,也可以是 Request 对象。这些键会「映射」到 Response 对象。 ()都支持可选的 options 对象,它允许通过设置以下属性来配置 URL 匹配的行为 cacheName: 只有 CacheStorage.matchAll()支持。

    3K20编辑于 2022-08-25
  • 来自专栏零域Blog

    PWA 方案相关技术分享

    caches.match() 用于检查 CacheStorage 中是否存在以 Request 为 key 的 Cache 对象。 caches.keys() 用于返回 CacheStorage 中所有 Cache 对象的 cacheName 列表。 主要使用的技术: App Manifest Service Worker cacheStorage App Manifest 添加 manifest.json 文件。 参考文献: 服务工作线程:简介 Web 技术文档 Web API 接口 ServiceWorker 借助Service Worker和cacheStorage缓存及离线开发 网站渐进式增强体验(PWA)

    1.1K20编辑于 2022-03-25
  • 来自专栏鱼头的Web海洋

    Service Worker初探

    CacheStorage API 在Service Worker中,我们通常使用CacheStorage来管理缓存。 CacheStorage是一种全新的缓存层,让我们对缓存具有完全的控制权。 CacheStorage为我们提供了一系列的api来操作缓存。这些api都是基于Promise的,所有方法的返回值都是一个Promise。 CacheStorage和http缓存的关系 ? 在发送http请求的时候,请求会先到达Service Worker。 CacheStorage不能取代过去的HTTP缓存。CacheStorage因为Service Worker的作用域问题,只能控制范围内的缓存,无法控制cdn和在其他域下的接口数据。 使用indexedDB传递参数 Service Worker环境中,除了CacheStorage外,也可以使用基于浏览器的本地数据库indexedDB。

    1.6K20发布于 2020-09-22
  • 来自专栏k-cloud-labs

    Informer LocalStore源码解析

    test-app”:}}} 如果还是不懂,就先往下看,看Indexer的具体实现 // 代码源自client-go/tools/cache/store.go type cache struct { // cacheStorage bears the burden of thread safety for the cache cacheStorage ThreadSafeStore // keyFunc is used = nil { return KeyError{obj, err} } c.cacheStorage.Add(key, obj) return nil } 代码很简单,就是通过

    42100编辑于 2023-03-28
  • 来自专栏终身学习者

    JavaScript是如何工作的:存储引擎+如何选择合适的存储API

    使用 CacheStorage.open(cacheName) 打开一个Cache 对象,再使用 Cache 对象的方法去处理缓存. CacheStorage 接口表示 Cache 对象的存储。 使用 CacheStorage.open() 获取 Cache 实例。 使用 CacheStorage.match() 检查给定的 Request 是否是 CacheStorage 对象跟踪的任何 Cache 对象中的键。 你可以通过 caches 属性访问 CacheStorage . IndexedDB ? IndexedDB 是一种在用户浏览器中持久存储数据的方法。

    2.3K10发布于 2019-01-29
  • 来自专栏杰的记事本

    Service Worker实现离线应用PWA的简单介绍

    离线应用相关接口 CacheStorage 在浏览器上的引用名叫 caches,CacheStorage 是多个 Cache 的集合,而每个 Cache 可以存储多个 Response 对象。

    1.1K20发布于 2019-09-04
  • 来自专栏后端云

    client-go 源码分析(5) - informer机制中的本地存储indexer

    type cache struct { // cacheStorage bears the burden of thread safety for the cache cacheStorage ThreadSafeStore = nil { return KeyError{obj, err} } c.cacheStorage.Add(key, obj) return nil } index.Add 先通过KeyFunc 并调用c.cacheStorage.Add方法,该方法会调用 updateIndices 方法。

    74020编辑于 2023-02-10
  • 来自专栏前端宇宙

    H5 秒开方案大全

    首先,PWA的能够通过cacheStorage缓存普通的图片、JS、CSS资源。 对于直出HTML,我们可以配合PWA,将从后台直出的文件,缓存到cacheStorage,在下一次请求时,优先从本地缓存中获取,同时发起网络请求更新本地html文件。 浏览器获取到数据,并且渲染好的html,能够通过outerHTML方法,将html页面缓存到cacheStorage中,第二次访问仍然优先从本地获取,同时发起html请求,通过对比其中唯一标识的差异,决定是否需要更新

    1.9K20发布于 2020-08-28
  • 来自专栏前端开发

    Client-side rendering:把渲染权交给浏览器后,你真正需要承担的性能账单

    web.dev在讨论渲染形态时提到:对于SPA来说,识别大多数页面共享的核心UI片段,可以应用applicationshellcachingtechnique;配合ServiceWorker,复访可以从CacheStorage (ChromeforDevelopers)CacheStorage与ServiceWorker是怎么配合的CacheStorage是浏览器提供的缓存存储接口,它维护了一组命名Cache,可以被ServiceWorker 4)复访体验做成秒开感:应用壳+ServiceWorker预缓存把稳定的UI外壳与依赖缓存进CacheStorage,复访直接走缓存,动态内容再按网络策略更新。 复访加速:应用壳+ServiceWorker+CacheStorage

    8910编辑于 2026-04-19
领券