You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/12/15 08:40:06 UTC

[GitHub] [airflow] mgorsk1 commented on a change in pull request #6820: [AIRFLOW-6255] Redis Hook Refactor

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

 ##########
 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)
 
 Review comment:
   returns int - number of subscribes that received the message. so will return that ;)

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services