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

push-ioredis

v1.0.20

Published

use sentinel + ioredis + sharding logic to replace push-redis-failover

Downloads

4

Readme

push-ioredis

The push-ioredis aims to use redis sentinel(Redis officially) and ioredis to replace redis-failover, which would make our redis cluster high-available and easy to operate.

NOTE THAT THE LIBRARY IS NOT INDEPENDENT, which is a component of push-server. The push-ioredis library relys on:

  • redis master-salves
  • sentinels that watch on these master-salves
  • encapsulated sharding object

Example

node test/t
node test/caller

index.js

Entrance of this library.

lib/redis-failover.js

Implements the redisNodeName-ioredisClient-Dictionary, e.g. ["node_x":"related ioredis instance"]. Create the failover redis obj, which receives the sharding objects as params. Acts as an API.

lib/redisClusterMap.js

Get the node name by the hash value. e.g. return node_1 when receives hash value 4~7.

lib/clientProxy

Implements the sharding logic.

  • Generate the hash value of a key
  • Find the real redis node according to the hash value
  • Use the redis node to do specific operations

config/redisConfig.json

The configuration file for the name of redis nodes and sentinel. The ioredis client get a master node from the sentinel by the name of master-slave pair, the sentinel would guarantee the node that ioredis client gets is a master node.

more redis configuration could be described in redis sentinel.conf, e.g. sentinel_8000.conf

config/redisSharing.json

The configuration file for the cluster sharding. "num" is the number of hash buckets, related to redis-crc, currently is 256(64 nodes, every node has 4 buckets, e.g. if a new inserting key's hashing value is 0~3, it would be inserted in node_0);


test/t.js:

Mainly for testing redis-failover, which is acquiring redis client(master) from sentinel configuration.

test/caller.js:

Exemplify how to use push-ioredis, to testify the failover of redis nodes(sentinel+ioredis) and the logic of sharding(mainly inherits form redis-failover).

test/largeRandomSetGetTest.js:

Test the correctness when high QPS at the same time master-redis down. Currently several master-redis need to be killed manually when this runs.

test/testIndex.js:

Test the redisClient.js