Install @upstash/redis from npm:
npm install @upstash/redisyarn add @upstash/redispnpm add @upstash/redisIn Deno, import it straight from npm with no install step:
import { Redis } from "npm:@upstash/redis";Basic Usage:#
import { Redis } from "@upstash/redis"const redis = new Redis({ url: <UPSTASH_REDIS_REST_URL>, token: <UPSTASH_REDIS_REST_TOKEN>,})// stringawait redis.set('key', 'value');let data = await redis.get('key');console.log(data)await redis.set('key2', 'value2', {ex: 1});// sorted setawait redis.zadd('scores', { score: 1, member: 'team1' })data = await redis.zrange('scores', 0, 100 )console.log(data)// listawait redis.lpush('elements', 'magnesium')data = await redis.lrange('elements', 0, 100 )console.log(data)// hashawait redis.hset('people', {name: 'joe'})data = await redis.hget('people', 'name' )console.log(data)// setsawait redis.sadd('animals', 'cat')data = await redis.spop('animals', 1)console.log(data)