功能:同步小程序流程
This commit is contained in:
@@ -1,15 +1,39 @@
|
||||
/**
|
||||
* Purpose: CACHE_PREFIX supports cache.js by holding or executing the cache prefix page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const CACHE_PREFIX = 'adminMiniCache:'
|
||||
/**
|
||||
* Purpose: memoryCache supports cache.js by holding or executing the memory cache page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const memoryCache = {}
|
||||
/**
|
||||
* Purpose: inflightCache supports cache.js by holding or executing the inflight cache page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const inflightCache = {}
|
||||
|
||||
/**
|
||||
* Purpose: buildKey supports cache.js by holding or executing the build key page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function buildKey(key) {
|
||||
return `${CACHE_PREFIX}${key}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: now supports cache.js by holding or executing the now page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function now() {
|
||||
return Date.now()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: getCache supports cache.js by holding or executing the get cache page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function getCache(key, defaultValue) {
|
||||
if (!key) {
|
||||
return defaultValue
|
||||
@@ -33,6 +57,10 @@ function getCache(key, defaultValue) {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: setCache supports cache.js by holding or executing the set cache page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function setCache(key, value, ttlMs) {
|
||||
if (!key) {
|
||||
return value
|
||||
@@ -48,6 +76,10 @@ function setCache(key, value, ttlMs) {
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: removeCache supports cache.js by holding or executing the remove cache page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function removeCache(key) {
|
||||
if (!key) {
|
||||
return
|
||||
@@ -58,6 +90,10 @@ function removeCache(key) {
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: remember supports cache.js by holding or executing the remember page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function remember(key, ttlMs, loader) {
|
||||
const cached = getCache(key, undefined)
|
||||
if (cached !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user