@b9g/cache-redis 0.1.2 → 0.1.4
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 +32 -32
- package/package.json +4 -23
- package/src/index.cjs +18790 -17
- package/src/index.d.ts +50 -8
- package/src/index.js +236 -10
- package/src/factory.cjs +0 -34
- package/src/factory.d.ts +0 -19
- package/src/factory.js +0 -11
- package/src/redis-cache.cjs +0 -18208
- package/src/redis-cache.d.ts +0 -71
- package/src/redis-cache.js +0 -228
package/README.md
CHANGED
|
@@ -22,16 +22,18 @@ bun install @b9g/cache-redis
|
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
24
|
import {CustomCacheStorage} from "@b9g/cache";
|
|
25
|
-
import {
|
|
25
|
+
import {RedisCache} from "@b9g/cache-redis";
|
|
26
26
|
|
|
27
27
|
// Create cache storage with Redis backend
|
|
28
|
-
const cacheStorage = new CustomCacheStorage(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const cacheStorage = new CustomCacheStorage((name: string) =>
|
|
29
|
+
new RedisCache(name, {
|
|
30
|
+
redis: {
|
|
31
|
+
url: "redis://localhost:6379"
|
|
32
|
+
},
|
|
33
|
+
defaultTTL: 3600, // 1 hour
|
|
34
|
+
prefix: "myapp"
|
|
35
|
+
})
|
|
36
|
+
);
|
|
35
37
|
|
|
36
38
|
// Use the cache
|
|
37
39
|
const cache = await cacheStorage.open("pages");
|
|
@@ -39,25 +41,24 @@ await cache.put(request, response);
|
|
|
39
41
|
const cached = await cache.match(request);
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
###
|
|
44
|
+
### Direct Cache Usage
|
|
43
45
|
|
|
44
46
|
```typescript
|
|
45
|
-
import {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
defaultTTL: 3600,
|
|
57
|
-
maxEntrySize: 5 * 1024 * 1024 // 5MB max per entry
|
|
58
|
-
})
|
|
59
|
-
}
|
|
47
|
+
import {createCache} from "@b9g/cache-redis";
|
|
48
|
+
|
|
49
|
+
// Create a single Redis cache instance
|
|
50
|
+
const cache = createCache({
|
|
51
|
+
name: "my-cache",
|
|
52
|
+
redis: {
|
|
53
|
+
url: process.env.REDIS_URL || "redis://localhost:6379",
|
|
54
|
+
password: process.env.REDIS_PASSWORD
|
|
55
|
+
},
|
|
56
|
+
defaultTTL: 3600,
|
|
57
|
+
maxEntrySize: 5 * 1024 * 1024 // 5MB max per entry
|
|
60
58
|
});
|
|
59
|
+
|
|
60
|
+
await cache.put(request, response);
|
|
61
|
+
const cached = await cache.match(request);
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
## Configuration Options
|
|
@@ -172,17 +173,16 @@ console.log({
|
|
|
172
173
|
});
|
|
173
174
|
```
|
|
174
175
|
|
|
175
|
-
## Cleanup
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
## Exports
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
// Dispose single cache
|
|
181
|
-
await cache.dispose();
|
|
179
|
+
### Classes
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
- `RedisCache` - Redis-backed cache implementation (extends Cache from @b9g/cache)
|
|
182
|
+
|
|
183
|
+
### Types
|
|
184
|
+
|
|
185
|
+
- `RedisCacheOptions` - Configuration options for RedisCache
|
|
186
186
|
|
|
187
187
|
## Shovel Integration
|
|
188
188
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b9g/cache-redis",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Redis cache adapter for Shovel cache system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cache",
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
"directory": "packages/cache-redis"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@logtape/logtape": "^1.2.0",
|
|
20
21
|
"redis": "^4.6.10"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@b9g/libuild": "^0.1.
|
|
24
|
+
"@b9g/libuild": "^0.1.18"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
|
-
"@b9g/cache": "^0.1.
|
|
27
|
+
"@b9g/cache": "^0.1.4"
|
|
27
28
|
},
|
|
28
29
|
"type": "module",
|
|
29
30
|
"types": "src/index.d.ts",
|
|
@@ -39,16 +40,6 @@
|
|
|
39
40
|
"import": "./src/index.js",
|
|
40
41
|
"require": "./src/index.cjs"
|
|
41
42
|
},
|
|
42
|
-
"./factory": {
|
|
43
|
-
"types": "./src/factory.d.ts",
|
|
44
|
-
"import": "./src/factory.js",
|
|
45
|
-
"require": "./src/factory.cjs"
|
|
46
|
-
},
|
|
47
|
-
"./factory.js": {
|
|
48
|
-
"types": "./src/factory.d.ts",
|
|
49
|
-
"import": "./src/factory.js",
|
|
50
|
-
"require": "./src/factory.cjs"
|
|
51
|
-
},
|
|
52
43
|
"./index": {
|
|
53
44
|
"types": "./src/index.d.ts",
|
|
54
45
|
"import": "./src/index.js",
|
|
@@ -59,16 +50,6 @@
|
|
|
59
50
|
"import": "./src/index.js",
|
|
60
51
|
"require": "./src/index.cjs"
|
|
61
52
|
},
|
|
62
|
-
"./redis-cache": {
|
|
63
|
-
"types": "./src/redis-cache.d.ts",
|
|
64
|
-
"import": "./src/redis-cache.js",
|
|
65
|
-
"require": "./src/redis-cache.cjs"
|
|
66
|
-
},
|
|
67
|
-
"./redis-cache.js": {
|
|
68
|
-
"types": "./src/redis-cache.d.ts",
|
|
69
|
-
"import": "./src/redis-cache.js",
|
|
70
|
-
"require": "./src/redis-cache.cjs"
|
|
71
|
-
},
|
|
72
53
|
"./package.json": "./package.json"
|
|
73
54
|
}
|
|
74
55
|
}
|