import
This commit is contained in:
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
package cache
|
||||
|
||||
import "log/slog"
|
||||
|
||||
// Cache — интерфейс подключения к кэшу.
|
||||
type Cache interface {
|
||||
Get(key string) (string, error)
|
||||
Set(key, value string) error
|
||||
Close() error
|
||||
}
|
||||
|
||||
// redisCache — конкретная реализация, скрыта от внешних пакетов.
|
||||
type redisCache struct {
|
||||
addr string
|
||||
}
|
||||
|
||||
// New создаёт подключение к кэшу.
|
||||
func New(addr string) Cache {
|
||||
slog.Info("подключились к кэшу", "addr", addr)
|
||||
return &redisCache{addr: addr}
|
||||
}
|
||||
|
||||
// Get получает значение по ключу.
|
||||
func (c *redisCache) Get(key string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// Set устанавливает значение по ключу.
|
||||
func (c *redisCache) Set(key, value string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close закрывает подключение к кэшу.
|
||||
func (c *redisCache) Close() error {
|
||||
slog.Info("подключение к кэшу закрыто")
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user