Francesco commited on
Commit
2b1aac4
1 Parent(s): c18c7db

redis storage

Browse files
Files changed (1) hide show
  1. storage.py +21 -0
storage.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from typing import List, TypedDict
3
+ from uuid import uuid4
4
+
5
+ import redis
6
+
7
+
8
+ class UserInput(TypedDict):
9
+ text: str
10
+ emotions: str
11
+ songs: List[str]
12
+
13
+
14
+ class RedisStorage:
15
+ def __init__(self, host: str, password: str):
16
+ self._client = redis.Redis(host=host, port="34307", password=password, ssl=True)
17
+
18
+ def store(self, data: UserInput) -> bool:
19
+ uid = uuid4()
20
+ response = self._client.json().set(f"data:{uid}", "$", data)
21
+ return response