Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
cache-storage
Advanced tools
Advanced cache storage inspired by cache in Nette framework.
Can be also used in browser for example with simq.
Unfortunately I don't have any more time to maintain this repository :-(
Don't you want to save me and this project by taking over it?
$ npm install cache-storage
Required node version: >= 0.9
var Cache = require('cache-storage');
var FileStorage = require('cache-storage/Storage/FileSyncStorage');
var cache = new Cache(new FileStorage('./temp'), 'namespace');
You have to set storage which you want to use (their list below) and namespace for cache, because you can use more than one independent caches.
cache-storage/Storage/FileSyncStorage
: saving data into json filescache-storage/Storage/BrowserLocalSyncStorage
: saving data into HTML5 local storagecache-storage/Storage/DevNullSyncStorage
: does not save anything and load always nullcache-storage/Storage/MemorySyncStorage
: saving data just into storage's class propertiescache-storage/Storage/FileAsyncStorage
cache-storage/Storage/DevNullAsyncStorage
cache-storage/Storage/MemoryAsyncStorage
cache-storage/Storage/RedisAsyncStorage
: uses redis packageMore storages will be added in future.
cache-storage/Storage/FileSyncStorage
cache-storage/Storage/FileAsyncStorage
cache-storage/Storage/RedisAsyncStorage
cache-storage/Storage/BrowserLocalSyncStorage
This storage exposes some variables from original package (redis).
cache.storage.selectDatabase(3, function(err) {
console.log('changed database');
});
cache.storage.client; // original client object from redis module
var data = cache.load('some_data');
if (data === null) {
// let's save data to cache
data = cache.save('some_data', 'some value of some_data');
}
console.log(data); // output: some value of some_data
There is also other more simple way to save data to cache if they are not in cache already.
var data = cache.load('some_data', function() {
return 'some value of some_data';
});
When no data were found, then fallback anonymous function is called and data from return statement are used. Cache.save function always return given data.
cache.load('some_data', function(err, data) {
if (data === null) {
cache.save('some_data', 'some value of some_data', function(err, savedData) {
console.log(savedData); // output: some value of some_data
});
}
});
or with fallback:
cache.load('some_data', function() {
return 'some value of some_data';
}, function(data) {
console.log(data); // output: some value of some_data
});
cache.remove('some_data');
or:
cache.save('some_data', null);
cache.remove('some_data', function(err) {
console.log('removed some_data');
});
You can set some conditions and information for every data which will be used for auto expiration or for your manual expiration.
cache.save('some_data', 'some value of some_data', {
files: ['./images.txt', './info.txt'], // expiration by files
tags: ['image', 'article'], // tags for manual expiration
expire: '2015-12-24 18:00', // expire data in given date (other examples below)
items: ['some_other_data'], // expire if other data in cache expires
priority: 50 // example below
});
If you set files to save function, then that item will expire when some of given files is changed.
This type of expiration can be used also in browser, but only with simq and with allowed
option filesStats
. See at documentation of simq.
Second argument in clean
method is callback with possible error, this is used just for asynchronous storages.
cache.clean({
tags: ['image']
});
Now every item in cache with tag image will be removed.
There are two ways to expire data by date. First way is to set exact date in YYYY-MM-DD HH:mm format. Second way is to set literal object with information about adding date to actual date.
cache.save('some_data', 'some value of some_data', {
expire: {days: 1}
});
Now some_data will expire tomorrow. You can see full documentation in moment.js documentation.
Every cache item can also depend on other cached items. If some of these other items is invalidated, then also this main is invalidated.
cache.clean({
priority: 100
});
All items with priority 100 or below will expire.
cache.clean(Cache.ALL); // or cache.clean('all');
$ npm test
2.0.1
2.0.0
Sync
to old storages' names (original names are deprecated)1.4.1
1.4.0
1.3.0
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.2
1.1.1
1.1.0
1.0.2
1.0.1
1.0.0
FAQs
[ABANDONED] Advanced cache storage for node js
The npm package cache-storage receives a total of 19 weekly downloads. As such, cache-storage popularity was classified as not popular.
We found that cache-storage 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.