RedisTemplate

Redis Developer Course Redis Technical Support Redis Enterprise Server

RedisTemplate

Spring Boot의 RedisTemplate의 메소드와 레디스 서버의 명령관계를 설명한다.
메소드명과 레디스 명령 이름이 달라 헷갈리는 경우가 있다.

public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperations<K, V>, BeanClassLoaderAware

일반 키 메소드 Common Key Methods

NoMethodsRedis Commands
1Boolean copy(K source, K target, boolean replace)copy()
2Boolean hasKey(K key) exists()
3Long countExistingKeys(Collection<K> keys) exists()
4Boolean delete(K key) del()
5Long delete(Collection<K> keys) del()
6Boolean unlink(K key) unlink()
7Long unlink(Collection<K> keys) unlink()
8DataType type(K key) type()
9Set<K> keys(K pattern) keys()
10Cursor<K> scan(ScanOptions options) scan()
11K randomKey() randomKey
12void rename(K oldKey, K newKey) rename()
13Boolean renameIfAbsent(K oldKey, K newKey) renameNX()
14Boolean expire(K key, final long timeout, final TimeUnit unit) pExpire(), expire()
15Boolean expireAt(K key, final Date date) pExpireAt(), expireAt()
16Boolean persist(K key) persist()
17Long getExpire(K key) ttl()
18Long getExpire(K key, TimeUnit timeUnit) pTtl(), ttl()
19Boolean move(K key, final int dbIndex) move()
20byte[] dump(K key)dump()
21void restore(K key, byte[] value, long timeToLive, TimeUnit unit, boolean replace)restore()

소트 메소드 Sort Methods

NoMethodsRedis Commands
1List<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()
5Long sort(SortQuery<K> query, K storeKey)sort()

트랜잭션 메소드 Transactions Methods

NoMethodsRedis Commands
1void watch(K key)watch()
2void watch(Collection<K> keys)watch()
3void unwatch()unwatch()
4void multi()multi()
5void discard()discard()
6List<Object> exec()exec()

클라이언트 메소드 Client Methods

NoMethodsRedis Commands
1List<RedisClientInfo> getClientList()client list
2void killClient(String host, int port)client kill

복제 관련 메소드 Replicaof Methods

NoMethodsRedis Commands
1void replicaOf(String host, int port)replicaof
2void replicaOfNoOne()replicaof no one

퍼블리쉬 메소드 Publish Methods

NoMethodsRedis Commands
1Long convertAndSend(String channel, Object message)publish


스트링 메소드 String Methods - DefaultValueOperations

class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements ValueOperations<K, V>

입력 메소드 Set Methods

NoMethodsRedis Commands
1void set(K key, V value)set()
2void set(K key, V value, long timeout, TimeUnit unit)setEx(), pSetEx()
3Boolean setIfAbsent(K key, V value)setNX()
4Boolean setIfAbsent(K key, V value, long timeout, TimeUnit unit)set()
5Boolean setIfPresent(K key, V value)set()
6Boolean setIfPresent(K key, V value, long timeout, TimeUnit unit)set()

조회 메소드 Get Methods

NoMethodsRedis Commands
1V get(Object key)get()
2V getAndDelete(K key)getDel()
3V getAndExpire(K key, long timeout, TimeUnit unit)getEx()
4V getAndExpire(K key, Duration timeout)getEx()
5V getAndPersist(K key)getEx(PERSIST)
6V getAndSet(K key, V newValue)getSet()

멀티 Set,Get 메소드 Multi Set,Get Methods

NoMethodsRedis Commands
1void multiSet(Map<? extends K, ? extends V> m)mSet()
2Boolean multiSetIfAbsent(Map<? extends K, ? extends V> m)mSetNX()
3List<V> multiGet(Collection<K> keys)mGet()

문자열 메소드 Str Methods

NoMethodsRedis Commands
1void set(K key, V value, long offset)setRange()
2String get(K key, long start, long end)getRange()
3Integer append(K key, String value)append()
4Long size(K key)strLen()

증가, 감소 메소드 Incr, Decr Methods

NoMethodsRedis Commands
1Long increment(K key)incr()
2Double increment(K key, double delta)incrBy()
3Long decrement(K key)decr()
4Long decrement(K key, long delta)decrBy()

비트 메소드 Bit Methods

NoMethodsRedis Commands
1Boolean setBit(K key, long offset, boolean value)setBit()
2Boolean getBit(K key, long offset)getBit()
3List<Long> bitField(K key, final BitFieldSubCommands subCommands)bitField()


리스트 메소드 List Methods - DefaultListOperations

class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements ListOperations<K, V>


왼쪽에 입력 메소드 leftPush Methods

NoMethodsRedis Commands
1Long leftPush(K key, V value)lPush()
2Long leftPushAll(K key, V... values)lPush()
3Long leftPushAll(K key, Collection values)lPush()
4Long leftPushIfPresent(K key, V value)lPushX()

오른쪽에 입력 메소드 rightPush Methods

NoMethodsRedis Commands
1Long rightPush(K key, V value)rPush()
2Long rightPushAll(K key, V... values)rPush()
3Long rightPushAll(K key, Collection values)rPush()
4Long rightPushIfPresent(K key, V value)rPushX()

지정한 값 전, 후에 넣기, 대체하기 메소드 Insert Before, After, Replace Methods

NoMethodsRedis Commands
1Long leftPush(K key, V pivot, V value)lInsert(Position.BEFORE)()
2Long rightPush(K key, V pivot, V value)lInsert(Position.AFTER)()
3void set(K key, long index, V value)lSet()

왼쪽에서, 오른쪽에서 꺼내기 메소드 leftPop, rightPop Methods

NoMethodsRedis Commands
1V leftPop(K key)lPop()
2List<V> leftPop(K key, long count)lPop()
3V rightPop(K key)rPop()
4List<V> rightPop(K key, long count)rPop()

데이터가 들어오면 꺼내기 메소드 Blocking leftPop, rightPop Methods

NoMethodsRedis Commands
1V leftPop(K key, long timeout, TimeUnit unit)bLPop()
2V rightPop(K key, long timeout, TimeUnit unit)bRPop()

인덱스로 값 조회, 값으로 인덱스 조회 메소드 Query Value by Index, Index by Value Methods

NoMethodsRedis Commands
1V index(K key, long index)lIndex()
2Long indexOf(K key, V value)lPos()
3Long lastIndexOf(K key, V value)lPos(-1)

값 개수, 범위 지정 조회, 삭제 메소드 Methods

NoMethodsRedis Commands
1Long size(K key)lLen()
2List<V> range(K key, long start, long end)lRange()
3Long remove(K key, long count, Object value)lRem()
4void trim(K key, long start, long end)lTrim()

데이터가 들어오면 이동하기 메소드 Blocking Methods

NoMethodsRedis Commands
1V rightPopAndLeftPush(K sourceKey, K destinationKey)rPopLPush()
2V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit)bRPopLPush()

이동 메소드 Move Methods

NoMethodsRedis Commands
1V move(K sourceKey, Direction from, K destinationKey, Direction to)lMove()


셋 메소드 Set Methods - DefaultSetOperations

class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements SetOperations<K, V>


입력, 꺼내오기 메소드 Add, Pop Methods

NoMethodsRedis Commands
1Long add(K key, V... values)sAdd()
2V pop(K key)sPop()
3List<V> pop(K key, long count)sPop()

조회 메소드 Get Methods

NoMethodsRedis Commands
1Long size(K key)sCard()
2Set<V> members(K key)sMembers()
3Cursor<V> scan(K key, ScanOptions options) sScan()
4V randomMember(K key)sRandMember()
5Set<V> distinctRandomMembers(K key, long count)   값 중복허용sRandMember(Positive)
6List<V> randomMembers(K key, long count)   값 중복안됨sRandMember(Negative)

