How to get sorted set in descending order with node redis
everything is zRange now

If you've got any questions feel free to DM on Twitter @reillyjodonnell
Search for a command to run...
everything is zRange now

If you've got any questions feel free to DM on Twitter @reillyjodonnell
No comments yet. Be the first to comment.
Someone shared this image above. At first glance, I wasn’t sure about the perf implications — so let’s break it down from first principles :D Let’s deconstruct this monster Here’s the code: // Function to flatten React Context Providers. const flatte...

Intro Hello it’s me from the future! I originally was going to go over file based routing but pivoted to going over important SSR concepts with React / how Bun makes it easy. It’s full of struggles with hydration (mismatches), React entry points, and...

history? Serverless is EVERYWHERE and for good reason: nearly infinite scalability, physically closer to users, and pay-for-what-you-use pricing. But not without tradeoffs — vendor lock-in, (potentially) higher costs, and the infamous cold-starts. cf...

Powered by bash and AppleScript!

Sockets can only transmit binary (text.) Imagine we have this data const message = {id: '123', name: 'Reilly', message: 'Hey'} Here's the problem: we want to send this data to the ui but we have hundreds of useEffects spread throughout the codebase....

You've got a structure like this:
redisClient.zAdd('leaderboard', {score: 0, value: "charlie"}
redisClient.zAdd('leaderboard', {score: 1, value: "beth"}
redisClient.zAdd('leaderboard', {score: 2, value: "adam"}
Sadly the below only retrieves the values in ASCENDING order
redisClient.zRange('leaderboard', 0, 2);
This will give us:
1) "charlie"
2) "beth"
3) "adam"
We have to pass the REV flag in the options
redisClient.zRange('leaderboard', 0, 2, {
REV: true,
});
}
If you ctrl+space in the object you get so many options it's hard to find it.
It took me a solid 10 min to find this. Hope this helps someone!
How to sort in desc order for top 10 results:
zRange('leaderboard', 0, 9, {
REV: true,
});
}
how to do it with scores:
redisClient.zRangeWithScores('leaderboard', 0, 9, {
REV: true,
});
How to do it in CLI:
ZRANGEBYSCORE leaderboard 0 9 rev