session

package
v6.8.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get returns a session for given client ID, fingerprint, and offset.
	Get(uint64, uint64, time.Time) *model.Session

	// Put stores a session for given client ID and fingerprint.
	Put(uint64, uint64, *model.Session)

	// Clear clears the cache.
	Clear()

	// NewMutex creates a new mutex for given client ID and fingerprint.
	NewMutex(uint64, uint64) sync.Locker
}

Cache is a session cache.

type MemCache

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

MemCache caches sessions in memory. This does only make sense for non-distributed systems (tracking on a single machine/app).

func NewMemCache

func NewMemCache(client db.Store, maxSessions int) *MemCache

NewMemCache creates a new cache for given client and maximum size.

func (*MemCache) Clear

func (cache *MemCache) Clear()

Clear implements the Cache interface.

func (*MemCache) Get

func (cache *MemCache) Get(clientID, fingerprint uint64, maxAge time.Time) *model.Session

Get implements the Cache interface.

func (*MemCache) NewMutex

func (cache *MemCache) NewMutex(uint64, uint64) sync.Locker

NewMutex implements the Cache interface.

func (*MemCache) Put

func (cache *MemCache) Put(clientID, fingerprint uint64, session *model.Session)

Put implements the Cache interface.

func (*MemCache) Sessions

func (cache *MemCache) Sessions() map[string]model.Session

Sessions returns all sessions. This is insecure and should only be used for testing.

type RedisCache

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

RedisCache caches sessions in Redis.

func NewRedisCache

func NewRedisCache(maxAge time.Duration, log *slog.Logger, redisOptions *redis.Options) *RedisCache

NewRedisCache creates a new cache for given maximum age and redis connection.

func (*RedisCache) Clear

func (cache *RedisCache) Clear()

Clear implements the Cache interface.

func (*RedisCache) Get

func (cache *RedisCache) Get(clientID, fingerprint uint64, _ time.Time) *model.Session

Get implements the Cache interface.

func (*RedisCache) NewMutex

func (cache *RedisCache) NewMutex(clientID, fingerprint uint64) sync.Locker

NewMutex implements the Cache interface.

func (*RedisCache) Put

func (cache *RedisCache) Put(clientID, fingerprint uint64, session *model.Session)

Put implements the Cache interface.

type RedisMutex

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

RedisMutex wraps a redis mutex.

func (*RedisMutex) Lock

func (m *RedisMutex) Lock()

func (*RedisMutex) Unlock

func (m *RedisMutex) Unlock()

Jump to

Keyboard shortcuts

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