Socket
Socket
Sign inDemoInstall

redis-serverclient

Package Overview
Dependencies
6
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    redis-serverclient

A no-brainer Redis server + client singleton for node Apps


Version published
Weekly downloads
12
decreased by-7.69%
Maintainers
1
Install size
358 kB
Created
Weekly downloads
 

Readme

Source

redis-serverclient

A no-brainer Redis server + client singleton for node Apps

This npm package uses 'redis-server' and 'redis' npm packages and seves as a singleton wrapper over these awesome npm packages.

Whats New

  1. Optimized for Digital OCean

Installation

  1. Install redis server first
    a. Windows
    b. Mac OS X brew install redis
    c. Linux

  2. Test Redis installation and port
    a. Run redis-server on a terminal
    b. Run redis-cli on another terminal and check if it connects
    c. If everything goes well, close both the terminals.

  3. Install redis-serverclient package npm i --save redis-serverclient

Usage

You can check the test.js file on how to use it. This is pretty simple and straight-forward.

Initiation

// file: app.js

  const redis=require('redis-serverclient');
  redis.init(function(err){
  	if(err)
    	console.log('Redis Error: ',err);
    console.log('Redis running successfully!');
  });

This will initiate redis server and client. You can pass an optional port redis.init(6379,function(err){....
If port is not passed, the default port used will be 6379.

Since redis-serverclient is singleton, you need to initialize it only once in main/index.js file. Require it anywhere and it would maintain the same state.


Set a value

  const redis=require('redis-serverclient');
  
  redis.client.set('name','Gangadhar');

redis.client exposes a redis object from the respective npm package. So, use it as you would use var redisClient=require('redis');.


Get a value

  const redis=require('redis-serverclient');
  
  redis.client.get('name',function(err,reply){
  	console.log('reply: ',reply);
  });

Close Redis instance

redis.close();

This will close the active redis server AND client instance and any firther commands will be halted. Use this when your server is shutting down else, you may end up with error 'Address already in use'.


Access client & server seperately

You may want to individually access the redis client and server, which you can easily get by redis.client and redis.server, respectively.

This package is free to use both commercially and personally without any limitations. However, the author shall not be liable for any damage occured during usage of this software.

'redis-server' and 'redis' packages are fully owned by their own authors(whose links are provided with the hyperlinks) and not me.

Keywords

FAQs

Last updated on 11 Nov 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc