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

basic-redis-factory

v0.0.3

Published

a redis client factory to simplify redis client creation for basic use cases

Downloads

166

Readme

Basic Redis Factory

A module that should make creating redis client instances from connection strings much easier. It does not require/install redis itself so the user can decide what version to load.

This module operates "synchronously" so you have an opportunity to attach event listeners to the redis client in the same cycle of the event loop as the one where the client is created.

This is a first draft and I'm open to renaming things and changing arguement structures etc. Yes, I realise this should probably be called a redis client factory but thats not quite as catchy and I didn't realise that at the time

Major Props / big shout / thanks to Jose-Luis Rivas / ghostbar for writing the majority of the option parsing code that I've basically just extracted into a module.

Example

also see the /examples folder for working demos


var redisFactory = require('basic-redis-factory');
var redis = require('redis');

var connectionUrl = 'redis://user:[email protected]:3444'

//either

var client = redisFactory(redis, connectionUrl)

// or if you want to bind a the factory function to a redis module in one place
// and call the factory in another

var myFactory = redisFactory.factory(redis);
// and then somewhere else maybe...
var client = myFactory(opts);


//do some userland stuff like attach event listeners
client.on('error', myErrorHandler)

API

The main export is a function that constructs the redis client

var redisFactory = require('basic-redis-factory');
var client = redisFactory(redis, opts);

it's arguments are

  • redis: the redis module to use
  • opts : either a url connection string or an object

if opts is an object then the factory will look for the following keys on the object and fallback to defaults for any missing values (host: 127.0.01, port: 6379, no authentication).

  • url : a url connection string.
  • host: the host to connect to.
  • port: the port to connect to.
  • password: the password to authenticate with, if not supplied then no auth will applied.
  • opts: an options object as expected by redis.createClient.

If opts.url is supplied then opts.host, opts.port, and opts.password keys will be ignored.

A factory function is available on the main export. This function allows you have a factory instance that is bound to a redis module.

var redis = require('redis');
var redisFactory = require('basic-redis-factory').factory(redis);
var client = redisFactory(opts);

This maybe useful to you if you wish to bind the factory to a particular redis module at some point in your app, so that other parts of your application can use the factory and just supply a configuration.

TODO

  • Add some tests!

Fixes, Improvements, Suggestion

I'm open to any and all fixes, changes, improvements, questions in whatever format suits you. Feel free to open a PR, or an issue, reach me on twitter, email or on any other medium that you are comfortable with.

While this repo has no CoC right now, lets all just assume it does and play nicely. Abusive behaviour will not be tolerated. If you see something you don't like, please do tell me, or if you aren't comfortable doing that yourself I'll understand if you get someone else to do it on your behalf.

License

MIT