
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@mediaxpost/memory-cache
Advanced tools
A Promise-based, simple, Redis-like, in-memory cache written in pure Javascript
memory-cache
is a simple, Redis-like, in-memory cache written in pure Javascript.
Memory Cache is designed to be a fully-functional stand-in replacement for mocking Redis and fail-over in production systems for when Redis is not available. This package is intentionally designed to mimic the behavior of the node redis
module and can be used with nearly all commands supported by Redis†.
Unlike some other Redis mocking library, thought has been put into achieving full Redis command coverage. Many other libraries only provide incomplete coverage by providing only the most commonly used commands. MemoryCache currently provides 224 of 267 (~85%) of the available Redis commands. With coverage for the remaining commands planned. All commands have been rigorously tested with over 500 unit test.
npm install @mediaxpost/memory-cache
const MemoryCache = require('@mediaxpost/memory-cache');
const client = new MemoryCache({ bypassUnsupported: true });
client.createClient();
client.set("TestKey", 10);
client.get("TestKey");
Create a new MemoryCache client with the passed options. MemoryCache only supports one option bypassUnsupported
which if set true
causes any unsupported commands to fail silently instead of throwing an error.
const MemoryCache = require('@mediaxpost/memory-cache');
const client = new MemoryCache({ bypassUnsupported: true });
Connect to the memory cache and emits the connect
and ready
events.
Disconnects from the memory cache and emits the end
event.
Disconnects from the memory cache and emits the end
event. Unlike the Redis client this is identical to calling quit.
Where possible, this module mimics the return data behavior of the Redis module. For example, the .hmset
will accept a single object hash to set multiple fields. Similar .hmget
will return an object hash.
Many Redis commands like set
, mget
, etc. accept multiple parameters. The memory cache library support passing all additional parameters.
For example:
client.mget('key1', 'key2', 'key3', 'key4');
Additionally, if a command is multiple words, then the additional portion of the command may be passed as the first parameter.
For example:
client.flushall('async');
Every Redis command can be called with *Async
at the end. This will invoke the Promisified variant of the command and return a Promise.
For Example:
client.getAsync('testkey')
.then((res) => {
// Do something useful
})
.catch((err) => {
// Do something useful
});
MemoryCache support all but a select few Redis Commands and returns then data as close to identically as possible to the redis
module. Any errors are thrown as exceptions which should be caught. The commands which are unavailable are as follows:
If an unavailable command is issued, then the module throws a MemoryCacheError -- "MemoryCache does not support that operation". This thrown error can be bypassed by passing the option bypassUnsupported
as true in the constructor. Or by directly setting your MemoryCache instance instance.options.bypassUnsupported = true
Copyright (c) 2018 Jay Reardon -- Licensed under the MIT license.
FAQs
A Promise-based, simple, Redis-like, in-memory cache written in pure Javascript
We found that @mediaxpost/memory-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 how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.