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 <ronagy@icloud.com>
Co-authored-by: Isak Törnros <isak.tornros@hotmail.com>

Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
  • Loading branch information
flakey5 committed Nov 19, 2024
1 parent a73fd09 commit dd7ba9a
Show file tree
Hide file tree
Showing 8 changed files with 488 additions and 7 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
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ 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 (_) {
// Do nothing
}

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

0 comments on commit dd7ba9a

Please sign in to comment.