AS AgentScopeAPI 手册 / API Reference

IdempotencyStore

public final class IdempotencyStore implements InboundEventDeduplicator
源码Source io/agentscope/extensions/channel/common/IdempotencyStore.java:34–106

Idempotency 存储,负责持久化与读取数据。位于 io.agentscope.extensions.channel.common 包,实现 InboundEventDeduplicator。核心成员包括 firstSeen、size、IdempotencyStore。

Bounded in-process implementation of InboundEventDeduplicator. Webhook providers (notably WeCom) commonly retry the same message id under failure; this store de-duplicates by msgId.

Internal map is bounded to #maxEntries — when full, entries are evicted to make room: expired entries are dropped first, after which the victim is unspecified. Entries are also lazily expired after #ttlMillis.

State lives in the JVM heap, so deduplication only holds within a single process; see InboundEventDeduplicator for multi-instance deployments. This class is thread-safe.

构造器摘要Constructor Summary

构造器Constructor说明Description
public IdempotencyStore()
初始化 `IdempotencyStore` 实例。
Default 5-minute TTL, 10k entries — sufficient for any single channel's retry burst.
public IdempotencyStore(long ttlMillis, int maxEntries)
初始化 `IdempotencyStore` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public boolean firstSeen(String key)
设置该参数。
Records `key` as seen.
public int size()
返回大小。
Returns the current size; mostly for tests/observability.

构造器详情Constructor Detail

IdempotencyStore

public IdempotencyStore()

初始化 IdempotencyStore 实例。

Default 5-minute TTL, 10k entries — sufficient for any single channel's retry burst.

源码Source io/agentscope/extensions/channel/common/IdempotencyStore.java:41–43

IdempotencyStore

public IdempotencyStore(long ttlMillis, int maxEntries)

初始化 IdempotencyStore 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
ttlMillislong存活时间毫秒(类型 `long`)。The ttl millis.
maxEntriesint最大条目(类型 `int`)。The max entries.
源码Source io/agentscope/extensions/channel/common/IdempotencyStore.java:45–54

方法详情Method Detail

firstSeen

public boolean firstSeen(String key)

设置该参数。

Records key as seen.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/common/IdempotencyStore.java:62–78

size

public int size()

返回大小。

Returns the current size; mostly for tests/observability.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/channel/common/IdempotencyStore.java:103–105
基于官方固定版本源码静态生成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.