Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sequelize-simple-cache

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequelize-simple-cache - npm Package Compare versions

Comparing version 1.0.0-beta.6 to 1.0.0-beta.7

3

package.json
{
"name": "sequelize-simple-cache",
"version": "1.0.0-beta.6",
"version": "1.0.0-beta.7",
"description": "A simple, transparent, client-side, in-memory cache for Sequelize",

@@ -49,5 +49,4 @@ "main": "src/SequelizeSimpleCache.js",

"dependencies": {
"bluebird": "^3.5.3",
"md5": "^2.2.1"
}
}

@@ -77,7 +77,7 @@ # sequelize-simple-cache

// this is not good
Model.findOne({ where: { startDate: { [Op.lte]: new Date() }, } });
Model.findAll({ where: { startDate: { [Op.lte]: new Date() }, } });
// you should do it this way
Model.findOne({ where: { startDate: { [Op.lte]: fn('NOW') }, } });
Model.findAll({ where: { startDate: { [Op.lte]: fn('NOW') }, } });
// if you don't want a query to be cached, you may explicitly bypass the cache like this
Model.noCache().findOne(...);
Model.noCache().findAll(...);
```

@@ -84,0 +84,0 @@

@@ -1,2 +0,1 @@

const Promise = require('bluebird');
const md5 = require('md5');

@@ -8,3 +7,3 @@ const { inspect } = require('util');

constructor(config = {}, options = {}) {
this.defaults = {
const defaults = {
ttl: 60 * 60, // 1 hour

@@ -14,3 +13,3 @@ methods: ['findById', 'findOne', 'findAll', 'findAndCountAll', 'count', 'min', 'max', 'sum'],

this.config = Object.entries(config)
.reduce((acc, [name, { ttl = this.defaults.ttl, methods = this.defaults.methods }]) => ({
.reduce((acc, [name, { ttl = defaults.ttl, methods = defaults.methods }]) => ({
...acc,

@@ -67,3 +66,3 @@ [name]: { ttl, methods },

}
const fn = (...args) => {
const fn = async (...args) => {
const hash = SequelizeSimpleCache.hash({ name, prop, args });

@@ -77,3 +76,3 @@ const item = this.cache.get(hash);

});
return Promise.resolve(data); // resolve from cache
return data; // resolve from cache
}

@@ -87,3 +86,3 @@ }

}
return Promise.resolve(data); // resolve from database
return data; // resolve from database
});

@@ -90,0 +89,0 @@ };

@@ -357,5 +357,5 @@ const chai = require('chai');

sinon.stub(User, 'findOne').returns({ username: 'foo' }); // should be `resolves`
expect(() => User.findOne({ where: { username: 'foo' } }))
.to.throw('User.findOne() did not return a promise but should');
User.findOne({ where: { username: 'foo' } })
.should.be.rejectedWith(Error, 'User.findOne() did not return a promise but should');
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc