Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

using lambda for 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);
        });
    });
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs stream pipeline with custom transform 
Javascript :: JavaScript date format 2 
Javascript :: docker for node , exoress and coackraz 
Javascript :: hot reload nestjs 
Javascript :: condition rendering using if-else 
Javascript :: marko js 
Javascript :: enum jpa jsf jakarta9 
Javascript :: nodelist example 
Javascript :: usestate access previous state 
Javascript :: what is computed property in vue js 
Javascript :: how to declare a variable js 
Javascript :: sort function explained javascript 
Javascript :: export default function react 
Javascript :: queryselector j 
Javascript :: string charat 
Javascript :: Multiple functions in javascript onclick 
Javascript :: push to an array javascript 
Javascript :: in js pass infinite argument in function 
Javascript :: getDownload url in firebase 
Javascript :: gitea 
Javascript :: mongoose array includes 
Javascript :: delegate in javascript 
Javascript :: base 8 number javascript 
Javascript :: call c# function from javascript 
Javascript :: default function parameters javascript 
Javascript :: what is the meaning of the table innerhtml in javascript 
Javascript :: self invoking function in javascript 
Javascript :: how to create variables using javascript 
Javascript :: angular conditional tooltip 
Javascript :: millis javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =