🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@samiyev/redis-comfortably

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@samiyev/redis-comfortably

redis session storage

latest
Source
npmnpm
Version
1.2.2
Version published
Weekly downloads
1
-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

redis-comfortably

Session storage

Installation

$ npm install @samiyev/redis-comfortably

Usage

Create connection

Start redis service

08-03-2017 11-46-11


    import * as Redis from "@samiyev/redis-comfortably";

    const options = {
        port: 6379,
        host: '127.0.0.1',
        collection: [
            'sessions',
            //'other collection names'
        ]
    };

    const memory = new Redis.DB(options);

    let user = {
        id: '545e1cae5ae582d1b4639',
        login: 'expamle',
        password: 'password'
    };

    async function write(key, value, expire) {
        try {
            return await memory.sessions.write(key, value, expire);
        }
        catch (error) {
            throw error
        }
    }

Writing item to Memory [ Firts-step ]


    async function write(key, value, expire) {
        try {
            return await memory.sessions.write(key, value, expire);
        }
        catch (error) {
            throw error
        }
    }
    
    setTimeout(async(user) => {
        var oneday = 24 * 60 * 60;
        var key = user.id;
    
        var result = await write(key, user, oneday);
        
        console.log("Writing => " , result);
        
    }, 3000, user);

Result

08-03-2017 12-11-00

Read item in memory [ Second-step ]


    async function read(key) {
        try {
            return await memory.sessions.read(key);
        }
        catch (error) {
            throw error;
        }
    }
    
    setTimeout(async(key) => {
    
        var result = await read(key)
    
        console.log("Reading => ", result);
    
    }, 6000, user.id);

Result

08-03-2017 11-54-18

Delete item in memory [ Third-step ]


async function deleting(key) {
    try {
        return await memory.sessions.delete(key);
    }
    catch (error) {
        throw error;
    }
}

setTimeout(async(key) => {

    var result = await deleting(key);
    
    console.log("Deleting => " , result);

}, 9000, user.id)

###Result

08-03-2017 12-11-19

##Logs

08-03-2017 12-27-28

Keywords

redis

FAQs

Package last updated on 12 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts