Skip to content

Commit fb41810

Browse files
committed
added edge example to readme
1 parent 240d497 commit fb41810

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,30 @@ import { get } from '@upstash/redis';
7474
}
7575
})();
7676
```
77+
78+
### Edge Support
79+
80+
> Only GET requests are supported in Edge Caching. As a result, write/update commands are not supported.
81+
82+
```typescript
83+
import upstash from '@upstash/redis';
84+
85+
const redis = upstash({
86+
url: 'UPSTASH_REDIS_REST_URL',
87+
token: 'UPSTASH_REDIS_REST_TOKEN',
88+
edgeUrl: 'UPSTASH_REDIS_EDGE_URL',
89+
});
90+
91+
(async () => {
92+
try {
93+
const { data, error, metadata } = await redis.get('key');
94+
if (error) throw error;
95+
console.log(data);
96+
// -> null | string
97+
console.log(metadata);
98+
// -> { edge: boolean, cache: null | 'miss' | 'hit' }
99+
} catch (error) {
100+
console.error(error);
101+
}
102+
})();
103+
```

0 commit comments

Comments
 (0)