GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - flamego/cache: Package cache is a middleware that provides the cache management for Flamego

BranchesTags
Open more actions menu

Latest commit

 

History

129 Commits
129 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
mongo
mongo
 
 
mysql
mysql
 
 
postgres
postgres
 
 
redis
redis
 
 
sqlite
sqlite
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.golangci.yml
.golangci.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
cache.go
cache.go
 
 
cache_test.go
cache_test.go
 
 
codecov.yml
codecov.yml
 
 
file.go
file.go
 
 
file_test.go
file_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
manager.go
manager.go
 
 
manager_test.go
manager_test.go
 
 
memory.go
memory.go
 
 
memory_test.go
memory_test.go
 
 
type.go
type.go
 
 

Repository files navigation

cache

GitHub Workflow Status GoDoc

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

Installation

go get github.com/flamego/cache

Getting started

package main

import (
	"net/http"
	"time"

	"github.com/flamego/cache"
	"github.com/flamego/flamego"
)

func main() {
	f := flamego.Classic()
	f.Use(cache.Cacher())
	f.Get("/set", func(r *http.Request, cache cache.Cache) error {
		return cache.Set(r.Context(), "cooldown", true, time.Minute)
	})
	f.Get("/get", func(r *http.Request, cache cache.Cache) string {
		v, err := cache.Get(r.Context(), "cooldown")
		if err != nil && err != os.ErrNotExist {
			return err.Error()
		}

		cooldown, ok := v.(bool)
		if !ok || !cooldown {
			return "It has been cooled"
		}
		return "Still hot"
	})
	f.Run()
}

Getting help

  • Read documentation and examples.
  • Please file an issue or start a discussion on the flamego/flamego repository.

License

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

About

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

Topics

cacheflamegogomiddleware

Resources

Readme
MIT license
Activity
Custom properties

Stars

12 stars

Watchers

2 watching

Forks

3 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.