import * as accountServices from '@life-payment/services/api/Account';
|
|
type CacheData = {
|
data: API.OssSTSReponse;
|
time: number;
|
};
|
|
export class OssSTS {
|
private static refreshSTSTokenInterval = 20 * 60 * 1000;
|
private static cacheKey = 'ossSTSCacheKey';
|
private static cache: { [key: string]: CacheData } = {};
|
|
static async getOssSTS() {
|
if (this.cache[this.cacheKey]) {
|
if (new Date().getTime() - this.cache[this.cacheKey].time < this.refreshSTSTokenInterval) {
|
return this.cache[this.cacheKey].data;
|
}
|
}
|
|
let res = await accountServices.getOssSTS({
|
showLoading: false,
|
});
|
this.cache[this.cacheKey] = {
|
data: res,
|
time: new Date().getTime(),
|
};
|
return res;
|
}
|
}
|