19 lines
316 B
Go
19 lines
316 B
Go
package middleware
|
|
|
|
import (
|
|
"game-driver/config"
|
|
"game-driver/leaf"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// Cache 缓存中间件
|
|
func Cache(cache config.Cache) leaf.HandlerFunc {
|
|
return func(c *leaf.Context) {
|
|
err := cache.Set(c.Publish)
|
|
if err != nil {
|
|
zap.S().Errorln("缓存数据失败: ", err)
|
|
}
|
|
c.Next()
|
|
}
|
|
}
|