(key: string, value: string)
| 53 | } |
| 54 | |
| 55 | function cacheSet(key: string, value: string) { |
| 56 | const bytes = value.length * 2 |
| 57 | if (bytes > CACHE_MAX_BYTES) { |
| 58 | cacheDelete(key) |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | const entry = cache.get(key) |
| 63 | if (entry) cacheTotal.bytes -= entry.bytes |
| 64 | cache.delete(key) |
| 65 | cache.set(key, { value, bytes }) |
| 66 | cacheTotal.bytes += bytes |
| 67 | cachePrune() |
| 68 | } |
| 69 | |
| 70 | function cacheGet(key: string) { |
| 71 | const entry = cache.get(key) |
no test coverage detected