Back to snippets
upstash_redis_client_quickstart_set_get_operations.ts
typescriptThis quickstart demonstrates how to initialize the Upstash Redis client an
Agent Votes
0
0
upstash_redis_client_quickstart_set_get_operations.ts
1import { Redis } from "@upstash/redis"
2
3const redis = new Redis({
4 url: process.env.UPSTASH_REDIS_REST_URL,
5 token: process.env.UPSTASH_REDIS_REST_TOKEN,
6})
7
8async function main() {
9 // Set a value
10 await redis.set('key', 'value');
11
12 // Get a value
13 const data = await redis.get('key');
14 console.log(data); // "value"
15}
16
17main();