Skip to content

Commit a89c527

Browse files
Update Redis cache handler example and docs (caching-tools#106)
1 parent 064b994 commit a89c527

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

.changeset/light-taxis-search.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@neshca/cache-handler': patch
3+
---
4+
5+
Update Redis cache handler example and docs

apps/cache-testing/cache-handler-redis-stack.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ if (process.env.SERVER_STARTED) {
5757
cache: {
5858
async get(key) {
5959
try {
60-
return (await client.json.get(PREFIX + key)) ?? null;
60+
const value = (await client.json.get(PREFIX + key)) ?? null;
61+
62+
if (value && value.kind === 'ROUTE' && value.body.type === 'Buffer') {
63+
value.body = Buffer.from(value.body);
64+
}
65+
66+
return value;
6167
} catch (error) {
6268
return null;
6369
}
@@ -77,7 +83,7 @@ if (process.env.SERVER_STARTED) {
7783
localTagsManifest = sharedTagsManifest;
7884
}
7985

80-
return localTagsManifest;
86+
return sharedTagsManifest;
8187
} catch (error) {
8288
return localTagsManifest;
8389
}

docs/examples/use-with-redis.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,13 @@ if (process.env.SERVER_STARTED) {
191191
cache: {
192192
async get(key) {
193193
try {
194-
return (await client.json.get(PREFIX + key)) ?? null;
194+
const value = (await client.json.get(PREFIX + key)) ?? null;
195+
196+
if (value && value.kind === 'ROUTE' && value.body.type === 'Buffer') {
197+
value.body = Buffer.from(value.body);
198+
}
199+
200+
return value;
195201
} catch (error) {
196202
return null;
197203
}
@@ -211,7 +217,7 @@ if (process.env.SERVER_STARTED) {
211217
localTagsManifest = sharedTagsManifest;
212218
}
213219
214-
return localTagsManifest;
220+
return sharedTagsManifest;
215221
} catch (error) {
216222
return localTagsManifest;
217223
}

0 commit comments

Comments
 (0)