Added dict with additional cards
This commit is contained in:
parent
181f3bc0aa
commit
88ea431a27
26 changed files with 232 additions and 35 deletions
|
|
@ -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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue