UNPKG

ram64

Version:

Multi-threaded 64bit memory cache database inspired by redis-like features

13 lines (10 loc) 385 B
import { getHash } from '../util/hash'; import { Shards } from './shards'; export function getShardFromKey(key: string) { // shard requires a unique hash compared to worker hash for even distribution return getShardFromHash(getHash(key+'s')); } function getShardFromHash(keyHash: number) { const shardI = keyHash % Shards.length; return Shards[shardI]; }