cache

GitHub Workflow Status Codecov GoDoc Sourcegraph

Package cache is a middleware that provides the cache management for Flamego.

Installation

The minimum requirement of Go is 1.16.

  1. go get github.com/flamego/cache

Getting started

  1. package main
  2. import (
  3. "time"
  4. "github.com/flamego/cache"
  5. "github.com/flamego/flamego"
  6. )
  7. func main() {
  8. f := flamego.Classic()
  9. f.Use(cache.Cacher())
  10. f.Get("/", func(cache cache.Cache) {
  11. _ = cache.Set("cooldown", true, time.Minute)
  12. cooldown, ok := cache.Get("cooldown").(bool)
  13. // ...
  14. })
  15. f.Run()
  16. }

Getting help

License

This project is under the MIT License. See the LICENSE file for the full license text.