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

@segment/redis-clustr

v1.8.2

Published

Redis cluster client

Downloads

52

Maintainers

harksinghharksinghfhalim-segmentfhalim-segmentcfreecfreeldelossantosldelossantoshjoonpmhjoonpmceline-segmentceline-segmentpmcanseco-segmentpmcanseco-segmentmasiramasiraamillet89amillet89cholt002cholt002av-segmentav-segmentaghotikaraghotikarvikrant-segmentvikrant-segmentlarryatsegmentlarryatsegmentscruwys1scruwys1kyliepedersenkyliepedersenjinaparkjinaparkcdignam-segmentcdignam-segmentsegmentiosegmentiojrupasinghejrupasingheshayan-golafshanishayan-golafshanilateefatlateefatrajulvaderarajulvaderayash-twilioyash-twiliosowjanyasegmentsowjanyasegmentebru.odokebru.odokryanligonryanligonlpediredlalpediredlabrookstaylorjrbrookstaylorjrnithan-twilionithan-twiliodean-huynhdean-huynhwdbettswdbettsn2parkon2parkojayakrishnannairjayakrishnannairrhall-twiliorhall-twiliokarimkeshwanikarimkeshwanityson_segmenttyson_segmentjgabe13jgabe13bgamwellbgamwellpoojasegmentpoojasegmentmaryam.sharifmaryam.sharifwally.tgwally.tgsalolivaressalolivareserikdwerikdwchenxiangzhangchenxiangzhangjusteenjusteenmericssonmericssonprayansh-segmenttprayansh-segmenttjeremylarkinjeremylarkinbsneedbsneeddanieljackinsdanieljackinssegment-sethsegment-sethsayan-das-insayan-das-injames9446james9446priscilla.giattipriscilla.giattinlsunnlsundrew-thompsondrew-thompsonsegment-jsinghsegment-jsinghmcoulibalimcoulibaliandrius-segmentandrius-segmentvalerieernstvalerieernstnithin-bennynithin-bennyainatancincoainatancincoskondamuriskondamuriclintz.segclintz.segreplateroreplateroslenin-twilioslenin-twilioakashyap91akashyap91csayusocsayusoseanhan-segmentseanhan-segmentnevermore2022nevermore2022gilomergilomermarcelopvmarcelopveric.rognereric.rognerkdharaiyakdharaiyajon.anderson-at-segment.comjon.anderson-at-segment.comstacy.songstacy.songrexatsegmentrexatsegmentnickaguilarnickaguilarbradenbeckerbradenbeckerreneewangreneewangdan.laskydan.laskysam.tapiasam.tapialnambalnambavikramkumar19vikramkumar19mpriyad25mpriyad25jeremy.parkerjeremy.parkersmidgessmidgesnageshgolemnageshgolemsudojatinsudojatinpmaidpmaidsethsegmentsethsegmentjair.avilesjair.avilesmanali-bhosalemanali-bhosaleelmoselyeeelmoselyeechtoombschtoombspeterdemartinipeterdemartinivincen7tranvincen7tranmayur-pitalemayur-pitalelfdelossantoslfdelossantosemmy.byrneemmy.byrnefelttripfelttripsa-jsootersa-jsooterlluque-twiliolluque-twiliokevinburkesegmentkevinburkesegmentafsha-nazim-segafsha-nazim-segsong4yousong4youdavid.anusontarangkul.segmentdavid.anusontarangkul.segmentjyim008jyim008michaelghsegmichaelghsegacharles14acharles14aishikawakiaishikawakitwjosiahtwjosiahtanya.gupta.segmenttanya.gupta.segmentsindhusegmentsindhusegmentprabhnoor1997prabhnoor1997chihchun-twiliochihchun-twiliopmiller-twiliopmiller-twiliovbatanovvbatanovsimpixelatedsimpixelatedmcullenmeyermcullenmeyerneeharikakondipatineeharikakondipatieric-hydeeric-hydearunlalam-segmentarunlalam-segmentmschaszbergermschaszbergershuvrajit9904shuvrajit9904abhinavsurekaabhinavsurekavaradarajan-twvaradarajan-twimmanojimmanojblangtwilioblangtwiliojsh-wujsh-wujahood-twiliojahood-twiliosethnutetwiliosethnutetwiliorrivera-segmentrrivera-segmentsegment-adminsegment-adminbgillanbgillantcgilberttcgilbertmckern_segmentmckern_segmentmaneesh.dharma29maneesh.dharma29joetessyjoetessygkochar123gkochar123dominicbarnesdominicbarnesmugelstadmugelstadjalexy12jalexy12lerahulramlerahulrampmuninpmuninwhaider_twiliowhaider_twilioariel.silvestriariel.silvestris3gm3nts3gm3ntama0223ama0223shraddha-twilioshraddha-twiliomichelrmichelrbrandon.scott-segmentbrandon.scott-segmentjfehrman.segmentjfehrman.segmentprayansh-twilioprayansh-twiliodangmai-segmentdangmai-segmentaaronklishaaronklishbrianhumphreystwiliobrianhumphreystwiliormukundanrmukundanashwitha.bgashwitha.bgryanrouleau-segmentryanrouleau-segmentfunlufunlutdibaccotdibaccofauzy.yyfauzy.yynlubchenconlubchencoricardo.rossiricardo.rossisahilsharma0709sahilsharma0709arubiochavezarubiochavezphillip.thomasphillip.thomasjkusa_segmentjkusa_segmentrollcoderollcodemeg1000meg1000nainy.agrawalnainy.agrawalseg-rustybaileyseg-rustybaileyjbandi-twiliojbandi-twiliosaisagarkappaganthulasaisagarkappaganthulaforgetfulfellowforgetfulfellowdbaik-twilio-segmentdbaik-twilio-segmentpooja.patilpooja.patiljoe.ayoub.segmentjoe.ayoub.segmenthmohanram_seghmohanram_segbrian.aguirrebrian.aguirreenyi.asonyeenyi.asonyefarhan0581farhan0581tbrennanjtbrennanjparag.pandaparag.pandacherylj-segmentcherylj-segmentharsh.vardhanharsh.vardhansshaikh_segmentsshaikh_segmentxinghao.huangxinghao.huangshupadhyayshupadhyayjohn.lee1100john.lee1100kx-segmentkx-segmentsegment_fansegment_fandazu70dazu70sbhodiwalsbhodiwalsai-patanjalisai-patanjaliemilyjiaemilyjiay.yuy.yuea_segmentea_segmentyli119yli119pooyajpooyajsungju.jinsungju.jinconniechenconniechenbharath.boregowdabharath.boregowdaigracheva-twilioigracheva-twiliobenattwiliobenattwiliomarinheromarinheroankit.gupta.unthinkableankit.gupta.unthinkabledobrin.ganevdobrin.ganevalfrimpongalfrimpongbrandonheyer-segmentbrandonheyer-segmentalecjacobs-segmentalecjacobs-segmentcjo2cjo2yashnit-segmentyashnit-segmentdltnbrks-segmentdltnbrks-segmentachandrashekaranachandrashekaranhimanshuphhimanshuphpraguptapraguptatw-dgarciatw-dgarciaalayvoraalayvoraaparna.singhalaparna.singhalynguyenynguyentimmyzsearcytimmyzsearcylweimersegmentlweimersegmentanton-vylushchakanton-vylushchakazhaotwilioazhaotwiliorokatyalrokatyalkjoerreskjoerresmsarafmsarafvikakumarvikakumaraditi.raveeshaditi.raveeshchenchensegmentcomchenchensegmentcomsanket.mishrasanket.mishraodoren_segmentodoren_segmentjxin_twiliojxin_twiliorcheedhallarcheedhallajbasiglio-segmentjbasiglio-segmentviveksainaneesegmentviveksainaneesegmentpriyanshispriyanshispreetyppreetypakash.gautam07akash.gautam07nanotimmnanotimmyshkpryshkprsrivig21srivig21ssunejassunejabala.singareddybala.singareddymoyara2moyara2arjunbhandagearjunbhandageakodankiryakodankiryrodhilton_twiliorodhilton_twiliocdelaomartinezcdelaomartinezgbatragbatraspencerattickspenceratticksegmentseansegmentseansundareswar.jayakumarsundareswar.jayakumarvaibhavnandavaibhavnandabannapplebannapplesrishti-nemasrishti-nemaar7devar7devgsolis_segmentgsolis_segmentitsarijitrayitsarijitraybhavanki-segmentbhavanki-segmentnitinpm432nitinpm432nikumarsegmentnikumarsegmentnanette.ranesnanette.ranesamigandhiamigandhiguthriesegmentguthriesegmentmiguelpdiaz8miguelpdiaz8mansarimansarisandhya16sandhya16hema-bahirwani-segmenthema-bahirwani-segmentbnakkinabnakkinapraveenugiripraveenugiriighorelaighorelanemery-segmentnemery-segmentwlumsegmentwlumsegmentnat-gridnat-gridneedcaffeineneedcaffeinekbhargavaram-sgkbhargavaram-sgirfan.ali.segmentirfan.ali.segmentharsh-joshi99harsh-joshi99ed-twilion-npmed-twilion-npmaubreysineaubreysinelight-bringer-blrlight-bringer-blrsethgrid_segmentsethgrid_segmentjibrangjibrangseg-leonelsanchesseg-leonelsanchessmccoy-twiliosmccoy-twiliodevthaledevthaleandwivediandwivedipoojapatilsegpoojapatilseggaprabhugaprabhuapackerapackermonusegmentmonusegment

