Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redis-in-docker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-in-docker

## Purpose

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

redis-in-docker

Purpose

Module starts redis server inside docker container. This is helpful while testing.

Installation

NOTE: Docker required.

npm i redis-in-docker --save

Usage

IRedisInDockerOptions options

interface IRedisInDockerOptions {

  // use redis v4, by default v5 is used [optional]
  redisV4?: boolean;

  // if true, all actions will be logged to console, default is false [optional]
  verbose?: boolean;

  // if specified, then it will be used to store redis database after shutdown
  // note: should be accessible by docker
  storage?: string;
}

Methods

constructor(options?: IRedisInDockerOptions)

Constructor

start()

Starts docker container with redis server. If succeeded, then port, host, etc. properties become available.

stop()

Stops running docker container. After completion all port, host, etc. properties become unavailable.

client() => IORedis

Returns redis client.

Properties

host: string | undefined

Returns domain or ip of running redis server.

port: number | undefined

Returns port redis server is listening to.

Example

const RedisContainer  = require('redis-in-docker');

async function main() {
  const options = {
    // See IRedisInDockerOptions
  };

  // instantiate
  const container = new RedisContainer(options);

  // boot
  await container.start();

  const port = container.port;
  const host = container.host;

  // do some work
  ...

  // shutdown
  await container.stop();
}

or if you want to use storage:

const RedisContainer  = require('redis-in-docker');

async function main() {
  const options = {
    // See IRedisInDockerOptions

    storage: '/my-path'
  };

  // instantiate
  const container = new RedisContainer(options);

  // boot
  await container.start();

  const port = container.port;
  const host = container.host;

  // do some work
  ...

  // shutdown
  await container.stop();

  // Restore after some from the same storage
  await container.start();

  // Work with restored database
  ...

  // shutdown again
  await container.stop();
}

License

MIT. See LICENSE

Author

Siarhei Ladzeika sergey.ladeiko@gmail.com

FAQs

Package last updated on 22 Nov 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc