Socket
Socket
Sign inDemoInstall

sequelize-use-cache

Package Overview
Dependencies
0
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
Weekly downloads
3
decreased by-25%

Weekly downloads

Readme

Source

Sequelize-Use-Cache

caching sequelize result using redis

https://www.npmjs.com/package/sequelize-use-cache

Installation

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

Usage

Usable methods

All select queries

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(sequelize.cacheHit) // false

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

License

MIT

reference

Keywords

FAQs

Last updated on 22 Sep 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