x-promisecache
v1.0.1
Published
js promise-cache
Downloads
1
Readme
Promise-cache
Promise缓存处理,针对同一时间或时间段内的promise进行缓存。
Npm
npm install x-promisecache
USE
let PromiseCache = require('x-promisecache');
let p = ()=> new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok..."+Date.now())
},1000)
})
PromiseCache.cache('tianxiangbing',p,1).then(res=>{
console.log('sucess:::',res)
})
setTimeout(()=>{
PromiseCache.cache('tianxiangbing',p,1000).then(res=>{
console.log('sucess:::',res)
})
},100)
setTimeout(()=>{
PromiseCache.cache('tianxiangbing',p,1000).then(res=>{
console.log('sucess:::',res)
})
},1001)