RedisClient.zinterstore method | Bun module | Bun
BuildDocsReferenceGuidesBlogDiscord/
Bun/
RedisClient/
zinterstoreMzinterstore
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
Bun/
RedisClient/
zinterstoreMzinterstore
method
RedisClient.zinterstorezinterstore(destination:
KeyLike,numkeys: number,...args: string | number[]): Promisenumber>;
Compute the intersection of multiple sorted sets and store in destination
This command is similar to ZINTER, but instead of returning the result, it stores it in the destination key. If the destination key already exists, it is overwritten.
Options:
WEIGHTS: Multiply the score of each member in the corresponding sorted set by the given weight before aggregationAGGREGATE SUM|MIN|MAX: Specify how the scores are aggregated (default: SUM)@param destination
The destination key to store the result
@param numkeys
The number of input keys (sorted sets)
@returns
Promise that resolves with the number of elements in the resulting sorted set
// Set up sorted sets
await redis.zadd("zset1", "1", "a", "2", "b", "3", "c");
await redis.zadd("zset2", "1", "b", "2", "c", "3", "d");
// Basic intersection store
const count1 = await redis.zinterstore("out", 2, "zset1", "zset2");
// Returns: 2 (stored "b" and "c" in "out")
// With weights
const count2 = await redis.zinterstore("out2", 2, "zset1", "zset2", "WEIGHTS", "2", "3");
// Returns: 2
// With MAX aggregation
const count3 = await redis.zinterstore("out3", 2, "zset1", "zset2", "AGGREGATE", "MAX");
// Returns: 2 (stores maximum scores)
Referenced typestype
KeyLike = string |
ArrayBufferView |
BlobResources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →