cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyRepository

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

APIKeyRepository implements the apikey.Repository interface in order to implement caching

func (*APIKeyRepository) Create

func (repo *APIKeyRepository) Create(ctx context.Context, create *apikey.Create) (*apikey.Key, string, error)

Create creates a new API key

func (*APIKeyRepository) Delete

func (repo *APIKeyRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes an API key by its ID

func (*APIKeyRepository) Get

func (repo *APIKeyRepository) Get(ctx context.Context, offset, limit uint64) ([]*apikey.Key, uint64, error)

Get retrieves multiple API keys

func (*APIKeyRepository) GetByID

func (repo *APIKeyRepository) GetByID(ctx context.Context, id uuid.UUID) (*apikey.Key, error)

GetByID retrieves an API key by its ID

func (*APIKeyRepository) GetByRawKey

func (repo *APIKeyRepository) GetByRawKey(ctx context.Context, key string) (*apikey.Key, error)

GetByRawKey retrieves an API key by the raw bearer token

func (*APIKeyRepository) GetByUserID

func (repo *APIKeyRepository) GetByUserID(ctx context.Context, userID string, offset, limit uint64) ([]*apikey.Key, uint64, error)

GetByUserID retrieves multiple API keys of a specific user

func (*APIKeyRepository) Update

func (repo *APIKeyRepository) Update(ctx context.Context, id uuid.UUID, update *apikey.Update) (*apikey.Key, error)

Update updates an API key

func (*APIKeyRepository) UpdateManyQuotas

func (repo *APIKeyRepository) UpdateManyQuotas(ctx context.Context, updates map[uuid.UUID]int64) error

UpdateManyQuotas updates many used API quotas at once

type Driver

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

Driver represents a storage driver implementation that wraps another one in order to implement in-memory caching

func New

func New(underlying storage.Driver) *Driver

New returns a new caching storage driver

func (*Driver) APIKeys

func (driver *Driver) APIKeys() apikey.Repository

APIKeys provides the caching API key repository implementation

func (*Driver) Close

func (driver *Driver) Close()

Close closes the caching repositories and disposes their instances

func (*Driver) Initialize

func (driver *Driver) Initialize(_ context.Context) error

Initialize initializes the caching repositories

func (*Driver) METARs

func (driver *Driver) METARs() metar.Repository

METARs provides the caching METAR repository implementation

func (*Driver) Users

func (driver *Driver) Users() user.Repository

Users provides the caching user repository implementation

type METARRepository

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

METARRepository implements the metar.Repository interface in order to implement caching

func (*METARRepository) Create

func (repo *METARRepository) Create(ctx context.Context, raw []string) ([]*metar.METAR, []uint, error)

Create creates new METARs based on their raw text representation. All raw strings are sanitized (leading and trailing spaces are trimmed). This method also returns the indexes of the METARs that already exist in the database and thus were not inserted.

func (*METARRepository) Delete

func (repo *METARRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a METAR by its ID

func (*METARRepository) GetByFilter

func (repo *METARRepository) GetByFilter(ctx context.Context, filter *metar.Filter, limit uint64) ([]*metar.METAR, uint64, error)

GetByFilter retrieves multiple METARs following a filter, ordered by their issuing date (descending). If limit <= 0, a default limit value of 10 is used.

func (*METARRepository) GetByID

func (repo *METARRepository) GetByID(ctx context.Context, id uuid.UUID) (*metar.METAR, error)

GetByID retrieves a METAR by its ID

type UserRepository

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

UserRepository implements the user.Repository interface in order to implement caching

func (*UserRepository) Create

func (repo *UserRepository) Create(ctx context.Context, create *user.Create) (*user.User, error)

Create creates a new user

func (*UserRepository) Delete

func (repo *UserRepository) Delete(ctx context.Context, id string) error

Delete deletes a user by their ID

func (*UserRepository) Get

func (repo *UserRepository) Get(ctx context.Context, offset, limit uint64) ([]*user.User, uint64, error)

Get retrieves multiple users

func (*UserRepository) GetByID

func (repo *UserRepository) GetByID(ctx context.Context, id string) (*user.User, error)

GetByID retrieves a user by their ID

func (*UserRepository) Update

func (repo *UserRepository) Update(ctx context.Context, id string, update *user.Update) (*user.User, error)

Update updates an existing user

Jump to

Keyboard shortcuts

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