Skip to content

Commit

Permalink
feat: sqlite cache store
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Nagy <[email protected]>
Co-authored-by: Isak Törnros <[email protected]>

Signed-off-by: flakey5 <[email protected]>
  • Loading branch information
flakey5 committed Nov 21, 2024
1 parent 444a0af commit 005f51b
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 6 deletions.
10 changes: 9 additions & 1 deletion docs/docs/api/CacheStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ The `MemoryCacheStore` stores the responses in-memory.
**Options**

- `maxEntries` - The maximum amount of responses to store. Default `Infinity`.
- `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.
- `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.

### `SqliteCacheStore`

The `SqliteCacheStore` stores the responses in a SQLite database.

**Options**

- `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.

## Defining a Custom Cache Store

Expand Down
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ module.exports.cacheStores = {
MemoryCacheStore: require('./lib/cache/memory-cache-store')
}

try {
const SqliteCacheStore = require('./lib/cache/sqlite-cache-store')
module.exports.cacheStores.SqliteCacheStore = SqliteCacheStore
} catch (err) {
if (err.code !== 'ERR_UNKNOWN_BUILTIN_MODULE') {
throw err
}
}

module.exports.buildConnector = buildConnector
module.exports.errors = errors
module.exports.util = {
Expand Down
Loading

0 comments on commit 005f51b

Please sign in to comment.