
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
@ioredis/commands
Advanced tools
@ioredis/commands is an npm package that provides a comprehensive list of Redis commands for use with the ioredis library. It allows developers to interact with Redis databases by executing various commands related to data manipulation, server management, and more.
String Operations
This feature allows you to perform basic string operations such as setting and getting the value of a key in Redis.
const Redis = require('ioredis');
const redis = new Redis();
// Set a key-value pair
redis.set('key', 'value');
// Get the value of a key
redis.get('key', (err, result) => {
console.log(result); // 'value'
});
Hash Operations
This feature allows you to perform operations on hash data structures in Redis, such as setting and getting fields.
const Redis = require('ioredis');
const redis = new Redis();
// Set a field in a hash
redis.hset('hash', 'field', 'value');
// Get a field from a hash
redis.hget('hash', 'field', (err, result) => {
console.log(result); // 'value'
});
List Operations
This feature allows you to perform operations on list data structures in Redis, such as pushing and popping values.
const Redis = require('ioredis');
const redis = new Redis();
// Push a value to a list
redis.lpush('list', 'value');
// Pop a value from a list
redis.rpop('list', (err, result) => {
console.log(result); // 'value'
});
Set Operations
This feature allows you to perform operations on set data structures in Redis, such as adding members and checking membership.
const Redis = require('ioredis');
const redis = new Redis();
// Add a member to a set
redis.sadd('set', 'member');
// Check if a member exists in a set
redis.sismember('set', 'member', (err, result) => {
console.log(result); // 1 if member exists, 0 otherwise
});
Pub/Sub
This feature allows you to use the publish/subscribe messaging paradigm in Redis, enabling you to send and receive messages between different parts of your application.
const Redis = require('ioredis');
const redis = new Redis();
const subscriber = new Redis();
// Subscribe to a channel
subscriber.subscribe('channel');
// Listen for messages
subscriber.on('message', (channel, message) => {
console.log(`Received message: ${message} from channel: ${channel}`);
});
// Publish a message
redis.publish('channel', 'Hello, world!');
The 'redis' npm package is a popular client for interacting with Redis databases. It provides a similar set of functionalities for executing Redis commands, but it is generally considered to be less feature-rich and less performant compared to ioredis.
The 'node-redis' package is another Redis client for Node.js. It offers a straightforward API for executing Redis commands and is known for its simplicity and ease of use. However, it may lack some of the advanced features and optimizations found in ioredis.
This module exports all the commands that Redis supports.
$ npm install @ioredis/commands
const commands = require('@ioredis/commands');
.list
is an array contains all the lowercased commands:
commands.list.forEach((command) => {
console.log(command);
});
.exists()
is used to check if the command exists:
commands.exists('set') // true
commands.exists('other-command') // false
.hasFlag()
is used to check if the command has the flag:
commands.hasFlag('set', 'readonly') // false
.getKeyIndexes()
is used to get the indexes of keys in the command arguments:
commands.getKeyIndexes('set', ['key', 'value']) // [0]
commands.getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
FAQs
Redis commands
The npm package @ioredis/commands receives a total of 4,468,205 weekly downloads. As such, @ioredis/commands popularity was classified as popular.
We found that @ioredis/commands demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.