MCPcopy Create free account
hub / github.com/astercloud/aster / parseStateKey

Function parseStateKey

pkg/session/postgres/service.go:436–452  ·  view source on GitHub ↗

parseStateKey 解析状态键的作用域 例如: "app:version" -> ("app", "version") "user:preferences" -> ("user", "preferences") "simple_key" -> ("session", "simple_key")

(key string)

Source from the content-addressed store, hash-verified

434// "user:preferences" -> ("user", "preferences")
435// "simple_key" -> ("session", "simple_key")
436func parseStateKey(key string) (scope, actualKey string) {
437 parts := strings.SplitN(key, ":", 2)
438 if len(parts) == 2 {
439 // 有前缀
440 scope = parts[0]
441 actualKey = parts[1]
442
443 // 验证 scope 是否有效
444 switch scope {
445 case session.KeyPrefixApp, session.KeyPrefixUser, session.KeyPrefixTemp:
446 return scope, actualKey
447 }
448 }
449
450 // 默认为 session 作用域
451 return "session", key
452}

Callers 1

AppendEventMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected