mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 21:02:25 +08:00
14
cache/redis.go
vendored
14
cache/redis.go
vendored
@@ -14,12 +14,12 @@ type Redis struct {
|
||||
|
||||
//RedisOpts redis 连接属性
|
||||
type RedisOpts struct {
|
||||
Host string
|
||||
Password string
|
||||
Database int
|
||||
MaxIdle int
|
||||
MaxActive int
|
||||
IdleTimeout time.Duration //second
|
||||
Host string `yml:"host" json:"host"`
|
||||
Password string `yml:"password" json:"password"`
|
||||
Database int `yml:"database" json:"database"`
|
||||
MaxIdle int `yml:"max_idle" json:"max_idle"`
|
||||
MaxActive int `yml:"max_active" json:"max_active"`
|
||||
IdleTimeout int32 `yml:"idle_timeout" json:"idle_timeout"` //second
|
||||
}
|
||||
|
||||
//NewRedis 实例化
|
||||
@@ -27,7 +27,7 @@ func NewRedis(opts *RedisOpts) *Redis {
|
||||
pool := &redis.Pool{
|
||||
MaxActive: opts.MaxActive,
|
||||
MaxIdle: opts.MaxIdle,
|
||||
IdleTimeout: opts.IdleTimeout,
|
||||
IdleTimeout: time.Second * time.Duration(opts.IdleTimeout),
|
||||
Dial: func() (redis.Conn, error) {
|
||||
return redis.Dial("tcp", opts.Host,
|
||||
redis.DialDatabase(opts.Database),
|
||||
|
||||
6
js/js.go
6
js/js.go
@@ -44,7 +44,7 @@ func NewJs(context *context.Context) *Js {
|
||||
func (js *Js) GetConfig(uri string) (config *Config, err error) {
|
||||
config = new(Config)
|
||||
var ticketStr string
|
||||
ticketStr, err = js.getTicket()
|
||||
ticketStr, err = js.GetTicket()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -61,8 +61,8 @@ func (js *Js) GetConfig(uri string) (config *Config, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//getTicket 获取jsapi_tocket全局缓存
|
||||
func (js *Js) getTicket() (ticketStr string, err error) {
|
||||
//GetTicket 获取jsapi_tocket
|
||||
func (js *Js) GetTicket() (ticketStr string, err error) {
|
||||
js.GetJsAPITicketLock().Lock()
|
||||
defer js.GetJsAPITicketLock().Unlock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user