File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -50,3 +50,27 @@ def set_value(key: str, value: str):
5050 connection = get_connection ()
5151 value = value .encode ('utf-8' )
5252 connection .set (key , value )
53+
54+
55+ def set_object (key : str , field : str , value : str ):
56+ """
57+ `key` is the file identifer. In our case a hash created using the file path.
58+ `field` is the field name. The possible values are `type`,`raw_image_content` and `processed_image_content`.
59+ `value` is the extracted text content after performing the Optical Character Recognition.
60+ HMSET <file_hash> raw_image_content <raw_image_content> processed_image_content <processed_image_content>
61+ """
62+ connection = get_connection ()
63+ value = value .encode ('utf-8' )
64+ connection .hset (key , field , value )
65+
66+
67+ def get_object (key : str , field : str ):
68+ connection = get_connection ()
69+ value = connection .hget (key , field )
70+ if value is None :
71+ return value
72+ # Redis stores bytes.
73+ # Application encodes the strings to utf-8 before putting in Redis.
74+ # Hence decode to utf-8 on read.
75+ value = value .decode ('utf-8' )
76+ return value
You can’t perform that action at this time.
0 commit comments