title: Read Data From Redis Using Flink
body: <p>I am completely new to Flink. May this question is repeated but found only one link and that is not understandable for me. </p>
  
  <p><a href="https://stackoverflow.com/a/44294980/6904987">https://stackoverflow.com/a/44294980/6904987</a></p>
  
  <p>I stored Data in Redis in Key Value format example Key is UserId and UserInfo is value. Written below code for it.</p>
  
  <pre><code>class RedisExampleMapper extends RedisMapper[(String, String)] {
    override def getCommandDescription: RedisCommandDescription = {
      new RedisCommandDescription(RedisCommand.HSET, "HASH_NAME")
    }
  
    override def getKeyFromData(data: (String, String)): String = data._1
  
    override def getValueFromData(data: (String, String)): String = data._2
  }
  
  
  val env = StreamExecutionEnvironment.getExecutionEnvironment
      val conf = new FlinkJedisPoolConfig.Builder().setHost("IP").build()
      val streamSink = env.readTextFile("/path/useInformation.txt").map(x =&gt; {
            val userInformation = x.split(",")
            val UserId = userInformation(0)
            val UserInfo  = userInformation(1)
            (UserId , UserInfo)
          })
  val redisSink = new RedisSink[(String, String)](conf, new RedisExampleMapper)
  streamSink.addSink(redisSink)
  </code></pre>
  
  <blockquote>
    <p>Sample Data: </p>
    
    <p>12 "UserInfo12" </p>
    
    <p>13 "UserInfo13" </p>
    
    <p>14 "UserInfo14" </p>
    
    <p>15 "UserInfo15"</p>
  </blockquote>
  
  <p>I want to feteched data from redis using Flink based on key . example 14 should return "UserInfo14". Output should print in Flink Log file or terminal whatever it is. </p>
  
  <p>Thanks in advance.</p>