npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@reshuffle/redis-connector

v0.0.1

Published

Reshuffle connector to Redis

Downloads

2

Readme

reshuffle-redis-connector

Code | npm | Code sample

npm install reshuffle-redis-connector

Reshuffle Redis Connector

This package contains a Reshuffle connector to Redis databases.

The following example sets and gets a value from Redis:

const { Reshuffle } = require('reshuffle')
const { RedisConnector } = require('reshuffle-redis-connector')

const app = new Reshuffle()

const redis = new RedisConnector(app, {
  endpoint: process.env.REDIS_ENDPOINT,
  password: process.env.REDIS_PASSWORD,
})

async function main() {
  try {
    await redis.set('key', 'value')
    console.log(await redis.get('key')) // 'value'
  } catch (error) {
    console.error(error)
  }   
}

app.start()
main()

Table of Contents

Configuration Options

Connector actions

sequence Run a sequence of queries

transaction Run a sequence of queries inside a transaction

sdk Returns the Node Redis Client that allows direct calls to the underlying redis

close Close redis connections

Configuration options

const app = new Reshuffle()
const redis = new RedisConnector(app, {
  endpoint: process.env.REDIS_ENDPOINT, // <hostname>:<port>
  password: process.env.REDIS_PASSWORD,
})

Connector actions

Sequence action

Definition:

(
  seq: (query) => any,
) => any

Usage:

const res = await res.sequence(async (conn) => {
  const val = conn.get('key')
  conn.set('key', val + 1)
})

Use sequence to perform multiple queries on the same database connection. This assures sequential access, but not atomicity in case other connections are open to the database.

Transaction action

Definition:

(
  seq: (query) => any,
) => any

Usage:

await redis.transaction(async (multi) => {
  const val = multi.get('key')
  multi.set('key', val + 1)
})

Use transaction to execute multiple queries as an atomic sequence using a Redis transaction and the MULTI command.

All operations either succeed or fail together.

SDK action

The sdk() action provides raw access to the async version of npm redis. The following actions are provided as convenience wrappers for its corresponding async methods.

For instance, calling redis.sdk().append() is equivalent to redis.append(). You can access the methods not listed below using the redis.sdk(). notation.

async function append(key: string, value: any)
async function decr(key: string)
async function decrby(key: string, decrement: number)
async function del(key: string)
async function exists(key: string)
async function get(key: string)
async function getset(key: string, value: string)
async function hdel(key: string, field: string)
async function hexists(key: string, field: string)
async function hget(key: string, field: string)
async function hgetall(key: string)
async function hincrby(key: string, field: string, increment: number)
async function hincrbyfloat(key: string, field: string, increment: number)
async function hkeys(key: string)
async function hlen(key: string)
async function hmget(key: string, fields: string[])
async function hmset(key: string, dict: Record<string, any>)
async function hset(key: string, field: string, value: any)
async function hsetnx(key: string, field: string, value: any)
async function hstrlen(key: string, field: string)
async function hvals(key: string)
async function incr(key: string)
async function incrby(key: string, increment: number)
async function incrbyfloat(key: string, increment: number)
async function mget(keys: string[])
async function mset(dict: Record<string, any>)
async function set(key: string, value: any)
async function setnx(key: string, value: any)
async function keys(pattern: string): Promise<string[]>

Close action

Definition:

() => void

Usage:

await redis.close()

Close all connections to redis. If an application terminates without calling close, it might hang for a few seconds until all active connections time out.