Extracted Cache dependencies
This commit is contained in:
parent
40f1687972
commit
1f69282c73
4 changed files with 15 additions and 28 deletions
|
|
@ -10,19 +10,15 @@ type CacheClient struct {
|
|||
Expiration time.Duration
|
||||
}
|
||||
|
||||
func GetClient() *CacheClient {
|
||||
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 NewClient(addr string, passwd string, expiration time.Duration, db int) *CacheClient {
|
||||
return &CacheClient{
|
||||
Storage: redis.NewClient(&redis.Options{
|
||||
Addr: addr,
|
||||
Password: passwd,
|
||||
DB: db,
|
||||
}),
|
||||
Expiration: expiration,
|
||||
}
|
||||
}
|
||||
|
||||
func (client *CacheClient) Set(key string, value string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue