Socket
Book a DemoInstallSign in
Socket

@itinari/lib-session

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itinari/lib-session

manage session in redis

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

lib-session

Manage user session in redis

Usage

import * as redis from 'redis'
import {SessionService} from '@itinari/session'

const redisClient = redis.createClient({
  enable_offline_queue: false,
})
const sessionService = new SessionService(redisClient, 3600)

// create/update session
try {
  await sessionService.set('key', {foo: 'bar'})
} catch (error) {
  // ...
}

// get session data
try {
  const data = await sessionService.get('key')
} catch (error) {
  // ...
}

// destroy session
try {
  await sessionService.unset('key')
} catch (error) {
  // ...
}

// refresh session
try {
  await sessionService.refresh('key')
} catch (error) {
  // ...
}

// exists
try {
  const exists = await sessionService.exists('key')
  if (exists) {
    // ...
  } else {
    // ...
  }
} catch (error) {
  // ...
}

FAQs

Package last updated on 21 Jan 2018

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