Added dict with additional cards

This commit is contained in:
Artyom Belousov 2021-02-03 19:09:08 +03:00
parent 181f3bc0aa
commit 88ea431a27
26 changed files with 232 additions and 35 deletions

View file

@ -1,39 +0,0 @@
package caching
import (
"github.com/go-redis/redis"
"time"
)
type CacheClient struct {
Storage *redis.Client
Expiration time.Duration
}
var client *CacheClient
func GetClient() *CacheClient {
if client != nil {
return client
}
client = new(CacheClient)
client.Init()
return client
}
func (client *CacheClient) Init() {
client.Storage = redis.NewClient(&redis.Options{
Addr: HostName,
Password: Password,
DB: 0,
})
client.Expiration = CacheExpiration
}
func (client *CacheClient) Set(key string, value string) {
client.Storage.Set(key, value, client.Expiration)
}
func (client *CacheClient) Get(key string) (string, error) {
return client.Storage.Get(key).Result()
}