Documentation ¶
Index ¶
- type APISession
- type Cache
- func (p *Cache) Close() error
- func (p *Cache) Delete(ctx context.Context, sessionID int64) error
- func (p *Cache) DeleteAllByUser(ctx context.Context, username string) (err error)
- func (p *Cache) DeleteByID(ctx context.Context, username string, sessionID int64) (err error)
- func (p *Cache) DeleteExpired(ctx context.Context) error
- func (p *Cache) Get(ctx context.Context, sessionID int64) (*APISession, error)
- func (p *Cache) GetAllByUser(ctx context.Context, username string) (sessions []*APISession, err error)
- func (p *Cache) Save(ctx context.Context, session *APISession) (sessionID int64, err error)
- type CleanupTask
- type InternalCacheProvider
- type SqliteProvider
- func (p *SqliteProvider) Close() error
- func (p *SqliteProvider) Delete(ctx context.Context, sessionID int64) error
- func (p *SqliteProvider) DeleteAllByUser(ctx context.Context, username string) (err error)
- func (p *SqliteProvider) DeleteByID(ctx context.Context, username string, sessionID int64) (err error)
- func (p *SqliteProvider) DeleteExpired(ctx context.Context) error
- func (p *SqliteProvider) Get(ctx context.Context, sessionID int64) (*APISession, error)
- func (p *SqliteProvider) GetAll(ctx context.Context) ([]*APISession, error)
- func (p *SqliteProvider) Save(ctx context.Context, session *APISession) (sessionID int64, err error)
- type StorageProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APISession ¶
type APISession struct { SessionID int64 `json:"session_id" db:"session_id"` ExpiresAt time.Time `json:"expires_at" db:"expires_at"` LastAccessAt time.Time `json:"last_access_at" db:"last_access_at"` Username string `json:"username" db:"username"` UserAgent string `json:"user_agent" db:"user_agent"` IPAddress string `json:"ip_address" db:"ip_address"` }
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
func NewCache( ctx context.Context, defaultExpiration, cleanupInterval time.Duration, storage StorageProvider, c InternalCacheProvider, ) (*Cache, error)
func (*Cache) DeleteAllByUser ¶
func (*Cache) DeleteByID ¶
func (*Cache) GetAllByUser ¶
type CleanupTask ¶
type CleanupTask struct {
// contains filtered or unexported fields
}
func NewCleanupTask ¶
func NewCleanupTask(c *Cache) *CleanupTask
type InternalCacheProvider ¶
type InternalCacheProvider interface { Set(k string, x interface{}, d time.Duration) Get(k string) (interface{}, bool) Delete(k string) ItemCount() int // using `cache.Item` creates a interface dependency on go-cache but currently // not worth de-coupling. if alternative cache implementations are required then // deal with this then. Items() map[string]cache.Item }
current implementation provided by go-cache
type SqliteProvider ¶
type SqliteProvider struct {
// contains filtered or unexported fields
}
func NewSqliteProvider ¶
func NewSqliteProvider(dbPath string, dataSourceOptions sqlite.DataSourceOptions) (*SqliteProvider, error)
func (*SqliteProvider) Close ¶
func (p *SqliteProvider) Close() error
func (*SqliteProvider) Delete ¶
func (p *SqliteProvider) Delete(ctx context.Context, sessionID int64) error
func (*SqliteProvider) DeleteAllByUser ¶
func (p *SqliteProvider) DeleteAllByUser(ctx context.Context, username string) (err error)
func (*SqliteProvider) DeleteByID ¶
func (*SqliteProvider) DeleteExpired ¶
func (p *SqliteProvider) DeleteExpired(ctx context.Context) error
func (*SqliteProvider) Get ¶
func (p *SqliteProvider) Get(ctx context.Context, sessionID int64) (*APISession, error)
func (*SqliteProvider) GetAll ¶
func (p *SqliteProvider) GetAll(ctx context.Context) ([]*APISession, error)
func (*SqliteProvider) Save ¶
func (p *SqliteProvider) Save(ctx context.Context, session *APISession) (sessionID int64, err error)
type StorageProvider ¶
type StorageProvider interface { Get(ctx context.Context, sessionID int64) (*APISession, error) GetAll(ctx context.Context) ([]*APISession, error) Save(ctx context.Context, session *APISession) (sessionID int64, err error) Delete(ctx context.Context, sessionID int64) error DeleteExpired(ctx context.Context) error Close() error DeleteAllByUser(ctx context.Context, username string) (err error) DeleteByID(ctx context.Context, username string, sessionID int64) (err error) }
Click to show internal directories.
Click to hide internal directories.