Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hashring

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashring

A consistent hashring compatible with ketama hashing and python's hash_ring

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
136K
increased by2.71%
Maintainers
1
Weekly downloads
 
Created

What is hashring?

The hashring npm package is a consistent hashing library that allows for the distribution of keys across a set of nodes. It is useful for load balancing, distributed caching, and sharding data across multiple servers.

What are hashring's main functionalities?

Creating a Hash Ring

This feature allows you to create a hash ring with a set of nodes. The nodes can be any identifier, such as server names or IP addresses.

const HashRing = require('hashring');
const ring = new HashRing(['node1', 'node2', 'node3']);

Adding and Removing Nodes

This feature allows you to dynamically add or remove nodes from the hash ring. This is useful for scaling up or down the number of nodes in your system.

ring.add('node4');
ring.remove('node2');

Getting the Node for a Key

This feature allows you to get the node responsible for a given key. This is useful for determining which node should handle a particular piece of data.

const node = ring.get('myKey');

Weighting Nodes

This feature allows you to assign weights to nodes, so some nodes can handle more keys than others. This is useful for load balancing when some nodes have more capacity than others.

const weightedRing = new HashRing({'node1': 1, 'node2': 2, 'node3': 1});

Other packages similar to hashring

Keywords

FAQs

Package last updated on 14 Mar 2013

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc