How to use handy-redis - 3 common examples

To help you get started, we’ve selected a few handy-redis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DFEAGILEDEVOPS / MTC / func-check-gen / check-allocator / index.ts View on Github external
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise {
  // init redis
  const redis = Redis.createHandyClient({
    host: process.env.RedisHost,
    password: process.env.RedisKey,
    port: 6380,
    tls: process.env.RedisHost
  })
  // TODO generate SAS token(s)
  const tokens = Array()
  const expireTokenAt = Moment().add(1, 'day')
  const sasTokenService = new SasTokenService()
  const queues = ['check-submitted', 'check-started', 'pupil-prefs', 'pupil-feedback']
  queues.forEach((q) => {
    const token = sasTokenService.generateSasToken(q, expireTokenAt)
    tokens.push(token)
  })

  // TODO load all pupils via SQL (schoolUUID(urlSlug), pupilUUID(urlSlug))
github staart / api / src / helpers / redis.ts View on Github external
import { createHandyClient } from "handy-redis";
import { REDIS_URL } from "../config";
import { logError } from "./errors";

export const redis = createHandyClient({
  url: REDIS_URL,
  retry_strategy: options => {
    if (options.error && options.error.code === "ECONNREFUSED") {
      logError("Redis connection failed", "Server refused the connection");
    }

    if (options.total_retry_time > 1000 * 60 * 60) {
      logError("Redis connection failed", "Total retry time exhausted");
    }

    if (options.attempt > 10) {
      logError("Redis connection failed", "Max number of attempts exceeded");
      return 43200;
    }

    // Reconnect after this time
github DFEAGILEDEVOPS / MTC / func-check-gen / check-allocator / poc-index.ts View on Github external
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise {
  // init redis
  const redis = Redis.createHandyClient({
    host: process.env.RedisHost,
    password: process.env.RedisKey,
    port: 6380,
    tls: process.env.RedisHost
  })

  const tokens = Array()
  const expireTokenAt = Moment().add(1, 'day')
  const sasTokenService = new SasTokenService()
  const queues = ['check-submitted', 'check-started', 'pupil-prefs', 'pupil-feedback']
  queues.forEach((q) => {
    const token = sasTokenService.generateSasToken(q, expireTokenAt)
    tokens.push(token)
  })

  // TODO load all pupils via SQL (schoolUUID(urlSlug), pupilUUID(urlSlug))

handy-redis

A redis client with first-class Promise and TypeScript support, and extensive documentation.

Apache-2.0
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular handy-redis functions