Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@coolgk/cache
Advanced tools
a javascript / typescript module
npm install @coolgk/cache
a redis wrapper
import { Cache } from '@coolgk/cache';
import { createClient } from 'redis';
// OR
// const { Cache } = require('@coolgk/cache');
// const { createClient } = require('redis');
const client = createClient({
host: 'localhost',
port: 12869,
password: '----'
});
const cache = new Cache({
redisClient: client
});
cache.set('abc', {a: 1}, 1).then(console.log); // 'OK'
cache.get('abc').then(console.log); // { a: 1 }
setTimeout(() => {
cache.get('abc').then(console.log); // null
client.quit();
}, 1500);
cache.getSetIfNull(
'abc',
() => Promise.resolve('data'),
10
).then((v) => {
console.log(v); // { a: 1 }
});
Promise.all([
cache.set('x', 'val x'),
cache.set('y', 'val y'),
cache.set('z', 'val z')
]).then(
() => Promise.all([
cache.get('x').then(console.log), // val x
cache.get('y').then(console.log), // val y
cache.get('z').then(console.log) // val z
])
).then(
() => Promise.all([
cache.delete('x'),
cache.delete('y'),
cache.delete('z')
])
).then(
() => Promise.all([
cache.get('x').then(console.log), // null
cache.get('y').then(console.log), // null
cache.get('z').then(console.log) // null
])
);
Kind: global class
promise
promise
promise
promise
promise
Param | Type | Description |
---|---|---|
options | object | |
[options.redisClient] | object | redis client from redis.createClient() redisClient needs to be passed in so the same connection can be used elsewhere and get closed outside this class |
promise
Kind: instance method of Cache
Param | Type | Default | Description |
---|---|---|---|
name | string | name of the variable | |
value | * | value is always JSON.stringify'ed | |
[expiry] | number | 0 | expire time in seconds. 0 = never expire |
promise
Kind: instance method of Cache
Returns: promise
- - cached value
Param | Type | Description |
---|---|---|
name | string | name of the variable |
promise
Kind: instance method of Cache
Param | Type | Description |
---|---|---|
name | string | Array.<string> | name(s) of the variable |
promise
get the cached value, if not set, resolve "callback()" and save the value then return it
Kind: instance method of Cache
Returns: promise
- - cached value
Param | Type | Default | Description |
---|---|---|---|
name | string | name of the variable | |
callback | function | a callback function which returns a value or a promise | |
[expiry] | number | 0 | expire time in seconds. 0 = never expire |
promise
Kind: instance method of Cache
Param | Type | Description |
---|---|---|
command | string | redis command to run |
...params | array | params for the command |
FAQs
a redis wrapper
The npm package @coolgk/cache receives a total of 4 weekly downloads. As such, @coolgk/cache popularity was classified as not popular.
We found that @coolgk/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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.