springboot_redistemplate
RedisTemplate
RedisTemplate/StringRedisTemplate
Spring Boot의 RedisTemplate/StringRedisTemplate의 메소드와 레디스 서버의 명령관계를 설명합니다.
메소드명과 레디스 명령 이름이 달라 헷갈리는 경우가 있어서 정리했습니다.
public class RedisTemplate <K, V> extends RedisAccessor implements RedisOperations<K, V>, ...
public class StringRedisTemplate extends RedisTemplate<String, String>
package org.springframework.data.redis.core
일반 키 메소드 Common Key Methods
No Methods Redis Commands
1 Boolean copy(K source, K target, boolean replace) copy()
2 Boolean hasKey(K key) exists()
3 Long countExistingKeys(Collection<K> keys) exists()
4 Boolean delete(K key) del()
5 Long delete(Collection<K> keys) del()
6 Boolean unlink(K key) unlink()
7 Long unlink(Collection<K> keys) unlink()
8 DataType type(K key) type()
9 Set<K> keys(K pattern) keys()
10 Cursor<K> scan(ScanOptions options) scan()
11 K randomKey() randomKey
12 void rename(K oldKey, K newKey) rename()
13 Boolean renameIfAbsent(K oldKey, K newKey) renameNX()
14 Boolean expire(K key, final long timeout, final TimeUnit unit) pExpire(),
expire()
15 Boolean expireAt(K key, final Date date) pExpireAt(),
expireAt()
16 Boolean persist(K key) persist()
17 Long getExpire(K key) ttl()
18 Long getExpire(K key, TimeUnit timeUnit) pTtl(),
ttl()
19 Boolean move(K key, final int dbIndex) move()
20 byte[] dump(K key) dump()
21 void restore(K key, byte[] value, long timeToLive, TimeUnit unit, boolean replace) restore()
소트 메소드 Sort Methods
No Methods Redis Commands
1 List<V> sort(SortQuery<K> query) sort()
2 <T> List<T> sort(SortQuery<K> query, @Nullable RedisSerializer<T> resultSerializer) sort()
3 <T> List<T> sort(SortQuery<K> query, BulkMapper<T, V> bulkMapper) sort()
4 <T, S> List<T> sort(SortQuery<K> query, BulkMapper<T, S> bulkMapper, @Nullable RedisSerializer<S> resultSerializer) sort()
5 Long sort(SortQuery<K> query, K storeKey) sort()
트랜잭션 메소드 Transactions Methods
No Methods Redis Commands
1 void watch(K key) watch()
2 void watch(Collection<K> keys) watch()
3 void unwatch() unwatch()
4 void multi() multi()
5 void discard() discard()
6 List<Object> exec() exec()
클라이언트 메소드 Client Methods
No Methods Redis Commands
1 List<RedisClientInfo> getClientList() client list
2 void killClient(String host, int port) client kill
복제 관련 메소드 Replicaof Methods
퍼블리쉬 메소드 Publish Methods
No Methods Redis Commands
1 Long convertAndSend(String channel, Object message) publish
스트링 메소드 String Methods - ValueOperations
public interface ValueOperations<K, V>
class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements
ValueOperations<K, V>
입력 메소드 Set Methods
No Methods Redis Commands
1 void set(K key, V value) set()
2 void set(K key, V value, long timeout, TimeUnit unit) setEx(),
pSetEx()
3 Boolean setIfAbsent(K key, V value) setNX()
4 Boolean setIfAbsent(K key, V value, long timeout, TimeUnit unit) set()
5 Boolean setIfPresent(K key, V value) set()
6 Boolean setIfPresent(K key, V value, long timeout, TimeUnit unit) set()
조회 메소드 Get Methods
No Methods Redis Commands
1 V get(Object key) get()
2 V getAndDelete(K key) getDel()
3 V getAndExpire(K key, long timeout, TimeUnit unit) getEx()
4 V getAndExpire(K key, Duration timeout) getEx()
5 V getAndPersist(K key) getEx(PERSIST)
6 V getAndSet(K key, V newValue) getSet()
멀티 Set,Get 메소드 Multi Set,Get Methods
No Methods Redis Commands
1 void multiSet(Map<? extends K, ? extends V> m) mSet()
2 Boolean multiSetIfAbsent(Map<? extends K, ? extends V> m) mSetNX()
3 List<V> multiGet(Collection<K> keys) mGet()
문자열 메소드 Str Methods
No Methods Redis Commands
1 void set(K key, V value, long offset) setRange()
2 String get(K key, long start, long end) getRange()
3 Integer append(K key, String value) append()
4 Long size(K key) strLen()
증가, 감소 메소드 Incr, Decr Methods
No Methods Redis Commands
1 Long increment(K key) incr()
2 Double increment(K key, double delta) incrBy()
3 Long decrement(K key) decr()
4 Long decrement(K key, long delta) decrBy()
비트 메소드 Bit Methods
No Methods Redis Commands
1 Boolean setBit(K key, long offset, boolean value) setBit()
2 Boolean getBit(K key, long offset) getBit()
3 List<Long> bitField(K key, final BitFieldSubCommands subCommands) bitField()
리스트 메소드 List Methods - ListOperations
public interface ListOperations<K, V>
class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements
ListOperations<K, V>
왼쪽에 입력 메소드 leftPush Methods
No Methods Redis Commands
1 Long leftPush(K key, V value) lPush()
2 Long leftPushAll(K key, V... values) lPush()
3 Long leftPushAll(K key, Collection values) lPush()
4 Long leftPushIfPresent(K key, V value) lPushX()
오른쪽에 입력 메소드 rightPush Methods
No Methods Redis Commands
1 Long rightPush(K key, V value) rPush()
2 Long rightPushAll(K key, V... values) rPush()
3 Long rightPushAll(K key, Collection values) rPush()
4 Long rightPushIfPresent(K key, V value) rPushX()
지정한 값 전, 후에 넣기, 대체하기 메소드 Insert Before, After, Replace Methods
왼쪽에서, 오른쪽에서 꺼내기 메소드 leftPop, rightPop Methods
No Methods Redis Commands
1 V leftPop(K key) lPop()
2 List<V> leftPop(K key, long count) lPop()
3 V rightPop(K key) rPop()
4 List<V> rightPop(K key, long count) rPop()
데이터가 들어오면 꺼내기 메소드 Blocking leftPop, rightPop Methods
No Methods Redis Commands
1 V leftPop(K key, long timeout, TimeUnit unit) bLPop()
2 V rightPop(K key, long timeout, TimeUnit unit) bRPop()
인덱스로 값 조회, 값으로 인덱스 조회 메소드 Query Value by Index, Index by Value Methods
No Methods Redis Commands
1 V index(K key, long index) lIndex()
2 Long indexOf(K key, V value) lPos()
3 Long lastIndexOf(K key, V value) lPos(-1)
값 개수, 범위 지정 조회, 삭제 메소드 Methods
No Methods Redis Commands
1 Long size(K key) lLen()
2 List<V> range(K key, long start, long end) lRange()
3 Long remove(K key, long count, Object value) lRem()
4 void trim(K key, long start, long end) lTrim()
데이터가 들어오면 이동하기 메소드 Blocking Methods
No Methods Redis Commands
1 V rightPopAndLeftPush(K sourceKey, K destinationKey) rPopLPush()
2 V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit) bRPopLPush()
이동 메소드 Move Methods
No Methods Redis Commands
1 V move(K sourceKey, Direction from, K destinationKey, Direction to) lMove()
셋 메소드 Set Methods - SetOperations
public interface SetOperations<K, V>
class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements
SetOperations<K, V>
입력, 꺼내오기 메소드 Add, Pop Methods
No Methods Redis Commands
1 Long add(K key, V... values) sAdd()
2 V pop(K key) sPop()
3 List<V> pop(K key, long count) sPop()
조회 메소드 Get Methods
멤버 있는지 확인 메소드 Exist Methods
No Methods Redis Commands
1 Boolean isMember(K key, Object o) sIsMember()
2 Map isMember(K key, Object... objects) sMIsMember()
멤버 삭제, 이동 메소드 Member Remove, Move Methods
No Methods Redis Commands
1 Long remove(K key, Object... values) sRem()
2 Boolean move(K key, V value, K destKey) sMove()
합집합, 교집합, 차집합 메소드 Union, Intersect, Difference Methods
No Methods Redis Commands
1 Set<V> union(K key, K otherKey) sUnion()
2 Set<V> union(K key, Collection<K> otherKeys) sUnion()
3 Set<V> union(Collection<K> keys) sUnion()
4 Set<V> intersect(K key, K otherKey) sInter()
5 Set<V> intersect(K key, Collection<K> otherKeys) sInter()
6 Set<V> intersect(Collection<K> keys) sInter()
7 Set<V> difference(K key, K otherKey) sDiff()
8 Set<V> difference(K key, Collection<K> otherKeys) sDiff()
9 Set<V> difference(Collection<K> keys) sDiff()
합집합, 교집합, 차집합 저장 메소드 Union, Intersect, Difference Store Methods
No Methods Redis Commands
1 Long unionAndStore(K key, K otherKey, K destKey) sUnionStore()
2 Long unionAndStore(K key, Collection otherKeys, K destKey) sUnionStore()
3 Long unionAndStore(Collection keys, K destKey) sUnionStore()
4 Long intersectAndStore(K key, K otherKey, K destKey) sInterStore()
5 Long intersectAndStore(K key, Collection otherKeys, K destKey) sInterStore()
6 Long intersectAndStore(Collection keys, K destKey) sInterStore()
7 Long differenceAndStore(K key, K otherKey, K destKey) sDiffStore()
8 Long differenceAndStore(K key, Collection otherKeys, K destKey) sDiffStore()
9 Long differenceAndStore(Collection keys, K destKey) sDiffStore()
소트셋 메소드 ZSet Methods - ZSetOperations
public interface ZSetOperations<K, V>
class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements
ZSetOperations<K, V>
입력 메소드 Add Methods
No Methods Redis Commands
1 Boolean add(K key, V value, double score) zAdd()
2 Boolean addIfAbsent(K key, V value, double score) zAdd(NX)
3 Boolean add(K key, V value, double score, ZAddArgs args) zAdd()
4 Long add(K key, Set<TypedTuple<V>> tuples) zAdd()
5 Long addIfAbsent(K key, Set<TypedTuple<V>> tuples) zAdd(NX)
6 Long add(K key, Set<TypedTuple<V>> tuples, ZAddArgs args) zAdd()
최소값, 최대값 꺼내오기 메소드 Min, Max Pop Methods
No Methods Redis Commands
1 TypedTuple<V> popMin(K key) zPopMin()
2 Set<TypedTuple<V>> popMin(K key, long count) zPopMin()
3 TypedTuple<V> popMax(K key) zPopMax()
4 Set<TypedTuple<V>> popMax(K key, long count) zPopMax()
5 TypedTuple<V> popMin(K key, long timeout, TimeUnit unit) bZPopMin()
6 TypedTuple<V> popMax(K key, long timeout, TimeUnit unit) bZPopMax()
스코어 증감 메소드 Score Incr, Decr Methods
No Methods Redis Commands
1 Double incrementScore(K key, V value, double delta) zIncrBy()
개수 조회 메소드 Card, Count Methods
No Methods Redis Commands
1 Long size(K key) zCard()
2 Long zCard(K key) zCard()
3 Long count(K key, double min, double max) zCount()
4 Long lexCount(K key, Range<String> range) zLexCount()
값으로 인덱스, 스코어 조회 메소드 Index, Score Methods
No Methods Redis Commands
1 Long rank(K key, Object o) zRank()
2 Long reverseRank(K key, Object o) zRevRank()
3 Double score(K key, Object o) zScore()
4 List<Double> score(K key, Object... o) zMScore()
인덱스로 조회 메소드 Query by Index Methods
No Methods Redis Commands
1 Set<V> range(K key, long start, long end) zRange()
2 Set<V> reverseRange(K key, long start, long end) zRevRange()
3 Set<TypedTuple<V>> rangeWithScores(K key, long start, long end) zRangeWithScores()
4 Set<TypedTuple<V>> reverseRangeWithScores(K key, long start, long end) zRevRangeWithScores()
스코어로 조회 메소드 Query by Score Methods
No Methods Redis Commands
1 Set<V> rangeByScore(K key, double min, double max) zRangeByScore()
2 Set<V> rangeByScore(K key, double min, double max, long offset, long count) zRangeByScore()
3 Set<V> reverseRangeByScore(K key, double min, double max) zRevRangeByScore()
4 Set<V> reverseRangeByScore(K key, double min, double max, long offset, long count) zRevRangeByScore()
5 Set<byte[]> rangeByScore(K key, String min, String max) zRangeByScore()
6 Set<byte[]> rangeByScore(K key, String min, String max, long offset, long count) zRangeByScore()
7 Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max) zRangeByScoreWithScores()
8 Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max, long offset, long count) zRangeByScoreWithScores()
9 Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max) zRevRangeByScoreWithScores()
10 Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max, long offset, long count) zRevRangeByScoreWithScores()
값으로 조회 메소드 Query by Value Methods
No Methods Redis Commands
1 Set rangeByLex(K key, Range range, Limit limit) zRangeByLex()
2 Set reverseRangeByLex(K key, Range range, Limit limit) zRevRangeByLex()
조회 결과를 저장 메소드 Store Result Methods
No Methods Redis Commands
1 Long rangeAndStoreByScore(K srcKey, K dstKey, Range<? extends Number> range, Limit limit) zRangeStoreByScore()
2 Long rangeAndStoreByLex(K srcKey, K dstKey, Range<String> range, Limit limit) zRangeStoreByLex()
3 Long reverseRangeAndStoreByScore(K srcKey, K dstKey, Range<? extends Number> range, Limit limit) zRangeStoreRevByScore()
4 Long reverseRangeAndStoreByLex(K srcKey, K dstKey, Range<String> range, Limit limit) zRangeStoreRevByLex()
Scan 메소드 Scan Methods
No Methods Redis Commands
1 Cursor<TypedTuple<V>> scan(K key, ScanOptions options) zScan()
랜덤 조회 메소드 Random Methods
삭제 메소드 Remove Methods
합집합, 교집합, 차집합 메소드 Union, Intersect, Diff Methods
No Methods Redis Commands
1 Set<V> union(K key, Collection<K> otherKeys) zUnion()
2 Set<TypedTuple<V>> unionWithScores(K key, Collection<K> otherKeys) zUnionWithScores()
3 Set<TypedTuple<V>> unionWithScores(K key, Collection<K> otherKeys, Aggregate aggregate, Weights weights) zUnionWithScores()
4 Set<V> intersect(K key, Collection<K> otherKeys) zInter()
5 Set<TypedTuple<V>> intersectWithScores(K key, Collection<K> otherKeys) zInterWithScores()
6 Set<TypedTuple<V>> intersectWithScores(K key, Collection<K> otherKeys, Aggregate aggregate, Weights weights) zInterWithScores()
7 Set<V> difference(K key, Collection<K> otherKeys) zDiff()
8 Set<TypedTuple<V>> differenceWithScores(K key, Collection<K> otherKeys) zDiffWithScores()
합집합, 교집합, 차집합 저장 메소드 Store Union, Intersect, Diff Methods
No Methods Redis Commands
1 Long unionAndStore(K key, K otherKey, K destKey) unionAndStore()
2 Long unionAndStore(K key, Collection<K> otherKeys, K destKey) zUnionStore()
3 Long unionAndStore(K key, Collection<K> otherKeys, K destKey, Aggregate aggregate, Weights weights) zUnionStore()
4 Long intersectAndStore(K key, K otherKey, K destKey) intersectAndStore()
5 Long intersectAndStore(K key, Collection<K> otherKeys, K destKey) zInterStore()
6 Long intersectAndStore(K key, Collection<K> otherKeys, K destKey, Aggregate aggregate, Weights weights) zInterStore()
7 Long differenceAndStore(K key, Collection<K> otherKeys, K destKey) zDiffStore()
해시 메소드 Hash Methods - HashOperations
public interface HashOperations<H, HK, HV>
class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> implements
HashOperations<K, HK, HV>
입력 메소드 Set Methods
No Methods Redis Commands
1 void put(K key, HK hashKey, HV value) hSet()
2 Boolean putIfAbsent(K key, HK hashKey, HV value) hSetNX()
3 void putAll(K key, Map<? extends HK, ? extends HV> m) hMSet()
조회 메소드 Get Methods
No Methods Redis Commands
1 HV get(K key, Object hashKey) hGet()
2 List<HV> multiGet(K key, Collection<HK> fields) hMGet()
3 Map<HK, HV> entries(K key) hGetAll()
4 Set<HK> keys(K key) hKeys()
5 List<HV> values(K key) hVals()
필드 개수, 있는지 확인 메소드 Field Count, Exist Methods
No Methods Redis Commands
1 Long size(K key) hLen()
2 Boolean hasKey(K key, Object hashKey) hExists()
3 Long lengthOfValue(K key, HK hashKey) hStrLen()
증가, 감소 메소드 Incr, Decr Methods
No Methods Redis Commands
1 Long increment(K key, HK hashKey, long delta) hIncrBy()
2 Double increment(K key, HK hashKey, double delta) hincrbyfloat()
랜덤 필드 메소드 Random Field Methods
삭제 메소드 Delete Methods
No Methods Redis Commands
1 Long delete(K key, Object... hashKeys) hDel()
스캔 메소드 Scan Methods
No Methods Redis Commands
1 Cursor<Entry<HK, HV>> scan(K key, ScanOptions options) hScan()
스트림 메소드 Stream Methods - StreamOperations
public interface StreamOperations extends HashMapperProvider
class DefaultStreamOperations<K, HK, HV> extends AbstractOperations<K, Object> implements
StreamOperations<K, HK, HV>
RecordId add(Record<K, ?> record) -> xAdd()
List<MapRecord<K, HK, HV>> range(K key, Range<String> range, Limit limit) -> xRange()
List<MapRecord<K, HK, HV>> reverseRange(K key, Range<String> range, Limit limit) -> xRevRange()
Long size(K key) -> xLen()
Long delete(K key, RecordId... recordIds) -> xDel()
Long acknowledge(K key, String group, String... recordIds) -> xAck()
List<MapRecord<K, HK, HV>> claim(K key, String consumerGroup, String newOwner, XClaimOptions xClaimOptions) -> xClaim()
String createGroup(K key, ReadOffset readOffset, String group) -> xGroupCreate()
Boolean deleteConsumer(K key, Consumer consumer) -> xGroupDelConsumer()
Boolean destroyGroup(K key, String group) -> xGroupDestroy()
XInfoStream info(K key) -> xInfo()
XInfoConsumers consumers(K key, String group) -> xInfoConsumers()
XInfoGroups groups(K key) -> xInfoGroups()
PendingMessages pending(K key, String group, Range<?> range, long count) -> xPending()
PendingMessages pending(K key, Consumer consumer, Range<?> range, long count) -> xPending()
PendingMessagesSummary pending(K key, String group) -> xPending()
List<MapRecord<K, HK, HV>> read(StreamReadOptions readOptions, StreamOffset<K>... streams) -> xRead()
List<MapRecord<K, HK, HV>> read(Consumer consumer, StreamReadOptions readOptions, StreamOffset<K>... streams) -> xReadGroup()
Long trim(K key, long count) -> xTrim()
Long trim(K key, long count, boolean approximateTrimming) -> xTrim()