1.0.1 • Published 8 months ago

x-promisecache v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
8 months ago

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)
1.0.1

8 months ago

1.0.0

8 months ago