Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2203

How can I store an Object as a value in Redis using Spring-Data-Redis?

$
0
0

I want to store an Object in Redis using Spring-Data-Redis, but it just doesn't save. If I change payload to a String, it DOES save. I originally had this as a JsonNode, but this caused a problem with Jackson, so I am using Object to fix that. The payload is received as Json from a third party. This is my Entity to be saved:

@Data@AllArgsConstructor@NoArgsConstructor@RedisHash("FruitPayload")public class FruitPayload implements Serializable {    @Id    private String id;    private Object payload;}

This is the code that calls it:

final Object responseBody = responseEntity.getBody();FruitPayload fruitPayload = new FruitPayload(key, responseBody);if(Objects.nonNull(responseBody)) {      FruitPayload savedPayload = fruitPayloadRepository.save(fruitPayload);                    }

If I run in debug in Intellij, the savedPayload has the data. However, if I check Redis, the key is there, but the payload is null. How can I store this payload in Redis?


Viewing all articles
Browse latest Browse all 2203

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>