expresso
  • Get Started
    • 👋Welcome!
    • ⚡Quick Start
  • Expresso Library
    • 📖Introduction
    • ⚛️expresso-core
      • Currency
      • Random String
      • Formatter
      • File
      • Phone
    • ⚓expresso-hooks
      • Multer
      • Token
      • OTP
    • 🚀expresso-provider
      • FCM
      • SMTP
      • Redis
      • Storage
    • 🔗expresso-query
      • TypeORM
      • Sequelize
Powered by GitBook
On this page
  • Initialize Redis
  • Using Redis
  1. Expresso Library
  2. expresso-provider

Redis

Memory Cache with ioredis library

PreviousSMTPNextStorage

Last updated 1 year ago

Redis Provider for expressjs

Using commonjs

const { Redis } = require('expresso-provider')

Using ES6

import { Redis } from 'expresso-provider'

Initialize Redis

// config/redis.ts

import { Redis } from 'expresso-provider'

export const redisService = new Redis({
  host: '127.0.0.1',
  port: 6379,
  password: 'your_password',
})

Using Redis

import { redisService } from 'config/redis'
import { ms } from 'expresso-core'

const keyRedis = 'your_key'
const storeRedis = {
  'text': 'any value'
}
const expires = ms('10m')

// Set Redis
await redisService.set(keyRedis, JSON.stringify(storeRedis), {
  timeout: expires,
})

// Get Redis
const getStore = redisService.get(keyRedis)
🚀
npm: ioredisnpm
memory cache with ioredis
Logo