upstash-redis
Because upstash-redis is HTTP based, we recommend it for Serverless functions.
Other TCP based clients can cause connection problems in highly concurrent use
cases.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
import { Redis } from '@upstash/redis';
const redis = new Redis({ url: 'UPSTASH_REDIS_REST_URL', token: 'UPSTASH_REDIS_REST_TOKEN' });
(async () => {
try {
const data = await redis.get('key');
console.log(data);
} catch (error) {
console.error(error);
}
})();
const Redis = require("ioredis");
let client = new Redis("rediss://:YOUR_PASSWORD@YOUR_ENDPOINT:YOUR_PORT");
await client.set("foo", "bar");
let x = await client.get("foo");
console.log(x);
import redis
r = redis.Redis(
host= 'YOUR_ENDPOINT',
port= 'YOUR_PORT',
password= 'YOUR_PASSWORD', ssl=True)
r.set('foo','bar')
print(r.get('foo'))
Jedis jedis = new Jedis("YOUR_ENDPOINT", "YOUR_PORT", true);
jedis.auth("YOUR_PASSWORD");
jedis.set("foo", "bar");
String value = jedis.get("foo");
System.out.println(value);
func main() {
c, err := redis.Dial("tcp", "YOUR_ENDPOINT:YOUR_PORT", redis.DialUseTLS(true))
if err != nil {
panic(err)
}
_, err = c.Do("AUTH", "YOUR_PASSWORD")
if err != nil {
panic(err)
}
_, err = c.Do("SET", "foo", "bar")
if err != nil {
panic(err)
}
value, err := redis.String(c.Do("GET", "foo"))
if err != nil {
panic(err)
}
println(value)
}
Was this page helpful?