cached

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionRepository

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

SessionRepository wraps a session repository with secondary storage caching It caches session lookups by token to reduce database load

func NewSessionRepository

func NewSessionRepository(
	primary session.Repository,
	secondary storage.SecondaryStorage,
) *SessionRepository

NewSessionRepository creates a new cached session repository

func (*SessionRepository) Count

func (r *SessionRepository) Count() (int, error)

Count returns the total number of sessions

func (*SessionRepository) Create

func (r *SessionRepository) Create(sess *session.Session) error

Create creates a new session and caches it

func (*SessionRepository) Delete

func (r *SessionRepository) Delete(id string) error

Delete deletes a session by ID and removes from cache

func (*SessionRepository) DeleteByUserID

func (r *SessionRepository) DeleteByUserID(userID string) error

DeleteByUserID deletes all sessions for a user

func (*SessionRepository) DeleteExpired

func (r *SessionRepository) DeleteExpired() error

DeleteExpired deletes all expired sessions

func (*SessionRepository) ExistsByID

func (r *SessionRepository) ExistsByID(id string) (bool, error)

ExistsByID checks if a session exists by ID

func (*SessionRepository) ExistsByToken

func (r *SessionRepository) ExistsByToken(token string) (bool, error)

ExistsByToken checks if a session exists by token, checking cache first

func (*SessionRepository) FindByID

func (r *SessionRepository) FindByID(id string) (*session.Session, error)

FindByID retrieves a session by ID from primary storage

func (*SessionRepository) FindByToken

func (r *SessionRepository) FindByToken(token string) (*session.Session, error)

FindByToken retrieves a session by token, checking cache first

func (*SessionRepository) FindByUserID

func (r *SessionRepository) FindByUserID(userID string) ([]*session.Session, error)

FindByUserID retrieves all sessions for a user from primary storage

func (*SessionRepository) Update

func (r *SessionRepository) Update(sess *session.Session) error

Update updates an existing session and updates cache

Jump to

Keyboard shortcuts

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