AS AgentScopeAPI 手册 / API Reference

JedisClientAdapter

public class JedisClientAdapter implements RedisClientAdapter
源码Source io/agentscope/extensions/redis/state/jedis/JedisClientAdapter.java:86–184

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

Adapter for Jedis Redis client.

This adapter supports all Jedis client types:

  • RedisClient - Standalone client

  • RedisClusterClient - Cluster client

  • RedisSentinelClient - Sentinel client

  • UnifiedJedis - Base unified interface

All new client types extend UnifiedJedis, providing a unified interface that handles different Redis deployment modes transparently.

Usage examples:

Using RedisClient (Standalone):

`// Create standalone client
RedisClient redisClient = RedisClient.create("redis://localhost:6379");

// Create adapter
JedisClientAdapter adapter = JedisClientAdapter.of(redisClient);
`

Using RedisClusterClient (Cluster):

`// Create cluster client
Set<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort("localhost", 7000));
nodes.add(new HostAndPort("localhost", 7001));
RedisClusterClient clusterClient = RedisClusterClient.create(nodes);

// Create adapter
JedisClientAdapter adapter = JedisClientAdapter.of(clusterClient);
`

Using RedisSentinelClient (Sentinel):

`// Create sentinel client
Set<String> sentinels = new HashSet<>();
sentinels.add("localhost:26379");
RedisSentinelClient sentinelClient = RedisSentinelClient.create("mymaster", sentinels);

// Create adapter
JedisClientAdapter adapter = JedisClientAdapter.of(sentinelClient);
`

Using UnifiedJedis (Direct):

`// Create any client type that extends UnifiedJedis
UnifiedJedis unifiedJedis = new RedisClient("redis://localhost:6379");

// Create adapter
JedisClientAdapter adapter = JedisClientAdapter.of(unifiedJedis);
`

方法摘要Method Summary

方法Method说明Description
public static JedisClientAdapter of(UnifiedJedis unifiedJedis)
static
创建适配器来自 UnifiedJedis。
Create adapter from UnifiedJedis.
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 long evalScript(String script, List<String> keys, List<String> args)
执行 `evalScript` 方法。
Performs the eval script operation.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.

方法详情Method Detail

of

public static JedisClientAdapter of(UnifiedJedis unifiedJedis)
static

创建适配器来自 UnifiedJedis。

Create adapter from UnifiedJedis.

参数Parameters
名称Name类型Type说明Description
unifiedJedisUnifiedJedis统一 Jedis(类型 `UnifiedJedis`)。the UnifiedJedis instance (any subclass)
返回Returns JedisClientAdapter
一种新的JedisClientAdapter。a new JedisClientAdapter
源码Source io/agentscope/extensions/redis/state/jedis/JedisClientAdapter.java:100–102

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/extensions/redis/state/jedis/JedisClientAdapter.java:104–107

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/extensions/redis/state/jedis/JedisClientAdapter.java:109–112

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/extensions/redis/state/jedis/JedisClientAdapter.java:114–117

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/extensions/redis/state/jedis/JedisClientAdapter.java:119–122

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/extensions/redis/state/jedis/JedisClientAdapter.java:124–127

deleteKeys

public void deleteKeys(String... keys)

删除密钥。

Deletes the keys.

参数Parameters
名称Name类型Type说明Description
keys varargsString...密钥(类型 `String...`)。The keys.
源码Source io/agentscope/extensions/redis/state/jedis/JedisClientAdapter.java:129–132

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/extensions/redis/state/jedis/JedisClientAdapter.java:134–137

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/extensions/redis/state/jedis/JedisClientAdapter.java:139–142

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/extensions/redis/state/jedis/JedisClientAdapter.java:144–147

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/extensions/redis/state/jedis/JedisClientAdapter.java:149–152

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/extensions/redis/state/jedis/JedisClientAdapter.java:154–169

evalScript

public long evalScript(String script, List<String> keys, List<String> args)

执行 evalScript 方法。

Performs the eval script operation.

参数Parameters
名称Name类型Type说明Description
scriptStringscript(类型 `String`)。The script.
keysList<String>密钥(类型 `List`)。The keys.
argsList<String>参数(类型 `List`)。The args.
返回Returns long
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/redis/state/jedis/JedisClientAdapter.java:171–178

close

public void close()

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

Releases resources and connections.

源码Source io/agentscope/extensions/redis/state/jedis/JedisClientAdapter.java:180–183
基于官方固定版本源码静态生成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.