AS AgentScopeAPI 手册 / API Reference

RedissonClientAdapter

public class RedissonClientAdapter implements RedisClientAdapter
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:117–221

Redisson 客户端适配器,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.core.session.redis.redisson 包,实现 RedisClientAdapter。核心成员包括 of、set、get、rightPushList、rangeList、getListLength。

Adapter for Redisson Redis client.

Redisson provides a comprehensive Redis client that automatically handles different deployment modes through a unified RedissonClient interface.

This adapter supports all Redisson deployment modes:

  • Standalone mode - single Redis instance

  • Cluster mode - Redis Cluster with multiple nodes

  • Sentinel mode - Redis with Sentinel for high availability

  • Master/Slave mode - Redis with master-slave replication

RedissonClient manages connection pooling, thread safety, and mode-specific logic internally, providing a seamless experience across all deployment modes.

Usage Examples:

Standalone Mode:

`// Create standalone configuration
Config config = new Config();
config.useSingleServer()
.setAddress("redis://localhost:6379")
.setConnectionMinimumIdleSize(5)
.setConnectionPoolSize(20);

// Create RedissonClient
RedissonClient redissonClient = Redisson.create(config);

// Create adapter
RedissonClientAdapter adapter = RedissonClientAdapter.of(redissonClient);

// Use with RedisSession
Session session = RedisSession.builder()
.redissonClient(redissonClient)
.build();
`

Cluster Mode:

`// Create cluster configuration
Config config = new Config();
config.useClusterServers()
.addNodeAddress("redis://localhost:7000", "redis://localhost:7001", "redis://localhost:7002")
.setScanInterval(2000);

// Create RedissonClient
RedissonClient redissonClient = Redisson.create(config);

// Create adapter
RedissonClientAdapter adapter = RedissonClientAdapter.of(redissonClient);
`

Sentinel Mode:

`// Create sentinel configuration
Config config = new Config();
config.useSentinelServers()
.setMasterName("mymaster")
.addSentinelAddress("redis://localhost:26379", "redis://localhost:26380")
.setDatabase(0);

// Create RedissonClient
RedissonClient redissonClient = Redisson.create(config);

// Create adapter
RedissonClientAdapter adapter = RedissonClientAdapter.of(redissonClient);
`

Master/Slave Mode:

`// Create master/slave configuration
Config config = new Config();
config.useMasterSlaveServers()
.setMasterAddress("redis://localhost:6379")
.addSlaveAddress("redis://localhost:6380", "redis://localhost:6381")
.setReadMode(ReadMode.SLAVE);

// Create RedissonClient
RedissonClient redissonClient = Redisson.create(config);

// Create adapter
RedissonClientAdapter adapter = RedissonClientAdapter.of(redissonClient);
`

方法摘要Method Summary

方法Method说明Description
public static RedissonClientAdapter of(RedissonClient redissonClient)
static
创建适配器来自 RedissonClient。
Create adapter from RedissonClient.
public void set(String key, String value)
执行设置相关操作。
Performs the set operation.
public String get(String key)
按条件读取数据。
Performs the get operation.
public void rightPushList(String key, String value)
执行 `rightPushList` 方法。
Performs the right push list operation.
public List<String> rangeList(String key, long start, long end)
执行 `rangeList` 方法。
Performs the range list operation.
public long getListLength(String key)
获取列表长度。
Returns the list length.
public void deleteKeys(String... keys)
删除密钥。
Deletes the keys.
public void addToSet(String key, String member)
添加到设置。
Adds the to set.
public Set<String> getSetMembers(String key)
获取设置成员。
Returns the set members.
public long getSetSize(String key)
获取设置大小。
Returns the set size.
public boolean keyExists(String key)
设置该参数。
Performs the key exists operation.
public Set<String> findKeysByPattern(String pattern)
查找 `findKeysByPattern`。
Finds the keys by pattern.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.

方法详情Method Detail

of

public static RedissonClientAdapter of(RedissonClient redissonClient)
static

创建适配器来自 RedissonClient。

Create adapter from RedissonClient.

参数Parameters
名称Name类型Type说明Description
redissonClientRedissonClientRedissonClient 实例。the RedissonClient instance
返回Returns RedissonClientAdapter
一种新的RedissonClientAdapter。a new RedissonClientAdapter
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:134–136

set

public void set(String key, String value)

执行设置相关操作。

Performs the set operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
valueString值(类型 `String`)。The value.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:138–142

get

public String get(String key)

按条件读取数据。

Performs the get operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:144–148

rightPushList

public void rightPushList(String key, String value)

执行 rightPushList 方法。

Performs the right push list operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
valueString值(类型 `String`)。The value.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:150–154

rangeList

public List<String> rangeList(String key, long start, long end)

执行 rangeList 方法。

Performs the range list operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
startlong启动(类型 `long`)。The start.
endlong结束(类型 `long`)。The end.
返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:156–167

getListLength

public long getListLength(String key)

获取列表长度。

Returns the list length.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
返回Returns long
返回数值结果。Returns a numeric result.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:169–173

deleteKeys

public void deleteKeys(String... keys)

删除密钥。

Deletes the keys.

参数Parameters
名称Name类型Type说明Description
keys varargsString...密钥(类型 `String...`)。The keys.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:175–179

addToSet

public void addToSet(String key, String member)

添加到设置。

Adds the to set.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
memberString成员(类型 `String`)。The member.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:181–185

getSetMembers

public Set<String> getSetMembers(String key)

获取设置成员。

Returns the set members.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:187–191

getSetSize

public long getSetSize(String key)

获取设置大小。

Returns the set size.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
返回Returns long
返回数值结果。Returns a numeric result.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:193–197

keyExists

public boolean keyExists(String key)

设置该参数。

Performs the key exists operation.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:199–203

findKeysByPattern

public Set<String> findKeysByPattern(String pattern)

查找 findKeysByPattern。

Finds the keys by pattern.

参数Parameters
名称Name类型Type说明Description
patternStringpattern(类型 `String`)。The pattern.
返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:205–215

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/core/session/redis/redisson/RedissonClientAdapter.java:217–220
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.