@prismakit/redis 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Redis `CacheAdapter` for `@prismakit/core` repositories (ioredis).
|
|
|
4
4
|
|
|
5
5
|
Fail-open: cache errors do not break reads/writes.
|
|
6
6
|
|
|
7
|
+
[Documentation](https://github.com/fikiap23/prismakit/blob/master/docs/README.md) · [Cache guide](https://github.com/fikiap23/prismakit/blob/master/docs/guide/cache.md) · [GitHub](https://github.com/fikiap23/prismakit)
|
|
8
|
+
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
11
|
```bash
|
|
@@ -16,19 +18,48 @@ pnpm add @prismakit/redis ioredis
|
|
|
16
18
|
import { RedisCacheAdapter } from '@prismakit/redis';
|
|
17
19
|
|
|
18
20
|
const cache = new RedisCacheAdapter({
|
|
21
|
+
url: process.env.REDIS_URL, // or host + port
|
|
19
22
|
prefix: 'myapp',
|
|
20
|
-
// url / client options — see RedisCacheAdapter options
|
|
21
23
|
});
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
### Options
|
|
27
|
+
|
|
28
|
+
| Option | Default | Description |
|
|
29
|
+
|--------|---------|-------------|
|
|
30
|
+
| `url` | — | Redis connection URL |
|
|
31
|
+
| `host` | `localhost` | Used when `url` is omitted |
|
|
32
|
+
| `port` | `6379` | Used when `url` is omitted |
|
|
33
|
+
| `prefix` | `prismakit` | Key prefix for all cache keys |
|
|
34
|
+
|
|
35
|
+
### Wire it up
|
|
36
|
+
|
|
37
|
+
**Core**
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const users = new UserRepository({ prisma, cache });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**NestJS**
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
PrismaKitModule.forRoot({
|
|
47
|
+
prisma,
|
|
48
|
+
cache: new RedisCacheAdapter({ prefix: 'myapp' }),
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Cache behavior (reminder)
|
|
53
|
+
|
|
54
|
+
- Reads cache only when `setCache: true`
|
|
55
|
+
- Never cache auth / sensitive selects
|
|
56
|
+
- Inside transactions: skip cache; invalidate in `afterCommit`
|
|
25
57
|
|
|
26
58
|
## Docs
|
|
27
59
|
|
|
28
60
|
- [Documentation index](https://github.com/fikiap23/prismakit/blob/master/docs/README.md)
|
|
29
61
|
- [Cache guide](https://github.com/fikiap23/prismakit/blob/master/docs/guide/cache.md)
|
|
30
62
|
|
|
31
|
-
|
|
32
63
|
## License
|
|
33
64
|
|
|
34
65
|
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismakit/redis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Redis CacheAdapter for @prismakit/core",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"engines": {
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@prismakit/core": "1.0.
|
|
26
|
+
"@prismakit/core": "1.0.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"ioredis": ">=5.0.0",
|
|
30
|
-
"@prismakit/core": "1.0.
|
|
30
|
+
"@prismakit/core": "1.0.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"ioredis": "^5.6.0",
|