
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@vortus-solutions/redis-service
Advanced tools
A robust Redis service client for Node.js applications
A Node.js package that provides a robust Redis service implementation with built-in Lua script support. This package helps manage Redis connections and execute predefined Lua scripts efficiently.
npm install @vortus-solutions/redis-service
const RedisService = require('@vortus-solutions/redis-service');
// Create a single instance connection
await RedisService.createConnection('main', {
host: '127.0.0.1',
port: 6379,
db: 0
}, []);
// Or create a cluster connection
await RedisService.createClusterConnection('cluster', {
nodes: [
{ host: 'redis-node1.example.com', port: 6379 },
{ host: 'redis-node2.example.com', port: 6379 }
]
}, []);
// Get connection instance
const redis = RedisService.getConnection('main');
Adds a member to a sorted set with a limit on the total number of members.
Parameters:
key: Sorted set keyscore: Member scoremember: Value to addlimit: Maximum number of membersoffset: Number of members to remove from startSets expiration on a key only if it doesn't have one.
Parameters:
key: Redis keyttl: Time to live in secondsSets hash field value only if new value is higher than existing.
Parameters:
key: Hash keyfield: Hash fieldvalue: New valueSets hash field value only if new value is lower than existing.
Parameters:
key: Hash keyfield: Hash fieldvalue: New valueRetrieves polyline chunks based on latitude and longitude bounds.
Parameters:
key: Base key for polyline datalatitude: Target latitudelongitude: Target longitudenew RedisService()
createConnection(connectionName, options = {}, luaScriptNames = []): Creates a new Redis single-instance connection.createClusterConnection(connectionName, options = {}, luaScriptNames = []): Creates a new Redis cluster connection.getConnection(connectionName): Returns the existing connection by name.closeAll(): Closes all active connections.register(name, script): Register a new Lua script.get(name): Get a script by name.getScripts(names): Get multiple scripts by their names.getAvailableScripts(): List all available scripts.Default connection options can be customized when creating a connection. The service supports both single Redis instances and Redis clusters with separate methods. All additional options are forwarded directly to ioredis, supporting its full range of configuration options.
Use with createConnection() method:
const singleInstanceOptions = {
enableAutoPipelining: false,
showFriendlyErrorStack: true,
enableOfflineQueue: true,
host: '127.0.0.1',
port: 6379,
db: 0
};
// Create single instance connection
await RedisService.createConnection('main', singleInstanceOptions, []);
Use with createClusterConnection() method:
const clusterOptions = {
nodes: [
{ host: '127.0.0.1', port: 6379 },
{ host: '127.0.0.1', port: 6380 }
],
scaleReads: 'slave',
clusterRetryStrategy: (times) => Math.min(times * 100, 2000),
maxRedirections: 16,
enableAutoPipelining: true,
showFriendlyErrorStack: true
};
// Create cluster connection
await RedisService.createClusterConnection('cluster', clusterOptions, []);
enableAutoPipelining: Enable automatic pipelining for improved performanceshowFriendlyErrorStack: Show detailed error stack tracesenableOfflineQueue: Enable offline queue for connection retrieskeyPrefix: Prefix for all Redis keyspassword: Redis authentication passwordtls: Enable TLS encryptionThe package includes built-in error handling for connection issues:
try {
// For single instance
await RedisService.createConnection('main', { host: 'localhost' });
// Or for cluster
await RedisService.createClusterConnection('cluster', { nodes: [...] });
} catch (error) {
console.error('Redis connection error:', error);
}
await RedisService.closeAll();
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
A robust Redis service client for Node.js applications
We found that @vortus-solutions/redis-service demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.