
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@level-two/redis
Advanced tools
A message broker and cache extension for LevelTwo. Refer to the Worker API for function definitions.
import { createLevelTwoRedis } from "@level-two/redis";
// Integrates redis pubsub & cache into a LevelTwo instance
const levelTwo = createLevelTwoRedis({
clientOptions: { url: "redis://localhost:6379" },
});
// Create a worker for getting cacheable customer objects
const worker = levelTwo.createWorker("customer", async (ids, earlyWrite) => {
const rows = await mysql.query(
"SELECT id, name FROM customers WHERE id IN (?)",
[ids]
);
rows.forEach((row) => earlyWrite(row.id, row));
});
// Service method for getting a single customer
export async function getCustomer(id: string): Promise<Customer> {
return await worker.get(id);
}
// Service method for getting a list of customers
export async function getCustomerList(ids: string[]): Promise<Customer[]> {
return await worker.getMulti(ids);
}
redis
Existing redis client that should be used in this extension
clientOptions
Configuration options for creating a new redis client
broadcastChannel
Broadcast channel name for sending/receiving actions. Defaults to "level-two-broadcast"
cachePrefix
String prefix to use in front of each cache key
cacheDisabled
Indicates if cache should be disabled or not. Defaults to enabled
cacheDefaults
LevelTwo worker cache defaults
v2.0.0
Starting with version 2.0.0
: Iterable, peek
, peekMulti
, values
, entries
, forEach
all return CachedEntry
wrapped result values instead of the ResultValue
directly.
Switching to a wrapped CachedEntry
will allow for current and future expansion on utilities for metric tracking of entries.
FAQs
Redis message broker and cache extension of LevelTwo
We found that @level-two/redis 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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.