Menggunakan Lambda untuk Elasticache Node.js

// npm i redis
// upload code from zip in lambda
const redis = require("redis");

const client = redis.createClient({
    host: 'YOUR REDIS HOST',
    port: 6379
});

export.handler = async () => {
    await storeValue('sampleKey', 'sampleValue');
    const value = await getValue('sampleKey');
    return value;
}

const getValue = key => {
    return new Promise((resolve, reject) => {
        client.get(key, (error, response) => {
            if (error)
                reject(error);
            else
                resolve(response);
        });
    });
}

const storeValue = (key, value) => {
    return new Promise((resolve, reject) => {
        client.set(key, value, (error, response) => {
            if (error)
                reject(error);
            else
                resolve(response);
        });
    });
}
Expensive Eland