2021-11-18 18:17:43 +00:00
|
|
|
package cache
|
|
|
|
|
|
|
|
import (
|
2021-11-18 18:52:40 +00:00
|
|
|
"log"
|
2021-11-18 18:17:43 +00:00
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewManager() Manager {
|
|
|
|
if strings.Contains(os.Getenv("PROFILE"), "redis") {
|
2021-11-18 18:52:40 +00:00
|
|
|
log.Println("Cache | using redis cache")
|
2021-11-18 18:17:43 +00:00
|
|
|
return newRedisCache()
|
|
|
|
} else {
|
2021-11-18 18:52:40 +00:00
|
|
|
log.Println("Cache | using in memory cache")
|
2021-11-18 18:17:43 +00:00
|
|
|
return newInMemCache()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Manager interface {
|
|
|
|
Set(key, value string, expiration time.Duration) error
|
|
|
|
Get(key string) (string, error)
|
|
|
|
Remove(key string)
|
|
|
|
}
|