Skip to content

Commit 74f75af

Browse files
committed
docs: update docs for the key/value redis adapter and s3 compatible adapter
AdminForth/1735/kv-adapters-and-storage-s3-com
1 parent 2bb4d14 commit 74f75af

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

adminforth/documentation/docs/tutorial/06-Adapters/04-storage-adapters.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pnpm add @adminforth/storage-adapter-s3-compatible
2222
```
2323

2424
Provides S3 compatible interface for object storage services such as MinIO, Wasabi, Cloudflare R2 or other third-party S3 providers.
25-
### How the adapter works:
25+
### How the adapter works
2626

2727
The Amazon S3 adapter uses tagging to mark objects with the special tag `adminforth-candidate-for-cleanup`, and then creates a lifecycle rule that automatically expires objects with that tag.
2828
But not all S3-compatible adapters support tagging, so this adapter has a built-in cleanup mechanism and you have two options:
@@ -51,6 +51,16 @@ If you don't want to use a key/value adapter and you don't need to clean up file
5151
5252
> If somebody uploaded a file and didn't save the record, you will pay for the storage until the file is removed manually
5353
54+
### Choosing Key/value adapter
55+
56+
Since the adapter uses a key/value adapter to store keys for deletion, it is important to use persistent storage, so the data will be safe:
57+
58+
- (⛔️) [RAM adapter](07-key-value-adapters.md#ram-adapter) - not recommended, because after a server restart all data will be lost
59+
- (✅) [Redis adapter](07-key-value-adapters.md#redis-adapter) - Redis itself stores data in-memory, but you can set it up to write data to an `.rdb` file so the database is restored on server restart. However, it requires regular database snapshots and persistent Docker storage setup
60+
- (✅✅) [LevelDB adapter](07-key-value-adapters.md#leveldb-adapter) - can be used, but you need to set up persistent storage in your Docker container, so data won't be lost between restarts
61+
- (✅✅✅) [Resource adapter](07-key-value-adapters.md#resource-based-adapter) - uses a database to store key/value pairs, so data will be safe between restarts, but you need to create an extra table for this storage
62+
63+
5464
### Cloudflare R2 setup example
5565

5666
This adapter requires key/value adapter. For example, we will be using levelDb adapter.

adminforth/documentation/docs/tutorial/06-Adapters/07-key-value-adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Redis uses in-memory storage with $O(1)$ get complexity. It is a great fit for l
3636
import RedisKeyValueAdapter from '@adminforth/key-value-adapter-redis';
3737

3838
const adapter = new RedisKeyValueAdapter({
39-
redisUrl: 'redis://localhost:6379',
39+
redisUrl: 'redis://localhost:6379/0', // where "/0" - is database number from 0 to 15; Redis can have up to 16 databases"
4040
});
4141

4242
adapter.set('test-key', 'test-value', 120);

0 commit comments

Comments
 (0)