first commit

This commit is contained in:
2026-01-16 12:37:08 +05:30
commit ecfee6732e
11 changed files with 407 additions and 0 deletions

35
server.js Normal file
View File

@@ -0,0 +1,35 @@
import Redis from 'ioredis';
// Create a new Redis client (default localhost:6379)
const redis = new Redis({
host: '72.60.220.57',
port: 6379,
username: 'default',
password: '4~pI27tEpI4(',
});
async function run() {
try {
// Set a key
// await redis.set('username', 'yash946');
// Get the key
const value = await redis.get('username');
console.log('Fetched from Redis:', value);
// Set a key with expiry (in seconds)
await redis.set('session', 'xyz123', 'EX', 20); // expires in 10 seconds
// Get all keys
const keys = await redis.keys('*');
console.log('All keys:', keys);
// Close the connection`
redis.disconnect();
} catch (err) {
console.error('Redis error:', err);
}
}
run();