This commit is contained in:
2026-04-13 08:10:14 +03:00
commit a4455b1170
18 changed files with 1063 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package repository
import "log/slog"
// SessionDB — интерфейс базы данных, который нужен SessionRepo.
type SessionDB interface {
Query(query string) error
Exec(query string) error
BeginTx() error
}
// SessionCache — интерфейс кэша, который нужен SessionRepo.
type SessionCache interface {
Get(key string) (string, error)
Set(key, value string) error
}
// SessionRepo — интерфейс репозитория сессий.
type SessionRepo interface{}
// sessionRepo — конкретная реализация, скрыта от внешних пакетов.
type sessionRepo struct {
db SessionDB
cache SessionCache
}
// NewSessionRepo создаёт репозиторий сессий.
func NewSessionRepo(db SessionDB, cache SessionCache) SessionRepo {
slog.Info("репозиторий сессий создан")
return &sessionRepo{db: db, cache: cache}
}