forked from luslucifer/vidjoy_api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
32 lines (27 loc) · 810 Bytes
/
test.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
32
import { Redis } from '@upstash/redis';
const redis = new Redis({
url: 'https://immortal-amoeba-48047.upstash.io',
token: 'AbuvASQgMzcxMDRhNjItNWUzOS00NmMwLWE2ODAtNDYzYjI3MjE0NDE2MzgxMzBiMDgxNTliNGNhY2EwOTU3NjdhYzI1ODkxZTQ=',
});
async function setName() {
try {
await redis.set('foo', 'bar');
console.log('Value set successfully.');
} catch (error) {
console.error('Error setting value:', error);
}
}
async function getName() {
try {
const data = await redis.get('foo');
console.log('Value:', data);
} catch (error) {
console.error('Error getting value:', error);
}
}
(async () => {
await setName(); // Set the value 'bar' for key 'foo'
await getName(); // Get the value for key 'foo'
// Close the connection when done
// await redis.disconnect();
})();