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

redis-serverclient

v1.2.2

Published

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

Downloads

50

Readme

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.

Copyright Notice

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.