Adding expiration times and interface for cached items
Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
This commit is contained in:
parent
2f328ec8ee
commit
03fbe92c7f
25
backend/internal/storage/cache/cache.go
vendored
25
backend/internal/storage/cache/cache.go
vendored
@ -2,17 +2,42 @@ package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.ewellenr.ca/receipt_indexer/backend/internal/storage"
|
||||
// auth_storage "git.ewellenr.ca/receipt_indexer/backend/internal/storage/auth"
|
||||
)
|
||||
|
||||
const (
|
||||
UserExpTime = time.Minute
|
||||
RolesExpTime = time.Minute
|
||||
GroupsExpTime = time.Minute
|
||||
UserGroupsExpTime = time.Minute
|
||||
ReceptsExpTime = time.Minute
|
||||
ReceiptImageExpTime = time.Minute
|
||||
)
|
||||
|
||||
type Storage struct {
|
||||
Users interface {
|
||||
Get(ctx context.Context, id int64) (*storage.User, error)
|
||||
Set(ctx context.Context, user *storage.User) error
|
||||
Delete(ctx context.Context, userID int64)
|
||||
}
|
||||
Roles interface {
|
||||
Get(ctx context.Context, name string) (*storage.Role, error)
|
||||
Set(ctx context.Context, role *storage.Role) error
|
||||
Delete(ctx context.Context, name string)
|
||||
}
|
||||
Groups interface {
|
||||
Get(ctx context.Context, name string) (*storage.Role, error)
|
||||
Set(ctx context.Context, role *storage.Role) error
|
||||
Delete(ctx context.Context, name string)
|
||||
}
|
||||
UserGroups interface {
|
||||
Get(ctx context.Context, userid int64) (*[]int64, error)
|
||||
Set(ctx context.Context, groups *[]int64) error
|
||||
Delete(ctx context.Context, userid int64)
|
||||
}
|
||||
Receipts interface {
|
||||
Get(ctx context.Context, id int64) (*storage.Receipt, error)
|
||||
Set(ctx context.Context, receipt *storage.Receipt) error
|
||||
|
||||
Loading…
Reference in New Issue
Block a user