sequelize-simple-cache
Advanced tools
Comparing version 1.0.0-beta.16 to 1.0.0-beta.17
{ | ||
"name": "sequelize-simple-cache", | ||
"version": "1.0.0-beta.16", | ||
"version": "1.0.0-beta.17", | ||
"description": "A simple, transparent, client-side, in-memory cache for Sequelize", | ||
@@ -36,13 +36,13 @@ "main": "src/SequelizeSimpleCache.js", | ||
"chai-as-promised": "^7.1.1", | ||
"coveralls": "^3.0.2", | ||
"eslint": "^5.7.0", | ||
"coveralls": "^3.0.3", | ||
"eslint": "^5.15.3", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-should-promised": "^2.0.0", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"sequelize": "^4.41.1", | ||
"sinon": "^7.0.0", | ||
"sinon-chai": "^3.2.0" | ||
"mocha": "^6.0.2", | ||
"nyc": "^13.3.0", | ||
"sequelize": "^5.2.1", | ||
"sinon": "^7.3.1", | ||
"sinon-chai": "^3.3.0" | ||
}, | ||
@@ -49,0 +49,0 @@ "dependencies": { |
# sequelize-simple-cache | ||
This is a simple, transparent, client-side, in-memory cache for [Sequelize](https://github.com/sequelize/sequelize) v4. | ||
This is a simple, transparent, client-side, in-memory cache | ||
for [Sequelize](https://github.com/sequelize/sequelize) v4 and v5. | ||
Cache invalidation is based on time-to-live (ttl). | ||
@@ -68,4 +69,5 @@ Selectively add your Sequelize models to the cache. | ||
Currently, the following methods on Sequelize model instances are supported for caching: | ||
`findById`, `findOne`, `findAll`, `findAndCountAll`, `count`, `min`, `max`, `sum`. | ||
The following methods on Sequelize model instances are supported for caching: | ||
`findOne`, `findAndCountAll`, `findByPk`, `findAll`, `count`, `min`, `max`, `sum`. | ||
In addition, for Sequelize v4: `find`, `findAndCount`, `findById`, `findByPrimary`, `all`. | ||
@@ -99,3 +101,7 @@ ### Non-cacheable queries / bypass caching | ||
If the Sequelize methods `update`, `create`, `upsert` or `destroy` are called on the model, the model's cache is automatically cleared by default. You can change this default behavior like this: | ||
By default, the model's cache is automatically cleared if these methods are called: | ||
`update`, `create`, `upsert`, `destroy`, `findOrBuild`. | ||
In addition, for Sequelize v4: `insertOrUpdate`, `findOrInitialize`, `updateAttributes`. | ||
You can change this default behavior like this: | ||
```javascript | ||
@@ -108,2 +114,5 @@ const cache = new SequelizeSimpleCache({ | ||
If you run multiple instances (clients or containers or PODs or alike), | ||
be aware that cache invalidation is more complex that the above simple approach. | ||
### Bypass caching | ||
@@ -110,0 +119,0 @@ |
@@ -9,4 +9,10 @@ const md5 = require('md5'); | ||
ttl: 60 * 60, // 1 hour | ||
methods: ['findById', 'findOne', 'findAll', 'findAndCountAll', 'count', 'min', 'max', 'sum'], | ||
methodsUpdate: ['create', 'update', 'destroy', 'upsert'], | ||
methods: [ | ||
'findOne', 'findAndCountAll', 'findByPk', 'findAll', 'count', 'min', 'max', 'sum', | ||
'find', 'findAndCount', 'findById', 'findByPrimary', 'all', // Sequelize v4 only | ||
], | ||
methodsUpdate: [ | ||
'create', 'update', 'destroy', 'upsert', 'findOrBuild', | ||
'insertOrUpdate', 'findOrInitialize', 'updateAttributes', // Sequelize v4 only | ||
], | ||
limit: 50, | ||
@@ -13,0 +19,0 @@ clearOnUpdate: true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35173
670
175