cache

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver is a database handler proxy for caching

func MakeRedisDriver

func MakeRedisDriver(dbh ProxiedHandler, log slog.Instance) *Driver

MakeRedisDriver creates a Redis Caching layer for the specified handler It also implements the Token mechanics (it does not pass to the underlying handler)

func (*Driver) AddGPGKey

func (h *Driver) AddGPGKey(key models.GPGKey) (string, bool, error)

AddGPGKey adds a GPG Key to the database or update an existing one by fingerprint Returns generated id / hasBeenAdded / error

func (*Driver) AddGPGKeys

func (h *Driver) AddGPGKeys(keys []models.GPGKey) ([]string, []bool, error)

AddGPGKey adds a list GPG Key to the database or update an existing one by fingerprint Same as AddGPGKey but in a single transaction

func (*Driver) AddUser

func (h *Driver) AddUser(um models.User) (string, error)

AddUser adds a user in the database if not exists

func (*Driver) AddUserToken

func (h *Driver) AddUserToken(ut models.UserToken) (string, error)

AddUserToken adds a new user token to be valid and returns its token ID

func (*Driver) DeleteGPGKey

func (h *Driver) DeleteGPGKey(key models.GPGKey) error

DeleteGPGKey deletes the specified GPG key by using it's ID

func (*Driver) FetchGPGKeyByFingerprint

func (h *Driver) FetchGPGKeyByFingerprint(fingerprint string) (*models.GPGKey, error)

FetchGPGKeyByFingerprint fetch a GPG Key by its fingerprint

func (*Driver) FetchGPGKeysWithoutSubKeys

func (h *Driver) FetchGPGKeysWithoutSubKeys() (res []models.GPGKey, err error)

FetchGPGKeysWithoutSubKeys fetch all keys that does not have a subkey This query is not implemented on PostgreSQL

func (*Driver) FindGPGKeyByEmail

func (h *Driver) FindGPGKeyByEmail(email string, pageStart, pageEnd int) (res []models.GPGKey, err error)

FindGPGKeyByEmail find all keys that has a underlying UID that contains that email

func (*Driver) FindGPGKeyByFingerPrint

func (h *Driver) FindGPGKeyByFingerPrint(fingerPrint string, pageStart, pageEnd int) ([]models.GPGKey, error)

FindGPGKeyByFingerPrint find all keys that has a fingerprint that matches the specified fingerprint

func (*Driver) FindGPGKeyByName

func (h *Driver) FindGPGKeyByName(name string, pageStart, pageEnd int) ([]models.GPGKey, error)

FindGPGKeyByName find all keys that has a underlying UID that contains that name

func (*Driver) FindGPGKeyByValue

func (h *Driver) FindGPGKeyByValue(value string, pageStart, pageEnd int) ([]models.GPGKey, error)

FindGPGKeyByValue find all keys that has a underlying UID that contains that email, name or fingerprint specified by value

func (*Driver) FinishCursor

func (h *Driver) FinishCursor() error

func (*Driver) GetUser

func (h *Driver) GetUser(username string) (um *models.User, err error)

GetUser fetchs a user from the database by it's username

func (*Driver) GetUserToken

func (h *Driver) GetUserToken(token string) (ut *models.UserToken, err error)

GetUserToken fetch a UserToken object by the specified token

func (*Driver) HealthCheck

func (h *Driver) HealthCheck() error

HealthCheck returns nil if everything is OK with the handler

func (*Driver) InitCursor

func (h *Driver) InitCursor() error

func (*Driver) InvalidateUserTokens

func (h *Driver) InvalidateUserTokens() (int, error)

InvalidateUserTokens removes all user tokens that had been already expired Does nothing on REDIS due automatic expiration using TTL

func (*Driver) NextGPGKey

func (h *Driver) NextGPGKey(key *models.GPGKey) bool

func (*Driver) NextUser

func (h *Driver) NextUser(user *models.User) bool

func (*Driver) NumGPGKeys

func (h *Driver) NumGPGKeys() (int, error)

func (*Driver) RemoveUserToken

func (h *Driver) RemoveUserToken(token string) (err error)

RemoveUserToken removes a user token from the database

func (*Driver) Setup

func (h *Driver) Setup(client rediser, maxLocalObjects int, localObjectTTL time.Duration) error

Setup configures the RedisDriver connection and cache ring

func (*Driver) UpdateGPGKey

func (h *Driver) UpdateGPGKey(key models.GPGKey) (err error)

UpdateGPGKey updates the specified GPG key by using it's ID

func (*Driver) UpdateUser

func (h *Driver) UpdateUser(um models.User) error

UpdateUser updates user fingerprint, password and / or fullname by it's ID

type ProxiedGPGRepository

type ProxiedGPGRepository interface {
	// AddGPGKey adds a GPG Key to the database or update an existing one by fingerprint
	// Returns generated id / hasBeenAdded / error
	AddGPGKey(key models.GPGKey) (string, bool, error)
	// AddGPGKey adds a list GPG Key to the database or update an existing one by fingerprint
	// Same as AddGPGKey but in a single transaction
	AddGPGKeys(keys []models.GPGKey) (ids []string, addeds []bool, err error)
	// FindGPGKeyByEmail find all keys that has a underlying UID that contains that email
	FindGPGKeyByEmail(email string, pageStart, pageEnd int) ([]models.GPGKey, error)
	// FindGPGKeyByFingerPrint find all keys that has a fingerprint that matches the specified fingerprint
	FindGPGKeyByFingerPrint(fingerPrint string, pageStart, pageEnd int) ([]models.GPGKey, error)
	// FindGPGKeyByValue find all keys that has a underlying UID that contains that email, name or fingerprint specified by value
	FindGPGKeyByValue(value string, pageStart, pageEnd int) ([]models.GPGKey, error)
	// FindGPGKeyByName find all keys that has a underlying UID that contains that name
	FindGPGKeyByName(name string, pageStart, pageEnd int) ([]models.GPGKey, error)
	// FetchGPGKeyByFingerprint fetch a GPG Key by its fingerprint
	FetchGPGKeyByFingerprint(fingerprint string) (*models.GPGKey, error)
	// FetchGPGKeysWithoutSubKeys fetch all keys that does not have a subkey
	// This query is not implemented on PostgreSQL
	FetchGPGKeysWithoutSubKeys() (res []models.GPGKey, err error)
	// DeleteGPGKey deletes the specified GPG key by using it's ID
	DeleteGPGKey(key models.GPGKey) error
	// UpdateGPGKey updates the specified GPG key by using it's ID
	UpdateGPGKey(key models.GPGKey) (err error)
}

ProxiedUserRepository a proxy to a GPG Repository

type ProxiedHandler

ProxiedHandler is a handler to be proxied by REDIS caching

type ProxiedHealthChecker

type ProxiedHealthChecker interface {
	// HealthCheck returns nil if everything is OK with the handler
	HealthCheck() error
}

ProxiedUserRepository a proxy to a Health Checker

type ProxiedMigrationHandler

type ProxiedMigrationHandler interface {
	InitCursor() error
	FinishCursor() error
	NextGPGKey(key *models.GPGKey) bool
	NextUser(user *models.User) bool
	NumGPGKeys() (int, error)
}

ProxiedMigrationHandler

type ProxiedUserRepository

type ProxiedUserRepository interface {
	GetUser(username string) (um *models.User, err error)
	// AddUserToken adds a new user token to be valid and returns its token ID
	AddUserToken(ut models.UserToken) (string, error)
	// RemoveUserToken removes a user token from the database
	RemoveUserToken(token string) (err error)
	// GetUserToken fetch a UserToken object by the specified token
	GetUserToken(token string) (ut *models.UserToken, err error)
	// InvalidateUserTokens removes all user tokens that had been already expired
	InvalidateUserTokens() (int, error)
	AddUser(um models.User) (string, error)
	UpdateUser(um models.User) error
}

ProxiedUserRepository a proxy to a User Repository

Jump to

Keyboard shortcuts

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