cache_users

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceName    = "srv_cache_user"
	DefaultTTL     = 1 * time.Minute
	CacheKeyPrefix = "users"
)

Variables

View Source
var ErrCircuitOpen = errors.New("circuit breaker is open")

Functions

This section is empty.

Types

type CacheItem

type CacheItem struct {
	Users     []*pb.User // 共享池中的指针,多节点同 hash 时复用同一份切片
	Hash      string
	ExpiresIn time.Duration
	SetAt     time.Time
	// contains filtered or unexported fields
}

type GetUsersResult added in v0.1.0

type GetUsersResult struct {
	Users []*pb.User
	Hash  string
}

GetUsersResult 包含已解析的用户列表和当前 hash。 Users 为 nil 表示数据未变更(304 语义),由调用方据此返回 NotModified。

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(api *api.Client, ttl time.Duration) (*Service, error)

func (*Service) Destroy

func (s *Service) Destroy() error

func (*Service) GetUsers

func (s *Service) GetUsers(ctx context.Context, nodeId int32, nodeType api.NodeType, clientHash string) (*GetUsersResult, error)

func (*Service) Init

func (s *Service) Init() error

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

func (*Service) String

func (s *Service) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL