
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Storing data in the form of key into the file
requires node 4+
npm install key-cache --save
// Create reference
var KeyCache = require('key-cache');
// Examples of objects
var cache = new KeyCache(options);
// Here you can use to manipulate the cache api
cache.get('balbalbal');
Cache directory path based on the current run directory
/**
* @default key-cache installation path of .cache/ directory
* @type {String}
*/
Save time, in seconds, if empty will always exist
/**
* @default null
* @type {number|null}
*/
Set whether to use md5 named cache file name,To path is valid, it will filter the illegal character key, in addition to Chinese, letters, numbers, -, other characters will be ignored outside _, regular use is/[^\u4e00-\u9fa5a-zA-Z\_\-0-9]/g.
/**
* @default true
* @type {Boolean}
*/
Write data to a file
/**
* @param {string} key
* @param {Object|string} value
* @param {Object|undefined} options If there will override the default configuration
* @return {Object} this
*/
set(key, value, options = {})
Get data from files
/**
* @param {string} key
*
* @return {Object|string|null} If there is no time has expired or will return null
*/
get(key)
Delete data, and delete files
/**
* @param {string|undefined} key
*
* @return {Object} this
*/
remove(key)
var cache = new KeyCache();
cache.set('name', 'key-cache');
console.log(cache.get('name'));
cache.remove('name');
console.log(cache.get('name')); // => null
var cache = new KeyCache({
dir: '../cache/'
});
cache.set('name', 'key-cache');
// override the default configuration
cache.set('name2', 'key-cache', {
dir: './cache2'
});
var cache = new KeyCache({
timeout: 3
});
cache.set('name', 'key-cache');
// override the default configuration
cache.set('age', 1, {
timeout: 5
});
setTimeout(function(){
console.log(cache.get('name')); // => null
console.log(cache.get('age')); // => 1
}, 3000);
var cache = new KeyCache();
cache.set('name', 'key-cache');
cache.set('age', 1);
// Delete single
cache.remove('name');
console.log(cache.get('name')); // => null
console.log(cache.get('age')); // => 1
// Delete all
cache.remove();
console.log(cache.get('age')); // => null
Do not use md5 named cache file
var cache = new KeyCache({
md5key: false
});
cache.set('key', 'key-cache'); // => filename is key.json
cache.set('age', 1); // => filename is age.json
cache.set('this a space +-', 1); // => filename is thisaspace-.json
cache.set('中文', 1); // => filename is 中文.json
Use es6 development, compiler-dependent babel 6.x
// Run the compiler, the es6 code from the compiled into lib in src
npm run compile
// Monitor file changes and runs the compiler
npm run watch
// Use fecs run Style Checker
npm run check
// Use mocha run the test case
npm run test
// Run the test cases and code coverage
npm run test-cov
Add nodejs V8 test environment
add .getAll()
stand by node 4.x+
Modify api: fs.existsSync=>fs.statSync
Add nodejs 6.x test environment
Update test case to ES6
babel 6.x upgrade to compile
precommit to prepushReturn Value Type Repair function when the value is, the change from the undefined to null~
Add options.md5key parameter is used to set whether to use md5 named cache file name
Optimized code, add a test case
MIT
FAQs
Storing data in the form of key into the file
We found that key-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.