redistemplate.opsforvalue()中都有哪些方法
时间: 2024-04-26 21:22:43 浏览: 109
`redistemplate.opsforvalue()` 返回一个 `ValueOperations` 接口,该接口提供了以下方法:
- `set(K key, V value)`:将键值对存储到 Redis 中。
- `setIfAbsent(K key, V value)`:仅当键不存在时,将键值对存储到 Redis 中。
- `multiSet(Map<? extends K, ? extends V> map)`:将多个键值对存储到 Redis 中。
- `multiSetIfAbsent(Map<? extends K, ? extends V> map)`:仅当所有给定的键都不存在时,将多个键值对存储到 Redis 中。
- `get(Object key)`:根据键获取对应的值。
- `getAndSet(K key, V value)`:获取指定键对应的旧值,并将新值存储到 Redis 中。
- `increment(K key, long delta)`:将指定键的值增加指定的增量。
- `decrement(K key, long delta)`:将指定键的值减少指定的增量。
- `append(K key, String value)`:将指定的字符串追加到指定键的值的末尾。
- `size(K key)`:获取指定键的值的长度。
- `set(K key, V value, long timeout, TimeUnit unit)`:将键值对存储到 Redis 中,并设置过期时间。
- `getOperations()`:获取底层的 Redis 操作对象。
阅读全文
相关推荐












