
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@cortec/redis
Advanced tools
@cortec/redis provides a flexible Redis integration for Node.js applications, supporting both single-node and cluster setups. It offers convenient methods for accessing Redis caches, performing health checks, and transforming objects for hash operations. The module is designed to work seamlessly with the Cortec context and configuration system.
Where to put config:
Place your Redis config in config/default.yml (or your environment-specific config file).
Schema:
redis:
cache:
connection:
host: 'localhost'
port: 6379
password: 'secret' # optional
db: 0 # optional, default: 0
maxRetries: 5 # optional, default: 5
encryption: false # optional, enables TLS if true
cluster: # optional, enables Redis Cluster mode
nodes:
- host: 'localhost'
port: 6379
- host: 'localhost'
port: 6380
Field-by-field explanation:
redis: Root key for Redis config.cache: Identity/name for this Redis instance (can be any string, e.g. "session", "main", etc.).connection: Connection options for ioredis.
host: Redis server hostname or IP.port: Redis server port.password: Password for authentication (optional).db: Database index (optional, default is 0).maxRetries: Maximum number of retry attempts before giving up (optional, default is 5).encryption: If true, enables TLS/SSL for secure connections (optional).cluster: If present, enables Redis Cluster mode.
nodes: List of cluster node objects, each with host and port.How config is loaded:
The config is loaded automatically by the @cortec/config module and validated at runtime.
Access it in code via:
const config = ctx.provide<IConfig>('config');
const redisConfig = config?.get<any>('redis');
If config is missing or invalid, an error is thrown at startup.
import CortecRedis from '@cortec/redis';
// Instantiate with optional object transformation for hash operations
const redisModule = new CortecRedis(true);
// After loading the context and configuration:
const cache = redisModule.cache('cache'); // 'cache' is the identity from config
// Set and get a value
await cache.set('key', 'value');
const value = await cache.get('key');
console.log(value); // 'value'
await redisModule.healthCheck(); // Throws if any Redis instance is unreachable
If your configuration includes a cluster section, you can access the cluster instance in the same way:
const clusterCache = redisModule.cache('clusteredCache');
await clusterCache.set('key', 'value');
If you instantiate CortecRedis with transformObjects = true, you can use objects directly with hset and get parsed objects from hgetall:
const redisModule = new CortecRedis(true);
const cache = redisModule.cache('cache');
await cache.hset('user:1', { name: 'Alice', age: 30 });
const user = await cache.hgetall('user:1');
console.log(user); // { name: 'Alice', age: 30 }
To gracefully close all Redis connections:
await redisModule.dispose();
For integration or unit tests, you can use TestableCortecRedis to spin up a disposable Redis container using testcontainers. This allows you to run tests against a real Redis instance without needing a local or shared Redis server.
You can use TestableCortecRedis together with Cortec core to run integration tests against a real, disposable Redis instance—no manual setup required.
import Cortec from '@cortec/core';
import TestableCortecRedis from '@cortec/redis/testable';
const cortec = new Cortec({ name: 'test-app', version: '1.0.0' });
const redis = new TestableCortecRedis({ version: '7.2' }, true);
cortec.use(redis);
// After Cortec is loaded:
const cache = redis.cache('cache');
await cache.set('key', 'value');
const value = await cache.get('key');
console.log(value); // 'value'
For more details, see the implementation in src/index.ts and ensure your configuration matches your deployment needs (single-node or cluster).
FAQs
<description>
We found that @cortec/redis 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.