[Python] How set bult-in dict in Redis

Discussão em 'Python' iniciado por Stack, Março 27, 2025.

  1. Stack

    Stack Membro Participativo

    I want to make a siilar structure:

    structure = {value: {key: item}, value : {key: item}}


    And i want to add this to redis a simlar way:

    mapping = {}
    for i, (key, item) in enumerate(sorted(total_activs.items()), start=1):
    mapping = {key: item}

    r.hset(f"{group}", json.dumps(mapping))


    but it's does't work. But why?

    Future im the code I want to get 3 elements and work with dicts

    top = r.hmget(f"{group}", ['1', '2', '3'])
    print(top) # return [{key_1: my_first_item}, {key_2: my_second_item}]

    top[0][key_1] # my_first_item

    Continue reading...

Compartilhe esta Página