title: Spark: How to send arguments to Spark foreach function
body: <p>I am trying to save the contents of a Spark RDD to Redis with the following code</p>
  
  <pre><code>import redis
  class RedisStorageAdapter(BaseStorageAdapter):
      @staticmethod
      def save(record):
  
          ###--- How do I get action_name ---- ###
          redis_key = #&lt;self.source_action_name&gt;
          redis_host=settings['REDIS']['HOST']
          redis_port=settings['REDIS']['PORT']
          redis_db=settings['REDIS']['DB']
  
          redis_client = redis.StrictRedis(redis_host, redis_port, redis_db)
          redis_client.sadd(redis_key, record)
  
      def store_output(self, results_rdd):
  
          print self.source_action_name
          results_rdd.foreach(RedisStorageAdapter.save)
  </code></pre>
  
  <p>But I want the Redis Key to be different based on what self.source_action_name is initialized to (in BaseStorageAdapter)</p>
  
  <p>How do I pass the source_action_name to RedisStorageAdapter.save function? foreach function only allows the name of the function to be executed and no parameter list</p>
  
  <p>Also - if there is a better way to move data from RDD to Redis, let me know</p>