@earth-app/collegedb
    Preparing search index...

    Function hrwShard

    • Selects a shard for key using rendezvous hashing.

      Each candidate is scored with a hash of the shard name combined with the key, and the highest score wins, with the shard name breaking exact ties. Adding or removing a shard only moves the keys whose winner changed, and the result is independent of the order shards is given in.

      Parameters

      • key: string

        Primary key to place

      • shards: string[]

        Candidate shard bindings (at least one)

      Returns string

      The winning shard binding

      If shards is empty

      1.4.0

      hrwShard('user-123', ['db-east', 'db-west']); // => 'db-east'