You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
26
26
27
27
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.
28
28
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
51
51
52
52
> If somebody uploaded a file and didn't save the record, you will pay for the storage until the file is removed manually
53
53
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
+
54
64
### Cloudflare R2 setup example
55
65
56
66
This adapter requires key/value adapter. For example, we will be using levelDb adapter.
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/06-Adapters/07-key-value-adapters.md
+102-4Lines changed: 102 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Key-value adapters are used to store data in a key-value format. They provide a
11
11
## RAM Adapter
12
12
13
13
```bash
14
-
pnpm i @adminforth/key-value-adapter-ram
14
+
pnpm add @adminforth/key-value-adapter-ram
15
15
```
16
16
17
17
The RAM adapter is a simple in-memory key-value store. It keeps data in process memory, so it is not suitable for multi-process deployments because each process would have its own isolated store. In that case you need a centralized KV adapter such as Redis.
@@ -27,7 +27,7 @@ Cons:
27
27
## Redis Adapter
28
28
29
29
```bash
30
-
pnpm i @adminforth/key-value-adapter-redis
30
+
pnpm add @adminforth/key-value-adapter-redis
31
31
```
32
32
33
33
Redis uses in-memory storage with $O(1)$ get complexity. It is a great fit for lightweight workloads that fit in RAM, and it also works well for multi-process or replica-based installations as a centralized store. If persistence across restarts is important, configure Redis persistence separately.
@@ -36,7 +36,7 @@ Redis uses in-memory storage with $O(1)$ get complexity. It is a great fit for l
LevelDB uses disk storage with $O(\log n)$ get complexity. It is a good fit for large or persistent KV datasets that still require fast lookups but do not efficiently fit in RAM. This is a single-process adapter only, so multiple admin processes should not point to the same LevelDB directory.
@@ -60,4 +60,102 @@ const adapter = new LevelDBKeyValueAdapter({
60
60
});
61
61
62
62
adapter.set('test-key', 'test-value', 120);
63
+
```
64
+
65
+
## Resource-based adapter
66
+
```bash
67
+
pnpm add @adminforth/key-value-adapter-resource
68
+
```
69
+
70
+
Resource adapter uses adminforth resource to store key/value pairs.
0 commit comments