Skip to content

Commit 005f51b

Browse files
committed
feat: sqlite cache store
Co-authored-by: Robert Nagy <[email protected]> Co-authored-by: Isak Törnros <[email protected]> Signed-off-by: flakey5 <[email protected]>
1 parent 444a0af commit 005f51b

8 files changed

+535
-6
lines changed

docs/docs/api/CacheStore.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ The `MemoryCacheStore` stores the responses in-memory.
1414
**Options**
1515

1616
- `maxEntries` - The maximum amount of responses to store. Default `Infinity`.
17-
- `maxEntrySize` - The maximum size in bytes that a response's body can be. If a response's body is greater than or equal to this, the response will not be cached.
17+
- `maxSize` - The maximum size in bytes that a response's body can be. If a response's body is greater than or equal to this, the response will not be cached.
18+
19+
### `SqliteCacheStore`
20+
21+
The `SqliteCacheStore` stores the responses in a SQLite database.
22+
23+
**Options**
24+
25+
- `maxSize` - The maximum size in bytes that a resposne's body can be. If a response's body is greater than or equal to this, the response will not be cached.
1826

1927
## Defining a Custom Cache Store
2028

index.js

+9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ module.exports.cacheStores = {
4848
MemoryCacheStore: require('./lib/cache/memory-cache-store')
4949
}
5050

51+
try {
52+
const SqliteCacheStore = require('./lib/cache/sqlite-cache-store')
53+
module.exports.cacheStores.SqliteCacheStore = SqliteCacheStore
54+
} catch (err) {
55+
if (err.code !== 'ERR_UNKNOWN_BUILTIN_MODULE') {
56+
throw err
57+
}
58+
}
59+
5160
module.exports.buildConnector = buildConnector
5261
module.exports.errors = errors
5362
module.exports.util = {

0 commit comments

Comments
 (0)