Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Repository files navigation

Cachego

Codecov branchGoDocGo Report CardLicense

Simple interface for caching

Installation

Cachego requires Go 1.21 or later.

go get github.com/faabiosr/cachego

Usage

package main
import (
"log""time""github.com/faabiosr/cachego/sync"
)
funcmain() {
cache:=sync.New()
iferr:=cache.Save("user_id", "1", 10*time.Second); err!=nil {
log.Fatal(err)
}
id, err:=cache.Fetch("user_id")
iferr!=nil {
log.Fatal(err)
}
log.Printf("user id: %s \n", id)
keys:=cache.FetchMulti([]string{"user_id", "user_name"})
fork, v:=rangekeys {
log.Printf("%s: %s\n", k, v)
}
ifcache.Contains("user_name") {
cache.Delete("user_name")
}
if_, err:=cache.Fetch("user_name"); err!=nil {
log.Printf("%v\n", err)
}
iferr:=cache.Flush(); err!=nil {
log.Fatal(err)
}
}

Supported drivers

Documentation

Read the full documentation at https://pkg.go.dev/github.com/faabiosr/cachego.

Development

Requirements

Makefile

// Clean up
$ make clean
//Run tests and generates html coverage file
$ make cover
// Up the docker containers for testing
$ make docker
// Format all go files
$ make fmt
//Run linters
$ make lint
// Run tests
$ make test

License

This project is released under the MIT licence. See LICENSE for more details.

About

Golang Cache component - Multiple drivers

Topics

Resources

Contributing

Stars

369 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages