Documentation
¶
Index ¶
- type Lock
- func (l *Lock) Acquire(ctx context.Context, name string, ttl time.Duration) (bool, error)
- func (l *Lock) Extend(ctx context.Context, name string, ttl time.Duration) error
- func (l *Lock) OwnerID() string
- func (l *Lock) Ping(ctx context.Context) error
- func (l *Lock) Release(ctx context.Context, name string) error
- type SessionStore
- func (s *SessionStore) Delete(ctx context.Context, id string) error
- func (s *SessionStore) DeleteByToken(ctx context.Context, token string) error
- func (s *SessionStore) DeleteByUser(ctx context.Context, userID string) error
- func (s *SessionStore) Get(ctx context.Context, id string) (*domain.Session, error)
- func (s *SessionStore) GetByRefreshToken(ctx context.Context, refreshToken string) (*domain.Session, error)
- func (s *SessionStore) GetByToken(ctx context.Context, token string) (*domain.Session, error)
- func (s *SessionStore) ListByUser(ctx context.Context, userID string) ([]*domain.Session, error)
- func (s *SessionStore) Save(ctx context.Context, session *domain.Session) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock implements DistributedLock using Redis SETNX with TTL. It uses a unique owner ID to prevent accidental release by other instances.
func NewLock ¶
NewLock creates a new Redis-backed distributed lock. The owner ID is automatically generated to uniquely identify this instance.
func (*Lock) Acquire ¶
Acquire attempts to acquire a named lock with the given TTL. Uses Redis SETNX (SET if Not eXists) for atomic lock acquisition. Returns true if acquired, false if already held by another instance.
func (*Lock) Extend ¶
Extend extends the TTL of a currently held lock. Returns error if the lock is not held by this instance.
func (*Lock) OwnerID ¶
OwnerID returns the unique identifier for this lock instance. Useful for debugging and logging.
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore implements driven.SessionStore using Redis Sessions use Redis TTL for automatic expiration
func NewSessionStore ¶
func NewSessionStore(client *redis.Client) *SessionStore
NewSessionStore creates a new Redis-backed SessionStore
func (*SessionStore) Delete ¶
func (s *SessionStore) Delete(ctx context.Context, id string) error
Delete deletes a session
func (*SessionStore) DeleteByToken ¶
func (s *SessionStore) DeleteByToken(ctx context.Context, token string) error
DeleteByToken deletes a session by token
func (*SessionStore) DeleteByUser ¶
func (s *SessionStore) DeleteByUser(ctx context.Context, userID string) error
DeleteByUser deletes all sessions for a user (logout everywhere)
func (*SessionStore) GetByRefreshToken ¶
func (s *SessionStore) GetByRefreshToken(ctx context.Context, refreshToken string) (*domain.Session, error)
GetByRefreshToken retrieves a session by refresh token value
func (*SessionStore) GetByToken ¶
GetByToken retrieves a session by token value
func (*SessionStore) ListByUser ¶
ListByUser lists all active sessions for a user