@Override
    public OneTimeToken store(final OneTimeToken token) {
        token.assignIdIfNecessary();
        if (exists(token.getUserId(), token.getToken())) {
            val tokens = storage.getIfPresent(token.getUserId());
            Objects.requireNonNull(tokens).add(token);
            LOGGER.debug("Storing previously used tokens [{}] for user [{}]", tokens, token.getUserId());
            storage.put(token.getUserId(), tokens);
        } else {
            val tokens = new ArrayList<OneTimeToken>(1);
            tokens.add(token);
            LOGGER.debug("Storing new token [{}] for user [{}]", token, token.getUserId());
            storage.put(token.getUserId(), tokens);
        }
        return token;
    }
This is {@link CachingOneTimeTokenRepository}.

@author Misagh Moayyed
@since 5.1.0
support/cas-server-support-otp-mfa-core/src/main/java/org/apereo/cas/otp/repository/token/CachingOneTimeTokenRepository.java