I user a CRUDRepository in my spring data redis project to persist a redis hash in my redis cluster. i have rest api written to persist and get thte values of the data. this works fine.
however my entity annotated with RedisHash is being saved as a set / and i am not able to look inside the value using redis cli.
how do i look inside a set data type(without popping) in redis cli
i looked at redis commands page https://redis.io/commands#set i only get operations which can pop value . i neeed to simply peek
EDIT: to make things clearer, i am using spring crudrepo to save the user entity into redis data store. the user entity gets saved as a set data type.
when i query back the user details, i can see entire details of the user
{ userName: "somak", userSurName: "dattta", age: 23, zipCode: "ah56h" }
i essentially want to do the same using redis cli... but all i get is 127.0.0.1:6379> smembers user 1) "somak" how do i look inside the somak object.
@RestController
@RequestMapping("/immem/core/user")
public class UserController {
@Autowired
private UserRepository userRepository;
@RequestMapping(path = "/save", method = RequestMethod.GET, produces = "application/json")
@ResponseStatus(HttpStatus.OK)
public void saveUserDetails() {
User user = new User();
user.setAge(23);
user.setUserName("somak");
user.setUserSurName("dattta");
user.setZipCode("ah56h");
userRepository.save(user);
}
@RequestMapping(path="/get/{username}", method = RequestMethod.GET, produces = "application/json")
public User getUserDetails(@PathVariable("username") String userName) {
return userRepository.findById(userName).get();
}
}
@Repository
public interface UserRepository extends CrudRepository<User, String>{
}
@RedisHash("user")
public class User {
private @Id String userName;
private @Indexed String userSurName;
private @Indexed int age;
private String zipCode;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserSurName() {
return userSurName;
}
public void setUserSurName(String userSurName) {
this.userSurName = userSurName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
}