Readme

redis-clustr

This fork of redis-clustr updates the cluster-key-slot, denque and redis dependencies and includes a few bug fixes.

npm i @segment/redis-clustr

Running tests:

$ ./test/setup-redis
$ ./test/start-redis
$ npm install
$ npm run test
$ npm run benchmark
$ ./test/stop-redis

This module is a relatively thin wrapper around the node redis client to enable use of Redis Cluster. It tries to be as unobtrusive as possible - mimicing the behaviour of the node_redis client.

Usage

var RedisClustr = require('@segment/redis-clustr');

var redis = new RedisClustr({
  servers: [
    {
      host: '127.0.0.1',
      port: 7000
    }
  ]
});

redis.set('key', 'value');

Servers

Servers in the cluster will be automatically connected to (via the response of cluster slots). Of course, to allow discovery there must be at least one server specified in the configuration.

Client creation

By default, clients will be created using Redis.createClient(port, host). This can be overridden by providing a function which must return a node_redis client. Clients are cached so only one connection will be made to each server.

var RedisClustr = require('@segment/redis-clustr');
var RedisClient = require('redis');
var redis = new RedisClustr({
  servers: [...],
  createClient: function(port, host) {
    // this is the default behaviour
    return RedisClient.createClient(port, host);
  }
});

