Documentation
¶
Index ¶
- type Cache
- type CacheManager
- type CacheOptions
- type InMemoryCache
- func (c *InMemoryCache) Checksum() string
- func (c *InMemoryCache) Class() string
- func (c *InMemoryCache) Delete(ctx context.Context, key string) error
- func (c *InMemoryCache) Get(ctx context.Context, key string) (string, bool, bool, error)
- func (c *InMemoryCache) GetAndDelete(ctx context.Context, key string) (string, bool, bool, error)
- func (c *InMemoryCache) Host() string
- func (c *InMemoryCache) Set(ctx context.Context, key string, value string, opts ...SetOption) error
- func (c *InMemoryCache) TTL() time.Duration
- func (c *InMemoryCache) Uncycled() bool
- type InMemoryCacheManager
- type SetOption
- type SetOptions
- type ValkeyCache
- func (s *ValkeyCache) Checksum() string
- func (s *ValkeyCache) Class() string
- func (s *ValkeyCache) Delete(ctx context.Context, key string) error
- func (s *ValkeyCache) Get(ctx context.Context, key string) (string, bool, bool, error)
- func (s *ValkeyCache) GetAndDelete(ctx context.Context, key string) (string, bool, bool, error)
- func (s *ValkeyCache) Host() string
- func (s *ValkeyCache) Set(ctx context.Context, key string, value string, opts ...SetOption) error
- func (s *ValkeyCache) TTL() time.Duration
- func (s *ValkeyCache) Uncycled() bool
- type ValkeyCacheManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
Checksum() string
Class() string
Delete(ctx context.Context, key string) error
Get(ctx context.Context, key string) (value string, exists bool, isCurrent bool, err error)
// GetAndDelete atomically reads and removes the entry for key,
// returning whether it existed. The primitive is needed to close
// the concurrent-redeem race in auth-code / refresh-token rotation
// (kdex-tech/host-manager#71): two concurrent callers that race on
// the same key must observe exactly one winner (found=true) and
// N-1 losers (found=false). Implementations that don't natively
// expose an atomic GETDEL must guard with their own lock.
GetAndDelete(ctx context.Context, key string) (value string, exists bool, isCurrent bool, err error)
Host() string
Set(ctx context.Context, key string, value string, opts ...SetOption) error
TTL() time.Duration
Uncycled() bool
}
type CacheManager ¶
type CacheManager interface {
Cycle(checksum string, force bool) error
GetCache(class string, opts CacheOptions) Cache
}
func NewCacheManager ¶
func NewCacheManager(addr, host string, ttl *time.Duration) (CacheManager, error)
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
func (*InMemoryCache) Checksum ¶ added in v0.2.7
func (c *InMemoryCache) Checksum() string
func (*InMemoryCache) Class ¶
func (c *InMemoryCache) Class() string
func (*InMemoryCache) Delete ¶
func (c *InMemoryCache) Delete(ctx context.Context, key string) error
func (*InMemoryCache) GetAndDelete ¶ added in v0.2.92
GetAndDelete atomically reads and removes the entry. Implementation: run the same Get walk and, on a hit, evict the entry before releasing the lock. The single c.mu.Lock around both halves is what makes this the contract-required single-winner primitive. See kdex-tech/host-manager#71.
func (*InMemoryCache) Host ¶
func (c *InMemoryCache) Host() string
func (*InMemoryCache) TTL ¶
func (c *InMemoryCache) TTL() time.Duration
func (*InMemoryCache) Uncycled ¶
func (c *InMemoryCache) Uncycled() bool
type InMemoryCacheManager ¶
type InMemoryCacheManager struct {
// contains filtered or unexported fields
}
func (*InMemoryCacheManager) Cycle ¶
func (m *InMemoryCacheManager) Cycle(checksum string, force bool) error
func (*InMemoryCacheManager) GetCache ¶
func (m *InMemoryCacheManager) GetCache(class string, opts CacheOptions) Cache
type SetOption ¶ added in v0.2.30
type SetOption func(*SetOptions)
type SetOptions ¶ added in v0.2.30
type ValkeyCache ¶
type ValkeyCache struct {
// contains filtered or unexported fields
}
func (*ValkeyCache) Checksum ¶ added in v0.2.7
func (s *ValkeyCache) Checksum() string
func (*ValkeyCache) Class ¶
func (s *ValkeyCache) Class() string
func (*ValkeyCache) GetAndDelete ¶ added in v0.2.92
GetAndDelete atomically reads and removes the entry. Backed by Valkey's GETDEL primitive (single round-trip, server-side atomic), so two concurrent callers racing on the same key always produce exactly one winner. See kdex-tech/host-manager#71.
func (*ValkeyCache) Host ¶
func (s *ValkeyCache) Host() string
func (*ValkeyCache) TTL ¶
func (s *ValkeyCache) TTL() time.Duration
func (*ValkeyCache) Uncycled ¶
func (s *ValkeyCache) Uncycled() bool
type ValkeyCacheManager ¶
type ValkeyCacheManager struct {
// contains filtered or unexported fields
}
func (*ValkeyCacheManager) Cycle ¶
func (m *ValkeyCacheManager) Cycle(checksum string, force bool) error
func (*ValkeyCacheManager) GetCache ¶
func (m *ValkeyCacheManager) GetCache(class string, opts CacheOptions) Cache