Redis cannot customize key

I want to cache some data according to the user"s user name. The code is as follows

@CachePut(key = "-sharpuser.userName", value = "loginList")
public String generateToken(User user) {

    HashMap<String, Object> map = new HashMap<>();
    map.put("userName", user.getUserName());
    map.put("roles", user.getUroles());
    String jwt = Jwts.builder()
            .setClaims(map)
            .setExpiration(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
            .signWith(SignatureAlgorithm.HS256, SECRET)
            .compact();
    
    return TOKEN_PREFIX + jwt;
}

for example, for a user whose user name is testid2, his key in cache should be testid2, but actually loginList::testid2,. That is to say, redis also adds the cached name in front of it, so I don"t quite understand it. Then the meaning of the @ Cachable key attribute is almost meaningless, because it still can not be completely customized key,. Is there any way to remove the prefix of this key?

clipboard.png

Apr.07,2021
Menu