Options

var RedisClustr = require('@segment/redis-clustr');
var redis = new RedisClustr({
  servers: [...],
  slotInterval: 1000, // default: none. Interval to repeatedly re-fetch cluster slot configuration
  maxQueueLength: 100, // default: no limit. Maximum length of the getSlots queue (basically number of commands that can be queued whilst connecting to the cluster)
  queueShift: false, // default: true. Whether to shift the getSlots callback queue when it's at max length (error oldest callback), or to error on the new callback
  wait: 5000, // default: no timeout. Max time to wait to connect to cluster before sending an error to all getSlots callbacks
  slaves: 'share', // default: 'never'. How to direct readOnly commands: 'never' to use masters only, 'share' to distribute between masters and slaves or 'always' to  only use slaves (if available)
  createClient: function(port, host, options) {
    return require('redis').createClient(port, host, options);
  }, // default: redis.createClient. Function used to connect to redis, called with arguments above
  redisOptions: {
    // options passed to the node_redis client https://github.com/NodeRedis/node_redis#options-is-an-object-with-the-following-possible-properties
    retry_max_delay: 500
    // etc
  }
});

Supported functionality

Slot reallocation

Supported - when a response is given with a MOVED error, we will immediately re-issue the command on the other server and run another cluster slots to get the new slot allocations. ASK redirection is also supported - we wil re-issue the command without updating the slots. TRYAGAIN responses will be retried automatically.

Multi / Exec (Batch)

Multi commands are supported but treated as a batch of commands (not an actual multi) and the response is recreated in the original order. Commands are grouped by node and sent as node_redis batches

Multi-key commands (del, mget and mset)

Multi-key commands are also supported and will be split into individual commands (using a batch) then have the response recreated. Only del, mget and mset are supported at the moment.

Pub/Sub

Pub/Sub is fully supported. When subscribe is used, a new client will be created (connected to a random node). This client is shared for all subscriptions.

var RedisClustr = require('@segment/redis-clustr');
var redis = new RedisClustr({...});

redis.on('message', function(channel, message) { /* ... */ });

redis.subscribe('my-channel', function(err) {
  redis.publish('my-channel', 'have a lovely day!');
});

Errors

Just like node_redis, listen to the error event to stop your application from crashing due to errors. Redis Clustr automatically intercepts connection errors and will try to reconnect to the server.