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.12 to 1.0.0-beta.13

2

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

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

@@ -107,3 +107,3 @@ # sequelize-simple-cache

This cache meant as a simple in-memory read cache for a very limited amount of data.
This cache is meant as a simple in-memory cache for a very limited amount of data.
So, you should be able to control the size of the cache.

@@ -110,0 +110,0 @@ ```javascript

@@ -23,3 +23,3 @@ const md5 = require('md5');

debug = false,
ops = false, // eslint-disable-next-line no-console
ops = 0, // eslint-disable-next-line no-console
delegate = (event, details) => console.debug(`CACHE ${event.toUpperCase()}`, details),

@@ -91,3 +91,3 @@ } = options;

this.log('load', { key, hash, expires });
if (cache.size > limit) { // check cache limit
if (cache.size > limit) {
let oldest = {};

@@ -138,3 +138,3 @@ cache.forEach(({ expires: e }, h) => {

// logging
if (!this.debug && ['init', 'hit', 'miss', 'load', 'purge'].includes(event)) return;
if (!this.debug && event !== 'ops') return;
this.delegate(event, {

@@ -141,0 +141,0 @@ ...details,

@@ -29,6 +29,10 @@ const chai = require('chai');

it('should create cache without crashing / no args', () => {
expect(() => new SequelizeSimpleCache({}, { ops: false })).to.not.throw();
expect(() => new SequelizeSimpleCache()).to.not.throw();
});
it('should create cache without crashing / empty args', () => {
it('should create cache without crashing / empty args / 1', () => {
expect(() => new SequelizeSimpleCache({}, {})).to.not.throw();
});
it('should create cache without crashing / empty args / 2', () => {
expect(() => new SequelizeSimpleCache({}, { ops: false })).to.not.throw();

@@ -137,2 +141,24 @@ });

it('should cache result and clear cache by model (via cache) / unknown model name', async () => {
const stub = sinon.stub().resolves({ username: 'fred' });
const model = {
name: 'User',
findOne: stub,
};
const model2 = {
name: 'Page',
findOne: sinon.stub().resolves({ foo: true }),
};
const cache = new SequelizeSimpleCache({ User: {}, Page: {} }, { ops: false });
const User = cache.init(model);
const Page = cache.init(model2);
const result1 = await User.findOne({ where: { username: 'fred' } });
const result2 = await Page.findOne({ where: { foo: true } });
expect(cache.size()).to.be.equal(2);
cache.clear('Foo');
expect(result1).to.be.deep.equal({ username: 'fred' });
expect(result2).to.be.deep.equal({ foo: true });
expect(cache.size()).to.be.equal(2);
});
it('should cache result and clear cache by model (via model)', async () => {

@@ -139,0 +165,0 @@ const stub = sinon.stub().resolves({ username: 'fred' });

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