| 47 | } |
| 48 | |
| 49 | export async function getRulesCacheKey( |
| 50 | url: string, |
| 51 | ): Promise<{ rulesCacheKey: string | number; singleObj? }> { |
| 52 | const cacheObj = new Cache(`rulesCacheKey/${url}`, 7 * 24 * 60 * 60 * 1000); |
| 53 | |
| 54 | if (await cacheObj.hasValue()) { |
| 55 | return cacheObj.getValue().then(res => { |
| 56 | return { |
| 57 | rulesCacheKey: res, |
| 58 | }; |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | const singleObj = getSingle(url); |
| 63 | await singleObj.update(); |
| 64 | cacheObj.setValue(singleObj.getRulesCacheKey()); |
| 65 | return { |
| 66 | rulesCacheKey: singleObj.getRulesCacheKey(), |
| 67 | singleObj, |
| 68 | }; |
| 69 | } |