ValueOperations接口的void set(K key, V value, long timeout, TimeUnit unit)方法
set
void set(K key, V value, long timeout, TimeUnit unit)
设置键的值和过期超时时间。
Set the value and expiration timeout for key.
Parameters:
- key - must not be null.
- value - must not be null.
- timeout - the key expiration timeout.
- unit - must not be null.
See Also: Redis Documentation: SETEX https://redis.io/docs/latest/commands/setex/
示例
stringRedisTemplate.opsForValue().set(LOGIN_CODE_KEY + phone, code, LOGIN_CODE_TTL, TimeUnit.MINUTES);

浙公网安备 33010602011771号