| 171 | return memoryCache.get(cacheKey); | 171 | return memoryCache.get(cacheKey); |
| 172 | } | 172 | } |
| 173 | if (useDiskCache) { | 173 | if (useDiskCache) { |
| | 174 | try { |
| 174 | const cachedData = await diskCache.instance().then(i => i.getItem(cacheKey)); | 175 | const cachedData = await diskCache.instance().then(i => i.getItem(cacheKey)); |
| 175 | if (cachedData) { | 176 | if (cachedData) { |
| 176 | return cachedData; | 177 | return cachedData; |
| 177 | } | 178 | } |
| | 179 | } catch (error) { |
| | 180 | console.warn('Error while reading from disk cache:', error); |
| | 181 | } |
| 178 | } | 182 | } |
| 179 | | 183 | |
| 180 | const result = await parse(inputFile, inputFormat); | 184 | const result = await parse(inputFile, inputFormat); |
| 181 | !isAndroid && memoryCache.set(cacheKey, result); | 185 | !isAndroid && memoryCache.set(cacheKey, result); |
| 182 | if (useDiskCache) { | 186 | if (useDiskCache) { |
| | 187 | try { |
| 183 | await diskCache.instance().then(i => i.setItem(cacheKey, result)); | 188 | await diskCache.instance().then(i => i.setItem(cacheKey, result)); |
| | 189 | } catch (error) { |
| | 190 | console.warn('Error while writing to disk cache:', error); |
| | 191 | } |
| 184 | } | 192 | } |
| 185 | return result; | 193 | return result; |
| 186 | } | 194 | } |