Files
xinghuoapi/backend/internal/service/gemini_token_cache.go
ianshaw 85fd1e4a2c fix(backend): 移除对已删除 ports 包的依赖
适配 main 分支的 ports 目录删除重构:
- 将 ports 包中的接口移至 service 包
- 更新 repository 层的导入路径
2025-12-26 00:11:03 -08:00

17 lines
600 B
Go

package service
import (
"context"
"time"
)
// GeminiTokenCache stores short-lived access tokens and coordinates refresh to avoid stampedes.
type GeminiTokenCache interface {
// cacheKey should be stable for the token scope; for GeminiCli OAuth we primarily use project_id.
GetAccessToken(ctx context.Context, cacheKey string) (string, error)
SetAccessToken(ctx context.Context, cacheKey string, token string, ttl time.Duration) error
AcquireRefreshLock(ctx context.Context, cacheKey string, ttl time.Duration) (bool, error)
ReleaseRefreshLock(ctx context.Context, cacheKey string) error
}