title: getting the entire data in redis from redisTemplate
body: <p>I am relatively new to redis .
  I am designing an rest API, to get the entire data set in the redis db.</p>
  
  <p>I used the below code to get all the keys</p>
  
  <p>public Map getAllRedisData() {</p>
  
  <pre><code>    Map&lt;Object, Object&gt; map  = new HashMap&lt;&gt;();
      Set&lt;byte[]&gt; keys = redisService.getTemplate().getConnectionFactory().getConnection().keys("*".getBytes());
      Iterator&lt;byte[]&gt; it = keys.iterator();
  
      while(it.hasNext()){
          byte[] data = (byte[])it.next();
         // String key = new String(data,0,data.length);
          Object key = null;
          try {
              key = getObjectFromByteArray(data);
              System.out.println(key);
          } catch (ClassNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }    
      return map;
  }
  
  private Object getObjectFromByteArray(byte[] bytes) throws IOException, ClassNotFoundException
  {
      try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
           ObjectInput in = new ObjectInputStream(bis)) {
          return in.readObject();
      } 
  }
  </code></pre>
  
  <p>I was able to get all the keys, but wasnt able to retrieve the value for all the keys. Below is the approach 
              "Object value = redisService.getTemplate().opsForValue().get("");" </p>
  
  <p>I guess this is because some keys are of different datatypes.</p>
  
  <p>Let me know if I have to modify/change my approach.</p>