You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@level-two/redis

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@level-two/redis

Redis message broker and cache extension of LevelTwo

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
1
-90%
Maintainers
1
Weekly downloads
 
Created
Source

LevelTwo - Redis

A message broker and cache extension for LevelTwo. Refer to the Worker API for function definitions.

Usage

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);
}

Settings

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

Keywords

cache

FAQs

Package last updated on 17 Jul 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.