0.0.2 • Published 6 years ago

heroku-redis-tools v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

heroku-redis-tools

This package allows programmatic access to a heroku redis instance.

Installation

npm install --save heroku-redis-tools

Usage

herokuRedis(commands, params) => promise

params: {
  apiKey: 'HEROKU_API_KEY',
  app: 'HEROKU_APP_NAME'
}

commands can be a string (for a single command) or array of commands, e.g., ['KEYS *', 'FLUSHALL'] or 'FLUSHALL'.

Auth

Either set process.env.HEROKU_API_KEY or pass your key as a param { apiKey: 'xxxxx' }

You can retrieve your heroku auth token by running:

heroku login # login if necessary
heroku auth:token

Examples

Flush all keys (FLUSHALL)

herokuRedis('MGET "sess:Lx8m6efID7ZZFrFPhajmk_b9LItkyLgs"', { app: 'menubar-dev' })

Get a value (MGET key)

const herokuRedis = require('heroku-redis-tools')

herokuRedis('MGET "sess:Lx8m6efID7ZZFrFPhajmk_b9LItkyLgs"', { app: 'menubar-dev' }).then(resp => {
  console.log(resp)

  => ['{"cookie":{"originalMaxAge":604800000,"expires":"2018-02-23T10:31:25.443Z","httpOnly":true,"path":"/"}}']
})

List all keys (KEYS *)

const herokuRedis = require('heroku-redis-tools')

herokuRedis('KEYS *', { app: 'menubar-dev' }).then(resp => {
  console.log(resp)
  => [
      'sess:vgvS5fgrE8XarmvI8xHpnngr1fgzYxRo',
      'sess:MBYSqShSbh58bsq6ipDj4S3ZbPf0ePhj',
      ...
    ]
})