35 lines
905 B
Go
35 lines
905 B
Go
package biz
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type SystemRepo interface {
|
|
InitializationRepo
|
|
UserRepo
|
|
}
|
|
|
|
type SystemUsecase struct {
|
|
repo SystemRepo
|
|
cache Cache
|
|
files FileStorage
|
|
}
|
|
|
|
func NewSystemUsecase(repo SystemRepo, cache Cache, files FileStorage) *SystemUsecase {
|
|
return &SystemUsecase{repo: repo, cache: cache, files: files}
|
|
}
|
|
|
|
func (uc *SystemUsecase) CacheGet(ctx context.Context, key string) (string, bool, error) {
|
|
return uc.cache.Get(ctx, key)
|
|
}
|
|
func (uc *SystemUsecase) CacheSet(ctx context.Context, key, value string, expiration time.Duration) error {
|
|
return uc.cache.Set(ctx, key, value, expiration)
|
|
}
|
|
func (uc *SystemUsecase) CacheDelete(ctx context.Context, key string) error {
|
|
return uc.cache.Delete(ctx, key)
|
|
}
|
|
func (uc *SystemUsecase) CacheIncrement(ctx context.Context, key string, expiration time.Duration) (int64, error) {
|
|
return uc.cache.Increment(ctx, key, expiration)
|
|
}
|