
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
light-cycle
Advanced tools
A consistent hashringcycle for sharding your dataz, with 100% more blue glow and 50% less Wagner.
To install:
npm install light-cycle
Sample usage:
var Lightcycle = require('light-cycle');
var cycle = new Lightcycle(
{
seed: 0xdeadbeef,
size: 50
});
// Create entries in the hash ring for each of our redis caches, using redis:host:port as
// their unique ids in the ring.
for (var i = 0; i < myRedisInstances.length; i++)
{
var redisShard = myRedisInstances[i];
cycle.add(redisShard, ['redis', redisShard.host, redisShard.port].join(':'));
}
// Now we have something to cache in one of our shards.
var dataToStore =
{
id: '3421',
data: 'This is very important data that must be cached in our redises.',
timestamp: Date.now()
};
// Where shall we store this?
var whichRedis = cycle.locate(dataToStore.id);
whichRedis.hmset(dataToStore.id, dataToStore, callback);
Resources are any object or identifier you wish to store. You can store an open database connection, a resource identifier, or something else. This module does not attempt to inspect or use the resource. It just implements a sharding scheme based on the resource's id.
Construct a cycle.
Settings may include the following fields:
seed
: seed for the hash function; must be a positive integer; defaults to 0xcafed00d
size
: expected number of resources you'll be storing; defaults to 128
replicas
: number of replicas to store in the cycle for each resource; defaults to size
If you want your light-cycle to behave identically to other invocations, pass the same hash seed.
Add a resource to the cycle. This will create replicas entries in the underlying data structure. The id
parameter must be a string.
Remove the resource with the given id from the cycle. This removes all replica entries.
Given the id of some data you wish to locate, return the resource where it should reside. id
may be a string or a buffer.
Resize the cycle to accomodate the current number of entries plus some padding.
This is called automatically if the number of entries added exceeds the size option passed in at configuration. Rebalance is not automatically called when resources are removed.
Hash keys are cached, so rebalancing shouldn't be too slow, but to avoid thrash rebalancing pads out the size and the replica count by Lightcycle.SIZE_PAD
and Lightcycle.REPLICAS_PAD
respectively. For best results, choose a size setting at start that can accomodate the number of resources you intend to use.
Wikipedia is informative.
This page is another good introduction to consistent hash rings.
And there's always the original paper.
FAQs
a consistent hash ring for your blue-glowing shards of PURE ENERGY
The npm package light-cycle receives a total of 42 weekly downloads. As such, light-cycle popularity was classified as not popular.
We found that light-cycle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.