Documentation
¶
Index ¶
- Variables
- func LockedReadThrough[T any](ctx context.Context, opts LockedReadThroughOptions[T]) (*T, error)
- func ReadThrough[T any](ctx context.Context, opts ReadThroughOptions[T]) (*T, error)
- type BackendKind
- type DataRole
- type Family
- type FamilyDescriptor
- type FamilyPolicy
- type GovernanceCapability
- type LockedReadThroughOptions
- type ReadThroughOptions
- type RedisDataType
- type ValueCodecKind
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMissingReadThroughGet = errors.New("cache read-through get function is required") ErrMissingReadThroughLoad = errors.New("cache read-through load function is required") ErrMissingReadThroughLock = errors.New("cache locked read-through lock function is required") ErrLockNotAcquired = errors.New("cache lock not acquired") )
Functions ¶
func LockedReadThrough ¶
func LockedReadThrough[T any](ctx context.Context, opts LockedReadThroughOptions[T]) (*T, error)
LockedReadThrough 执行带短租约的缓存读穿透流程。
func ReadThrough ¶
func ReadThrough[T any](ctx context.Context, opts ReadThroughOptions[T]) (*T, error)
ReadThrough 执行缓存 hit -> load -> set 的最小流程。
Types ¶
type BackendKind ¶
type BackendKind string
BackendKind 表示缓存后端类型。
const ( BackendKindRedis BackendKind = "redis" BackendKindMemory BackendKind = "memory" )
type Family ¶
type Family string
Family 表示 IAM 中一个稳定的缓存族标识。
const ( FamilyAuthnRefreshToken Family = "authn.refresh_token" FamilyAuthnRevokedAccessToken Family = "authn.revoked_access_token" FamilyAuthnSession Family = "authn.session" FamilyAuthnUserSessionIndex Family = "authn.user_session_index" FamilyAuthnAccountSessionIndex Family = "authn.account_session_index" FamilyAuthnLoginOTP Family = "authn.login_otp" FamilyAuthnLoginOTPSendGate Family = "authn.login_otp_send_gate" FamilyIDPWechatAccessToken Family = "idp.wechat_access_token" FamilyIDPWechatSDK Family = "idp.wechat_sdk" FamilyAuthnJWKSPublishSnapshot Family = "authn.jwks_publish_snapshot" )
type FamilyDescriptor ¶
type FamilyDescriptor struct {
Family Family
Backend BackendKind
RedisType RedisDataType
Codec ValueCodecKind
Role DataRole
OwnerModule string
KeyPattern string
TTLSource string
SelectionReason string
Policy FamilyPolicy
Capabilities []GovernanceCapability
}
FamilyDescriptor 描述一个缓存族的治理元数据。
func GetFamily ¶
func GetFamily(family Family) (FamilyDescriptor, bool)
GetFamily 返回指定 family 的静态描述。
type FamilyPolicy ¶
type FamilyPolicy struct {
TTLSource string
WriteMode string
InvalidationMode string
HasInternalRefreshCoordination bool
}
FamilyPolicy 描述某个缓存族的静态策略。
type GovernanceCapability ¶
type GovernanceCapability string
GovernanceCapability 表示治理面对 family 暴露的能力。
const (
GovernanceCapabilityInspect GovernanceCapability = "inspect"
)
type LockedReadThroughOptions ¶
type LockedReadThroughOptions[T any] struct { ReadThroughOptions[T] Lock func(context.Context) (ok bool, unlock func(), err error) RereadUsable func(*T) bool LockMissError error }
LockedReadThroughOptions 在 ReadThrough 基础上增加短租约协调。
type ReadThroughOptions ¶
type ReadThroughOptions[T any] struct { Get func(context.Context) (*T, error) Valid func(*T) bool Load func(context.Context) (*T, error) TTL func(*T) time.Duration Set func(context.Context, *T, time.Duration) error IgnoreGetError bool }
ReadThroughOptions 描述一次最小缓存读穿透流程。
type RedisDataType ¶
type RedisDataType string
RedisDataType 表示治理面视角下的 Redis 数据结构。
const ( RedisDataTypeNone RedisDataType = "none" RedisDataTypeString RedisDataType = "string" RedisDataTypeHash RedisDataType = "hash" RedisDataTypeSet RedisDataType = "set" RedisDataTypeZSet RedisDataType = "zset" )
type ValueCodecKind ¶
type ValueCodecKind string
ValueCodecKind 表示 family 的 value 编码方式。
const ( ValueCodecKindMemoryObject ValueCodecKind = "memory_object" ValueCodecKindJSON ValueCodecKind = "json" ValueCodecKindMarker ValueCodecKind = "marker" ValueCodecKindString ValueCodecKind = "string" ValueCodecKindLeaseToken ValueCodecKind = "lease_token" )
Click to show internal directories.
Click to hide internal directories.