nuclearpinguin commented on a change in pull request #6820: [AIRFLOW-6255] 
Redis Hook Refactor
URL: https://github.com/apache/airflow/pull/6820#discussion_r357936721
 
 

 ##########
 File path: airflow/contrib/hooks/redis_hook.py
 ##########
 @@ -66,3 +66,47 @@ def get_conn(self):
                 db=self.db)
 
         return self.redis
+
+    def set_key_value(self, k, v):
+        """
+        Create redis key ${k} with value ${v}
+        """
+        client = self.get_conn()
+
+        return client.set(k, v)
+
+    def get_key(self, k):
+        """ Get value of key ${key} stored in Redis """
+        client = self.get_conn()
+
+        return client.get(k)
+
+    def delete_key(self, k):
+        """ Delete key ${k} from redis """
+        client = self.get_conn()
+
+        return client.delete(k)
+
+    def publish_message(self, channel, message):
+        """ Publish message ${message} to channel ${channel}"""
+        client = self.get_conn()
+
+        client.publish(channel=channel, message=message)
+
+    def check_if_key_exists(self, key):
+        """ Verify if key ${k} exists in Redis """
+        client = self.get_conn()
+
+        return client.exists(key)
+
+    def create_pubsub(self):
+        """ Create pubsub object which can subscribe to Redis channel """
+        client = self.get_conn()
+
+        return client.pubsub()
 
 Review comment:
   Here, adding type annotation will be really helpful because user could 
easily go to Pubsub object.

----------------------------------------------------------------
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

Reply via email to