From 70c888943b2f4e2b8d7c142c2af664f69ac2ba01 Mon Sep 17 00:00:00 2001 From: Enes Akar Date: Wed, 3 Nov 2021 09:22:18 -0700 Subject: [PATCH 1/2] update edge examples --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f757740..fcc7b29a 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ import { get } from '@upstash/redis'; ### Edge Support -> Only GET requests are supported in Edge Caching. As a result, write/update commands are not supported. +Once you set `edgeUrl`, all read commands are fetched using edge url. The REST URL is used for write/update commands. ```typescript import upstash from '@upstash/redis'; @@ -90,12 +90,15 @@ const redis = upstash({ (async () => { try { + // the below reads using edge url const { data, error, metadata } = await redis.get('key'); if (error) throw error; console.log(data); // -> null | string console.log(metadata); // -> { edge: boolean, cache: null | 'miss' | 'hit' } + // the below reads using REST url (non-edge) + const { data2, error2, metadata2 } = await redis.get('key', {edge: false}); } catch (error) { console.error(error); } From 8773b4a464cf0c78cbd71078893785d269c88d06 Mon Sep 17 00:00:00 2001 From: Adem ilter Date: Thu, 4 Nov 2021 10:37:41 +0300 Subject: [PATCH 2/2] fix: edge example in readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fcc7b29a..c32a95dc 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,10 @@ const redis = upstash({ // -> null | string console.log(metadata); // -> { edge: boolean, cache: null | 'miss' | 'hit' } + // the below reads using REST url (non-edge) - const { data2, error2, metadata2 } = await redis.get('key', {edge: false}); + const get1 = await redis.get('key', {edge: false}); + if (get1.error) throw get1.error; } catch (error) { console.error(error); }