멤버 있는지 확인 메소드 Exist Methods

NoMethodsRedis Commands
1Boolean isMember(K key, Object o)sIsMember()
2Map isMember(K key, Object... objects)sMIsMember()

멤버 삭제, 이동 메소드 Member Remove, Move Methods

NoMethodsRedis Commands
1Long remove(K key, Object... values)sRem()
2Boolean move(K key, V value, K destKey)sMove()

합집합, 교집합, 차집합 메소드 Union, Intersect, Difference Methods

NoMethodsRedis Commands
1Set<V> union(K key, K otherKey)sUnion()
2Set<V> union(K key, Collection<K> otherKeys)sUnion()
3Set<V> union(Collection<K> keys)sUnion()
4Set<V> intersect(K key, K otherKey)sInter()
5Set<V> intersect(K key, Collection<K> otherKeys)sInter()
6Set<V> intersect(Collection<K> keys)sInter()
7Set<V> difference(K key, K otherKey)sDiff()
8Set<V> difference(K key, Collection<K> otherKeys)sDiff()
9Set<V> difference(Collection<K> keys)sDiff()

합집합, 교집합, 차집합 저장 메소드 Union, Intersect, Difference Store Methods

NoMethodsRedis Commands
1Long unionAndStore(K key, K otherKey, K destKey)sUnionStore()
2Long unionAndStore(K key, Collection otherKeys, K destKey)sUnionStore()
3Long unionAndStore(Collection keys, K destKey)sUnionStore()
4Long intersectAndStore(K key, K otherKey, K destKey)sInterStore()
5Long intersectAndStore(K key, Collection otherKeys, K destKey)sInterStore()
6Long intersectAndStore(Collection keys, K destKey)sInterStore()
7Long differenceAndStore(K key, K otherKey, K destKey)sDiffStore()
8Long differenceAndStore(K key, Collection otherKeys, K destKey)sDiffStore()
9Long differenceAndStore(Collection keys, K destKey)sDiffStore()


소트셋 메소드 ZSet Methods - DefaultZSetOperations

class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZSetOperations<K, V>


입력 메소드 Add Methods

NoMethodsRedis Commands
1Boolean add(K key, V value, double score)zAdd()
2Boolean addIfAbsent(K key, V value, double score)zAdd(NX)
3Boolean add(K key, V value, double score, ZAddArgs args)zAdd()
4Long add(K key, Set<TypedTuple<V>> tuples)zAdd()
5Long addIfAbsent(K key, Set<TypedTuple<V>> tuples)zAdd(NX)
6Long add(K key, Set<TypedTuple<V>> tuples, ZAddArgs args)zAdd()

최소값, 최대값 꺼내오기 메소드 Min, Max Pop Methods

NoMethodsRedis Commands
1TypedTuple<V> popMin(K key)zPopMin()
2Set<TypedTuple<V>> popMin(K key, long count)zPopMin()
3TypedTuple<V> popMax(K key)zPopMax()
4Set<TypedTuple<V>> popMax(K key, long count)zPopMax()
5TypedTuple<V> popMin(K key, long timeout, TimeUnit unit)bZPopMin()
6TypedTuple<V> popMax(K key, long timeout, TimeUnit unit)bZPopMax()

스코어 증감 메소드 Score Incr, Decr Methods

NoMethodsRedis Commands
1Double incrementScore(K key, V value, double delta)zIncrBy()

개수 조회 메소드 Card, Count Methods

NoMethodsRedis Commands
1Long size(K key)zCard()
2Long zCard(K key)zCard()
3Long count(K key, double min, double max)zCount()
4Long lexCount(K key, Range<String> range)zLexCount()

값으로 인덱스, 스코어 조회 메소드 Index, Score Methods

NoMethodsRedis Commands
1Long rank(K key, Object o)zRank()
2Long reverseRank(K key, Object o)zRevRank()
3Double score(K key, Object o)zScore()
4List<Double> score(K key, Object... o)zMScore()

인덱스로 조회 메소드 Query by Index Methods

NoMethodsRedis Commands
1Set<V> range(K key, long start, long end)zRange()
2Set<V> reverseRange(K key, long start, long end)zRevRange()
3Set<TypedTuple<V>> rangeWithScores(K key, long start, long end)zRangeWithScores()
4Set<TypedTuple<V>> reverseRangeWithScores(K key, long start, long end)zRevRangeWithScores()

스코어로 조회 메소드 Query by Score Methods

NoMethodsRedis Commands
1Set<V> rangeByScore(K key, double min, double max)zRangeByScore()
2Set<V> rangeByScore(K key, double min, double max, long offset, long count)zRangeByScore()
3Set<V> reverseRangeByScore(K key, double min, double max)zRevRangeByScore()
4Set<V> reverseRangeByScore(K key, double min, double max, long offset, long count)zRevRangeByScore()
5Set<byte[]> rangeByScore(K key, String min, String max)zRangeByScore()
6Set<byte[]> rangeByScore(K key, String min, String max, long offset, long count)zRangeByScore()
7Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max)zRangeByScoreWithScores()
8Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max, long offset, long count)zRangeByScoreWithScores()
9Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max)zRevRangeByScoreWithScores()
10Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max, long offset, long count)zRevRangeByScoreWithScores()

값으로 조회 메소드 Query by Value Methods

NoMethodsRedis Commands
1Set rangeByLex(K key, Range range, Limit limit)zRangeByLex()
2Set reverseRangeByLex(K key, Range range, Limit limit)zRevRangeByLex()

조회 결과를 저장 메소드 Store Result Methods

NoMethodsRedis Commands
1Long rangeAndStoreByScore(K srcKey, K dstKey, Range<? extends Number> range, Limit limit)zRangeStoreByScore()
2Long rangeAndStoreByLex(K srcKey, K dstKey, Range<String> range, Limit limit)zRangeStoreByLex()
3Long reverseRangeAndStoreByScore(K srcKey, K dstKey, Range<? extends Number> range, Limit limit)zRangeStoreRevByScore()
4Long reverseRangeAndStoreByLex(K srcKey, K dstKey, Range<String> range, Limit limit)zRangeStoreRevByLex()

Scan 메소드 Scan Methods

NoMethodsRedis Commands
1Cursor<TypedTuple<V>> scan(K key, ScanOptions options)zScan()

랜덤 조회 메소드 Random Methods

NoMethodsRedis Commands
1V randomMember(K key)zRandMember()
2TypedTuple randomMemberWithScore(K key)zRandMemberWithScore()
3Set distinctRandomMembers(K key, long count) 중복안됨zRandMember()
4List randomMembers(K key, long count) 중복허용zRandMember()
5Set> distinctRandomMembersWithScore(K key, long count) 중복안됨zRandMemberWithScore()
6List> randomMembersWithScore(K key, long count) 중복허용zRandMemberWithScore()

삭제 메소드 Remove Methods

NoMethodsRedis Commands
1Long remove(K key, Object... values)zRem()
2Long removeRange(K key, long start, long end)zRemRangeByRank()
3Long removeRangeByScore(K key, double min, double max)zRemRangeByScore()
4Long removeRangeByLex(K key, Range<String> range)zRemRangeByLex()

합집합, 교집합, 차집합 메소드 Union, Intersect, Diff Methods

NoMethodsRedis Commands
1Set<V> union(K key, Collection<K> otherKeys)zUnion()
2Set<TypedTuple<V>> unionWithScores(K key, Collection<K> otherKeys)zUnionWithScores()
3Set<TypedTuple<V>> unionWithScores(K key, Collection<K> otherKeys, Aggregate aggregate, Weights weights)zUnionWithScores()
4Set<V> intersect(K key, Collection<K> otherKeys)zInter()
5Set<TypedTuple<V>> intersectWithScores(K key, Collection<K> otherKeys)zInterWithScores()
6Set<TypedTuple<V>> intersectWithScores(K key, Collection<K> otherKeys, Aggregate aggregate, Weights weights)zInterWithScores()
7Set<V> difference(K key, Collection<K> otherKeys)zDiff()
8Set<TypedTuple<V>> differenceWithScores(K key, Collection<K> otherKeys)zDiffWithScores()

합집합, 교집합, 차집합 저장 메소드 Store Union, Intersect, Diff Methods

NoMethodsRedis Commands
1Long unionAndStore(K key, K otherKey, K destKey)unionAndStore()
2Long unionAndStore(K key, Collection<K> otherKeys, K destKey)zUnionStore()
3Long unionAndStore(K key, Collection<K> otherKeys, K destKey, Aggregate aggregate, Weights weights)zUnionStore()
4Long intersectAndStore(K key, K otherKey, K destKey)intersectAndStore()
5Long intersectAndStore(K key, Collection<K> otherKeys, K destKey)zInterStore()
6Long intersectAndStore(K key, Collection<K> otherKeys, K destKey, Aggregate aggregate, Weights weights)zInterStore()
7Long differenceAndStore(K key, Collection<K> otherKeys, K destKey)zDiffStore()


해시 메소드 Hash Methods - DefaultHashOperations

class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> implements HashOperations<K, HK, HV>


입력 메소드 Set Methods

NoMethodsRedis Commands
1void put(K key, HK hashKey, HV value)hSet()
2Boolean putIfAbsent(K key, HK hashKey, HV value)hSetNX()
3void putAll(K key, Map<? extends HK, ? extends HV> m)hMSet()

조회 메소드 Get Methods

NoMethodsRedis Commands
1HV get(K key, Object hashKey)hGet()
2List<HV> multiGet(K key, Collection<HK> fields)hMGet()
3Map<HK, HV> entries(K key)hGetAll()
4Set<HK> keys(K key)hKeys()
5List<HV> values(K key)hVals()

필드 개수, 있는지 확인 메소드 Field Count, Exist Methods

NoMethodsRedis Commands
1Long size(K key)hLen()
2Boolean hasKey(K key, Object hashKey)hExists()
3Long lengthOfValue(K key, HK hashKey)hStrLen()

증가, 감소 메소드 Incr, Decr Methods

NoMethodsRedis Commands
1Long increment(K key, HK hashKey, long delta)hIncrBy()
2Double increment(K key, HK hashKey, double delta)hincrbyfloat()

랜덤 필드 메소드 Random Field Methods

NoMethodsRedis Commands
1HK randomKey(K key)hRandField()
2Entry<HK, HV> randomEntry(K key)hRandFieldWithValues()
3List<HK> randomKeys(K key, long count)hRandField()
4Map<HK, HV> randomEntries(K key, long count)hRandFieldWithValues()

삭제 메소드 Delete Methods

NoMethodsRedis Commands
1Long delete(K key, Object... hashKeys)hDel()

스캔 메소드 Scan Methods

NoMethodsRedis Commands
1Cursor<Entry<HK, HV>> scan(K key, ScanOptions options)hScan()


스트림 메소드 Stream Methods - DefaultStreamOperations

package org.springframework.data.redis.core

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()

<< Lettuce ReadFrom Redis Template Connection Pool >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.

혹시 처음이세요?
레디스게이트에는 레디스에 대한 많은 정보가 있습니다.
레디스 소개, 명령어, SQL, 클라이언트, 서버, 센티널, 클러스터 등이 있습니다.
혹시 필요한 정보를 찾기 어려우시면 redisgate@gmail.com로 메일 주세요.
제가 찾아서 알려드리겠습니다.
 
close
IP를 기반으로 보여집니다.