Documentation
¶
Index ¶
- func Cache(defaultCacheStore persist.CacheStore, defaultExpire time.Duration, ...) gin.HandlerFunc
- func CacheByRequestPath(defaultCacheStore persist.CacheStore, defaultExpire time.Duration, ...) gin.HandlerFunc
- func CacheByRequestURI(defaultCacheStore persist.CacheStore, defaultExpire time.Duration, ...) gin.HandlerFunc
- type Config
- type Discard
- type GetCacheStrategyByRequest
- type Logger
- type OnHitCacheCallback
- type Option
- type Strategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cache ¶
func Cache( defaultCacheStore persist.CacheStore, defaultExpire time.Duration, opts ...Option, ) gin.HandlerFunc
Cache user must pass getCacheKey to describe the way to generate cache key
func CacheByRequestPath ¶ added in v1.0.0
func CacheByRequestPath(defaultCacheStore persist.CacheStore, defaultExpire time.Duration, opts ...Option) gin.HandlerFunc
CacheByRequestPath a shortcut function for caching response by url path, means will discard the query params
func CacheByRequestURI ¶ added in v1.0.0
func CacheByRequestURI(defaultCacheStore persist.CacheStore, defaultExpire time.Duration, opts ...Option) gin.HandlerFunc
CacheByRequestURI a shortcut function for caching response by uri
Types ¶
type Discard ¶ added in v1.0.0
type Discard struct {
}
Discard the default logger that discard all logs of gin-cache
type GetCacheStrategyByRequest ¶ added in v1.0.0
GetCacheStrategyByRequest User can this function to design custom cache strategy by request. The first return value bool means whether this request should be cached. The second return value Strategy determine the special strategy by this request.
type OnHitCacheCallback ¶ added in v1.1.0
type Option ¶ added in v1.0.0
type Option func(c *Config)
func WithCacheStrategyByRequest ¶ added in v1.0.0
func WithCacheStrategyByRequest(getGetCacheStrategyByRequest GetCacheStrategyByRequest) Option
func WithLogger ¶ added in v1.0.0
WithLogger user can record logs by the logger
func WithOnHitCache ¶ added in v1.1.0
func WithOnHitCache(cb OnHitCacheCallback) Option
WithOnHitCache will be called when cache hit.
func WithSingleFlightForgetTimeout ¶ added in v1.2.0
WithSingleFlightForgetTimeout to reduce the impact of long tail requests. when request in the singleflight, after the forget timeout, singleflight.Forget will be called

