'I am trying to build a real time leaderboard app with node js and redis

When I am trying to run this command in nodejs using node-redis

client.ZRANGEBYSCORE(`rank`, score, score, "REV", "LIMIT", 0,1)

it is returning an array with all the values instead of one.

And when I'm running

client.ZRANGEBYSCORE([`rank`, score, score, "REV", "LIMIT", 0,1])

it is returning an empty array. Any one have a solution that returns only one item from the reversed rank sorted-set



Solution 1:[1]

Try this:

def check_interfaces(some_num):
    FOOBAR.CheckInterfaces.restype = ct.c_bool
    FOOBAR.CheckInterfaces.argtypes = [
        ct.c_ushort,
        ct.POINTER(ct.c_ushort),
        ct.POINTER(ct.POINTER(CardInfo)),
    ]

    num_cards = ct.c_ushort(0)
    card_info_array = (CardInfo * 16)()
    status = FOOBAR.CheckInterfaces(some_num, ct.byref(num_cards), ct.byref(card_info_array))
    return [card_info_array[i] for i in range(num_cards)]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1