| 114 | } |
| 115 | |
| 116 | function shouldCache(result: unknown, options: CacheableOptions = {}): boolean { |
| 117 | // Don't cache undefined or null |
| 118 | if (result === undefined || result === null) { |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | // Don't cache empty strings |
| 123 | if (typeof result === 'string') { |
| 124 | return result.length > 0; |
| 125 | } |
| 126 | |
| 127 | if (Array.isArray(result)) { |
| 128 | return options.cacheEmptyArray ? true : result.length > 0; |
| 129 | } |
| 130 | |
| 131 | // Don't cache empty objects |
| 132 | if (typeof result === 'object' && result !== null) { |
| 133 | return Object.keys(result).length > 0; |
| 134 | } |
| 135 | |
| 136 | // Cache everything else (booleans, numbers, etc.) |
| 137 | return true; |
| 138 | } |
| 139 | |
| 140 | const DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.*Z$/; |
| 141 | const parseCache = (cached: string) => { |