MCPcopy Index your code
hub / github.com/chavyleung/scripts / reloadAppSubCache

Function reloadAppSubCache

chavy.box.js:968–991  ·  view source on GitHub ↗

* =================================== * 工具类函数 * ===================================

(url)

Source from the content-addressed store, hash-verified

966 */
967
968function reloadAppSubCache(url) {
969 // 地址后面拼时间缀, 避免 GET 缓存
970 const requrl = `${url}${
971 url.includes('?') ? '&' : '?'
972 }_=${new Date().getTime()}`
973 return $.http.get(requrl).then((resp) => {
974 try {
975 const subcaches = getAppSubCaches()
976 subcaches[url] = $.toObj(resp.body)
977 subcaches[url].updateTime = new Date()
978 // 仅缓存存在 id 的订阅
979 Object.keys(subcaches).forEach((key) => {
980 if (!subcaches[key].hasOwnProperty('id')) {
981 delete subcaches[key]
982 }
983 })
984 $.setjson(subcaches, $.KEY_app_subCaches)
985 $.log(`更新订阅, 成功! ${url}`)
986 } catch (e) {
987 $.logErr(e)
988 $.log(`更新订阅, 失败! ${url}`)
989 }
990 })
991}
992
993function update(obj, path, value) {
994 const keys = path.split('.')

Callers 3

apiAddAppSubFunction · 0.70
apiReloadAppSubFunction · 0.70
reloadAppSubCachesFunction · 0.70

Calls 6

getAppSubCachesFunction · 0.70
getMethod · 0.45
toObjMethod · 0.45
setjsonMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…