Skip to content

TankTim68/go-cache

 
 

Repository files navigation

go-cache

Modified from https://github.com/fanjindong/go-cache with Generics in Go 1.18+.

Install

go get -u github.com/Xhofe/go-cache

Basic Usage

import "github.com/Xhofe/go-cache"

func main() {
    c := cache.NewMemCache[int]()
    c.Set("a", 1)
    c.Set("b", 1, cache.WithEx[int](1*time.Second))
    time.sleep(1*time.Second)
    c.Get("a") // 1, true
    c.Get("b") // nil, false
}

About

⚡Modified from https://github.com/fanjindong/go-cache with Generics in Go 1.18+.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%