File size: 488 Bytes
14a3421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa10b74
14a3421
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
from typing import List, TypedDict
from uuid import uuid4

import redis


class UserInput(TypedDict):
    text: str
    emotions: str
    songs: List[str]


class RedisStorage:
    def __init__(self, host: str, password: str):
        self._client = redis.Redis(host=host, port="35043", password=password, ssl=True)

    def store(self, data: UserInput) -> bool:
        uid = uuid4()
        response = self._client.json().set(f"data:{uid}", "$", data)
        return response