记录类 SimpleSessionKey

java.lang.Object
java.lang.Record
io.agentscope.core.state.SimpleSessionKey
记录组件:
sessionId - the unique session identifier string
所有已实现的接口:
SessionKey

public record SimpleSessionKey(String sessionId) extends Record implements SessionKey
Default simple session identifier implementation using a single string.

This is the recommended session key for most use cases where a simple string identifier is sufficient.

Example usage:


 SessionKey sessionKey = SimpleSessionKey.of("user_123");
 agent.loadIfExists(session, sessionKey);
 agent.saveTo(session, sessionKey);
 
另请参阅:
  • 构造器详细资料

    • SimpleSessionKey

      public SimpleSessionKey(String sessionId)
      Creates a SimpleSessionKey with validation.
      参数:
      sessionId - the session identifier (must not be null or blank)
  • 方法详细资料

    • of

      public static SimpleSessionKey of(String sessionId)
      Factory method to create a SimpleSessionKey.
      参数:
      sessionId - the session identifier
      返回:
      a new SimpleSessionKey instance
    • toIdentifier

      public String toIdentifier()
      从接口复制的说明: SessionKey
      Returns a string identifier for this session key.

      This method is used by Session implementations to convert the session key to a string suitable for storage (e.g., as a directory name, database key, or Redis key prefix).

      The default implementation uses JSON serialization. Implementations like SimpleSessionKey override this to return the session ID directly for better readability.

      指定者:
      toIdentifier 在接口中 SessionKey
      返回:
      a string identifier for this session key
    • toString

      public String toString()
      返回此记录类的字符串表示形式。此表示形式包含类的名称,后跟每个记录组件的名称和值。
      指定者:
      toString 在类中 Record
      返回:
      此对象的字符串表示形式
    • hashCode

      public final int hashCode()
      返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。
      指定者:
      hashCode 在类中 Record
      返回:
      此对象的哈希代码值
    • equals

      public final boolean equals(Object o)
      指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 此记录类中的所有组件都使用 Objects::equals(Object,Object) 进行比较。
      指定者:
      equals 在类中 Record
      参数:
      o - 要与之进行比较的对象
      返回:
      如果此对象与 o 参数相同,则为 true;否则为 false
    • sessionId

      public String sessionId()
      返回 sessionId 记录组件的值。
      返回:
      sessionId 记录组件的值