cache

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SubNamespace is the plugin sub-namespace within GoModularAuth cache keys.
	SubNamespace = "anonymous"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache wraps the core cache adapter for anonymous identity caching.

func New

func New(core corecache.Cache) *Cache

New creates a new Cache wrapper. If core is nil, the cache operates in no-op/degraded mode.

func (*Cache) Available

func (c *Cache) Available() bool

Available reports whether a backing cache is configured.

func (*Cache) DeleteIdentity

func (c *Cache) DeleteIdentity(ctx context.Context, userID string) error

DeleteIdentity invalidates the cached anonymous identity for a user.

func (*Cache) GetIdentity

func (c *Cache) GetIdentity(ctx context.Context, userID string) (*CachedIdentity, error)

GetIdentity retrieves an anonymous identity from cache by Core User ID.

func (*Cache) SetIdentity

func (c *Cache) SetIdentity(ctx context.Context, id *CachedIdentity, ttl time.Duration) error

SetIdentity stores an anonymous identity in cache with a TTL.

type CachedIdentity

type CachedIdentity struct {
	ID           string            `json:"id"`
	UserID       string            `json:"user_id"`
	ExpiresAt    time.Time         `json:"expires_at"`
	ConvertedAt  *time.Time        `json:"converted_at,omitempty"`
	LinkedUserID string            `json:"linked_user_id,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
	CreatedAt    time.Time         `json:"created_at"`
	UpdatedAt    time.Time         `json:"updated_at"`
}

CachedIdentity represents the cached anonymous identity.

func (*CachedIdentity) Converted

func (i *CachedIdentity) Converted() bool

Converted reports whether the identity has been converted.

func (*CachedIdentity) Expired

func (i *CachedIdentity) Expired(now time.Time) bool

Expired reports whether the cached identity has expired.

func (*CachedIdentity) IsActive

func (i *CachedIdentity) IsActive(now time.Time) bool

IsActive reports whether the identity is active.

Jump to

Keyboard shortcuts

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