nuclearpinguin commented on a change in pull request #6820: [AIRFLOW-6255]
Redis Hook Refactor
URL: https://github.com/apache/airflow/pull/6820#discussion_r360645106
##########
File path: airflow/contrib/hooks/redis_hook.py
##########
@@ -66,3 +69,47 @@ def get_conn(self):
db=self.db)
return self.redis
+
+ def set_key_value(self, key: str, value: Any) -> Optional[bool]:
+ """
+ Create redis key ${k} with value ${v}
+ """
+ client = self.get_conn()
+
+ return client.set(key, value)
+
+ def get_key(self, key: str) -> Optional[Any]:
+ """ Get value of key ${key} stored in Redis """
+ client = self.get_conn()
+
+ return client.get(key)
+
+ def delete_key(self, key: str) -> int:
+ """ Delete key ${k} from redis """
+ client = self.get_conn()
+
+ return client.delete(key)
+
+ def publish_message(self, channel: str, message: str) -> int:
+ """ Publish message ${message} to channel ${channel}"""
Review comment:
I am not sure if we need `${message}` here, it duplicates information imho.
Plus it would be amazing to have full docstring:
```
Publishes message to a channel.
:param message: The message to publish
:type message: str
:param channel: The channel to which message has to be published
:type channel: str
```
I know it is a tedious work but it makes our documentation and project a
better place <3
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services