I encouter a strange problem with one method.. no idea why this one, because it is the same as the other one..
I'm using Redis for the cache, but redis doesn't return me the cached response after the first call..
Springboot parent version : 2.6.3
@GetMapping(value = "/groups", produces = APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Cacheable(value = "groups") public GroupsDTO getAllGroups() { return iGroupsAndUsersService.getAllGroups(); } @GetMapping(value = "/users", produces = APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @Cacheable(value = "users") public UsersDTO getAllUsers() { System.out.println("here"); // is displayed the first call return iGroupsAndUsersService.getAllUsers(); }
For my first call to /users i get my list of users within 1.5 seconds so OK.The second call and other one i get null like this (http 200) :
{"items": null}
I can see that my method as been called only one time, but unlike other methods, the cache is not returning me the cached response..
The endpoint /groups is working without any problem.. these methods do the same job...
public interface IGroupsAndUsersService { GroupsDTO getAllGroups(); UsersDTO getAllUsers();}
Users
@Datapublic class Users { List<Item> items; @Data public static class Item { public Metadata metadata; public String fullName; } @Data public static class Metadata { public String name; }}
public class UsersDTO extends Users implements Serializable{}