为了方便使用,包装了一个npm包可以直接使用,具体代码参考连接
npm 使用
yarn add @dalongrong/cubejs-schemaversion-cache
cube.js
// Cube.js configuration options: https://cube.dev/docs/config
const {pause,schemaVersion} = require("@dalongrong/cubejs-schemaversion-cache")
// one demo func
async function fetchVersion(securityContext){
pause(3000)
console.log("call version")
return `"dalong"---${parseInt(Math.random()*100)}`
}
module.exports = {
schemaVersion: async ({ securityContext }) =>{
return schemaVersion(securityContext,fetchVersion)
},
contextToAppId: ({ securityContext }) => {
return `CUBEJS_APP_${securityContext.user_id}`
}
};
参考资料
https://github.com/rongfengliang/cubejs-schemaversion-cache
https://www.npmjs.com/package/@dalongrong/cubejs-schemaversion-cache