-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis.ts
31 lines (22 loc) · 780 Bytes
/
redis.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export async function getRedis(key: string) {
const REDIS_KEY = Deno.env.get("REDIS_KEY");
const REDIS_URL = Deno.env.get("REDIS_URL");
const headers = new Headers();
headers.append("Authorization", `Bearer ${REDIS_KEY}`);
const res = await fetch(`${REDIS_URL}/get/${key}`, { headers });
const json = await res.json();
return json;
}
export async function setRedis(key: string, value: string) {
const REDIS_KEY = Deno.env.get("REDIS_KEY");
const REDIS_URL = Deno.env.get("REDIS_URL");
const headers = new Headers();
headers.append("Authorization", `Bearer ${REDIS_KEY}`);
const res = await fetch(`${REDIS_URL}/set/${key}`, {
headers,
method: "POST",
body: JSON.stringify(value),
});
const json = await res.json();
return json;
}