34 lines
692 B
Go
34 lines
692 B
Go
package myRedis
|
|
|
|
import (
|
|
"github.com/redis/go-redis/v9"
|
|
"time"
|
|
)
|
|
|
|
type Client struct {
|
|
client *redis.Client
|
|
}
|
|
|
|
func NewClient(client *redis.Client) *Client {
|
|
if client == nil {
|
|
panic("redis client is nil")
|
|
}
|
|
return &Client{client: client}
|
|
}
|
|
|
|
func (t *Client) GetClient() *redis.Client {
|
|
return t.client
|
|
}
|
|
|
|
func (t *Client) NewStringCache() *StringCache {
|
|
return NewStringCache(t.client)
|
|
}
|
|
|
|
func (t *Client) NewJsonCache(expire time.Duration) *SimpleCache {
|
|
return NewSimpleCache(NewStringOperation(t.client), expire, SerializerJson)
|
|
}
|
|
|
|
func (t *Client) NewGobCache(expire time.Duration) *SimpleCache {
|
|
return NewSimpleCache(NewStringOperation(t.client), expire, SerializerGob)
|
|
}
|