Skip to content

Gin middleware for caching requests - uses interface for storage adapter

License

Notifications You must be signed in to change notification settings

francoispqt/gincache

Repository files navigation

Gin Cache Middleware

Build Status codecov

Get started

Import the package

import "github.com/francoispqt/gincache"

Then use it

r := gin.Default()

// creating a global middleware
r.Use(gincache.NewMiddleware(&gincache.Options{
    TTL: 3600,
    KeyFunc: func(c *gin.Context) (string, error){
        return "CACHEKEY", nil
    },
}))

// creating a route based middleware
r.GET(
    "/",
    gincache.NewMiddleware(&gincache.Options{
        TTL: 3600,
        Key: "GET/",
    }),
    func(c *fin.Context) {

    }
)

r.Run(":8080")

About

Gin middleware for caching requests - uses interface for storage adapter

Resources

License

Stars

Watchers

Forks

Packages

No packages published