Documentation
¶
Index ¶
- Variables
- func Cache(store persist.Store, expire time.Duration, opts ...Option) gin.HandlerFunc
- func GenerateKeyWithPrefix(prefix, key string) string
- func GenerateRequestPath(c *gin.Context) (string, bool)
- func GenerateRequestUri(c *gin.Context) (string, bool)
- type BodyCache
- type BodyWriter
- type Config
- type Discard
- type Encoding
- type JSONEncoding
- type JSONGzipEncoding
- type Logger
- type Option
Constants ¶
This section is empty.
Variables ¶
var PageCachePrefix = "gincache.page.cache:"
PageCachePrefix default page cache key prefix
Functions ¶
func Cache ¶
Cache user must pass store and store expiration time to cache and with custom option. default caching response with uri, which use PageCachePrefix
func GenerateKeyWithPrefix ¶
GenerateKeyWithPrefix generate key with GenerateKeyWithPrefix and u, if key is larger than 200,it will use sha1.Sum key like: prefix+u or prefix+sha1(u)
func GenerateRequestPath ¶
GenerateRequestPath generate key with PageCachePrefix and request Path
Types ¶
type BodyCache ¶
type BodyCache struct { Status int Header http.Header Data []byte // contains filtered or unexported fields }
BodyCache body cache store
func (*BodyCache) MarshalBinary ¶
func (*BodyCache) UnmarshalBinary ¶
type BodyWriter ¶
type BodyWriter struct { gin.ResponseWriter // contains filtered or unexported fields }
BodyWriter dup response writer body
func (*BodyWriter) Write ¶
func (w *BodyWriter) Write(b []byte) (int, error)
Write writes the data to the connection as part of an HTTP reply.
func (*BodyWriter) WriteString ¶
func (w *BodyWriter) WriteString(s string) (int, error)
WriteString the string into the response body.
type Discard ¶
type Discard struct{}
Discard is an logger on which all Write calls succeed without doing anything.
func NewDiscard ¶
func NewDiscard() Discard
NewDiscard a discard logger on which always succeed without doing anything
type JSONEncoding ¶
type JSONEncoding struct{}
type JSONGzipEncoding ¶
type JSONGzipEncoding struct{}
type Option ¶
type Option func(c *Config)
Option custom option
func WithEncoding ¶
WithEncoding custom Encoding, default is JSONEncoding.
func WithGenerateKey ¶
WithGenerateKey custom generate key ,default is GenerateRequestURIKey.
func WithRandDuration ¶
WithRandDuration custom rand duration for expire, default return zero expiration time always expire + rand()
func WithSingleflight ¶
func WithSingleflight(group *singleflight.Group) Option
WithSingleflight custom single flight group, default is private single flight group.