Sure, here's a simple example of how you can use Amazon ElastiCache with Redis in Node.js:
const redis = require('redis');
// Connect to ElastiCache Redis instance
const client = redis.createClient({
host: 'your-elasticache-endpoint',
port: 6379,
password: 'your-redis-password'
});
// Set a key-value pair
client.set('myKey', 'myValue', (err, reply) => {
if (err) throw err;
console.log(reply);
});
// Get the value of a key
client.get('myKey', (err, reply) => {
if (err) throw err;
console.log(reply);
});
// Close the connection
client.quit();