Socket
Socket
Sign inDemoInstall

sequelize-use-cache

Package Overview
Dependencies
23
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sequelize-use-cache

caching sequelize result using redis


Version published
Maintainers
1
Created

Readme

Source

Sequelize-Use-Cache

caching sequelize result using redis

Installation

npm install --save redis # prerequisite
npm install --save sequelize-use-cache

Usage

Usable methods: findOne, findAll, count, max, min, sum, findByPk, findAndCountAll

parameter

model.findOne({
  // ...options,
  cache: true, // use cache or not, boolean
  expire: 10, // expire time(seconds), integer
})

Example

import Sequelize from 'sequelize'
import Redis from 'redis'
import useCache from 'sequelize-use-cache

const redis = Redis.createClient()
const sequelize = new Sequelize()

// import models
sequelize.define('projects', {
  title: Sequelize.TEXT,
  description: Sequelize.TEXT,
})

useCache(sequelize, redis)

const { projects } = sequelize.models

projects.findAll({
  cache: true,
  expire: 5,
})
console.log(projects.cacheHit) // false

projects.findAll({
  cache: true,
  expire: 5,
})
console.log(projects.cacheHit) // true

License

MIT

reference

  • sequelize-redis-cache

Keywords

FAQs

Last updated on 20 Jun 2020

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc