文档首页/ 多活高可用服务 MAS/ 开发指南/ MAS-Redis-SDK使用手册/ 命令参考/ RedisTemplate命令与DcsConnection接口对应关系
更新时间:2024-10-23 GMT+08:00
分享

RedisTemplate命令与DcsConnection接口对应关系

RedisTemplate命令对应DcsConnection接口,请参考下表。

表1 RedisTemplate和DcsConnection对应关系

RedisTemplate命令

DcsConnection方法

expire(stringKey, 1L, TimeUnit.SECONDS)

expire(stringKey, Duration.ofSeconds(10L))

Boolean pExpire(@Nonnull byte[] key, long millis)

opsForValue().get(stringKey)

byte[] get(@Nonnull byte[] key)

opsForValue().set(stringKey, stringValue)

Boolean set(@Nonnull byte[] key, @Nonnull byte[] value)

opsForValue().set(stringKey, stringValue, 1L, TimeUnit.SECONDS)

// Boolean setEx(@Nonnull byte[] key, long seconds, @Nonnull byte[] value)

opsForValue().setIfAbsent(stringKey, stringValue)

Boolean setNX(@Nonnull byte[] key, @Nonnull byte[] value)

opsForValue().setIfAbsent(stringKey, stringValue, 1L, TimeUnit.SECONDS)

Boolean set(@Nonnull byte[] key, @Nonnull byte[] value, @Nonnull Expiration expiration, @Nonnull RedisStringCommands.SetOption option)

opsForValue().set(stringKey, stringValue, 1L)

void setRange(@Nonnull byte[] key, @Nonnull byte[] value, long offset)

opsForValue().append(stringKey, stringValue)

public Long append(@Nonnull byte[] key, @Nonnull byte[] value)

opsForValue().decrement("numKey")

Long decr(@Nonnull byte[] key)

opsForValue().decrement("numKey", 2)

Long decrBy(@Nonnull byte[] key, long value)

countExistingKeys(Collections.singleton("devspore"))

Long exists(@Nonnull byte[]... keys)

delete(stringKey)

Long del(@Nonnull byte[]... keys)

opsForValue().increment(stringKey)

Long incr(@Nonnull byte[] key)

opsForValue().increment(stringKey, 1L)

Long incrBy(@Nonnull byte[] key, long value)

opsForValue().increment(stringKey, 1D)

Double incrBy(@Nonnull byte[] key, double value)

opsForValue().getAndSet("appendKey", "getSetValue")

byte[] getSet(@Nonnull byte[] key, @Nonnull byte[] value)

keys(stringKey)

Set<byte[]> keys(@Nonnull byte[] pattern)

opsForSet().members(setKey)

Set<byte[]> sMembers(@Nonnull byte[] key)

opsForSet().add(setKey, setValue)

Long sAdd(@Nonnull byte[] key, @Nonnull byte[]... values)

opsForSet().remove(setKey,setValue)

Long sRem(@Nonnull byte[] key, @Nonnull byte[]... values)

opsForSet().isMember(setKey, setValue)

Boolean sIsMember(@Nonnull byte[] key, @Nonnull byte[] value)

opsForZSet().add(zSetKey, zSetValue, 1)

Boolean zAdd(@Nonnull byte[] key, double score, @Nonnull byte[] value)

opsForZSet().add(zSetKey, Collections.singleton(new DefaultTypedTuple<>(zSetValue, 1d)))

Long zAdd(@Nonnull byte[] key, @Nonnull Set<Tuple> tuples)

opsForZSet().addIfAbsent(zSetKey, Collections.singleton(new DefaultTypedTuple<>(zSetValue, 1d)))

Long zAdd(@Nonnull byte[] key, @Nonnull Set<Tuple> set, @Nonnull ZAddArgs zAddArgs)

opsForZSet().addIfAbsent(zSetKey, zSetValue, 1)

Boolean zAdd(@Nonnull byte[] key, double v, @Nonnull byte[] member, @Nonnull ZAddArgs zAddArgs)

opsForZSet().zCard(zSetKey)

Long zCard(@Nonnull byte[] key)

opsForZSet().rangeByScore(zSetKey, 1D, 2D)

Set<byte[]> zRangeByScore(@Nonnull byte[] key, @Nonnull Range range, @Nonnull Limit limit)

opsForZSet().rangeByScore(zSetKey, 1D, 2D, 1L, 1L)

Set<byte[]> zRangeByScore(@Nonnull byte[] key, @Nonnull Range range, @Nonnull Limit limit)

opsForZSet().remove(zSetKey, zSetThirdValue)

Long zRem(@Nonnull byte[] key, @Nonnull byte[]... values)

opsForZSet().incrementScore(zSetKey, zSetValue, 2)

Double zIncrBy(@Nonnull byte[] key, double increment, @Nonnull byte[] value)

opsForZSet().score(zSetKey, zSetValue)

Double zScore(@Nonnull byte[] key, @Nonnull byte[] value)

opsForZSet().removeRange(zSetKey, 0, 2)

Long zRemRange(@Nonnull byte[] key, long start, long end)

opsForZSet().range(zSetKey, 0, 4)

Set<byte[]> zRange(@Nonnull byte[] key, long start, long end)

opsForZSet().reverseRange(zSetKey, 0, 2)

Set<byte[]> zRevRange(@Nonnull byte[] key, long start, long end)

opsForZSet().removeRangeByScore(zSetKey, 1, 2)

Long zRemRangeByScore(@Nonnull byte[] key, Range range)

Long zRemRangeByLex(@Nonnull byte[] key, @Nonnull Range range)

opsForZSet().removeRangeByLex(zSetKey, new RedisZSetCommands.Range().gte(zSetValue).lte(zSetSecondValue))

opsForHash().get(hKey, hValue)

byte[] hGet(@Nonnull byte[] key, @Nonnull byte[] field)

opsForHash().entries(hKey)

Map<byte[], byte[]> hGetAll(@Nonnull byte[] key)

opsForHash().put(hKey, "filed", hValue)

Boolean hSet(@Nonnull byte[] key, @Nonnull byte[] field, @Nonnull byte[] value)

opsForHash().putAll(hKey, hashes)

hMSet(@Nonnull byte[] key, @Nonnull Map<byte[], byte[]> hashes)

opsForHash().delete(hKey, "field")

Long hDel(@Nonnull byte[] key, @Nonnull byte[]... fields)

opsForHash().hasKey(hKey, "field")

Boolean hExists(@Nonnull byte[] key, @Nonnull byte[] field)

opsForHash().keys(hKey)

Set<byte[]> hKeys(@Nonnull byte[] key)

opsForHash().increment(hKey, "field", 1L)

Long hIncrBy(@Nonnull byte[] key, @Nonnull byte[] field, long delta)

opsForHash().increment(hKey, "field", 2D)

Double hIncrBy(@Nonnull byte[] key, @Nonnull byte[] field, double delta)

opsForHash().scan(hKey, ScanOptions.scanOptions().build())

Cursor<Map.Entry<byte[], byte[]>> hScan(@Nonnull byte[] key, @Nonnull ScanOptions options)

opsForHash().values(hKey)

List<byte[]> hVals(byte[] key)

opsForList().set(lKey, 0, "setValue")

void lSet(@Nonnull byte[] key, long index, @Nonnull byte[] value)

opsForList().range(lKey, 1, 2)

List<byte[]> lRange(@Nonnull byte[] key, long start, long end)

opsForList().rightPush(lKey, lValue)

Long rPush(@Nonnull byte[] key, @Nonnull byte[]... values)

opsForList().leftPush(lKey, lValue)

Long lPush(@Nonnull byte[] key, @Nonnull byte[]... values)

opsForList().leftPop(lKey)

byte[] lPop(@Nonnull byte[] key)

opsForList().leftPop(lKey, 1L, TimeUnit.SECONDS)

List<byte[]> bLPop(int timeout, @Nonnull byte[]... keys)

opsForList().rightPop(lKey)

byte[] rPop(@Nonnull byte[] bytes)

opsForList().trim(lKey, 0, 2);

void lTrim(byte[] key, long start, long end)

opsForList().remove(lKey, 1, str2byte("setValue"))

Long lRem(byte[] key, long count, byte[] value)

opsForList().size(lKey)

Long lLen(@Nonnull byte[] key)

getExpire(lKey, TimeUnit.SECONDS)

Long pTtl(@Nonnull byte[] key)Long pTtl(@Nonnull byte[] key, @Nonnull TimeUnit timeUnit)

unlink(str2byte("unlinkKey")))

Long unlink(@Nonnull byte[]... keys)

type(stringKey)

DataType type(@Nonnull byte[] key)

相关文档