Skip to content

Commit

Permalink
feature: remove expired items for postgres adapter #20 (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: nwittstruck <nwittstruck@users.noreply.github.com>
  • Loading branch information
JannikStreek and nwittstruck authored Jun 11, 2024
1 parent 1cd18f5 commit 22571c1
Show file tree
Hide file tree
Showing 8 changed files with 439 additions and 173 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
push:
branches:
- main
- 20-feature-remove-expired-items-for-postgres-adapter

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -51,4 +52,4 @@ jobs:
target: production
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,25 @@ It use Keyv as a simple K/V store so you can use the database of your choice.

## Environement Variables

| Name | Description | Default value |
| --------------- | ------------------------------------------------------------ | ---------------- |
| `PORT` | Server listening port | 8080 |
| `GLOBAL_PREFIX` | API global prefix for every routes | `/api/v2` |
| `STORAGE_URI` | [Keyv](https://github.com/jaredwray/keyv) connection string, example: `redis://user:pass@localhost:6379`. Availabe Keyv storage adapter: redis, mongo, postgres and mysql | `""` (in memory **non-persistent**) |
| `STORAGE_TTL` | Time to live for data | null |
| `LOG_LEVEL` | Log level (`debug`, `verbose`, `log`, `warn`, `error`) | `warn` |
| `BODY_LIMIT` | Payload size limit for scenes or images | `50mb` |
| Name | Description | Default value |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `PORT` | Server listening port | 8080 |
| `GLOBAL_PREFIX` | API global prefix for every routes | `/api/v2` |
| `STORAGE_URI` | [Keyv](https://github.com/jaredwray/keyv) connection string, example: `redis://user:pass@localhost:6379`. Availabe Keyv storage adapter: redis, mongo, postgres and mysql | `""` (in memory **non-persistent**) |
| `STORAGE_TTL` | Time to live for data | null |
| `LOG_LEVEL` | Log level (`debug`, `verbose`, `log`, `warn`, `error`) | `warn` |
| `BODY_LIMIT` | Payload size limit for scenes or images | `50mb` |
| `ENABLE_POSTGRES_TTL_SERVICE` | Enabling the Postgres TTL Service will clean up expired items once a day. This will break if used with a non-postgres `STORAGE_URI`. | `false` |

### Env Variables for Postgres

For setting postgres pool variables, a few code adjustment have to be made in the `storage.service.ts`:

```typescript
const store = new (require('@keyv/postgres'))({
uri,
max: 1
})
max: 1,
});

const keyv = new Keyv({
store,
Expand Down
Loading

0 comments on commit 22571c1

Please sign in to comment.