Skip to content
👜 Cache arbitrary data with an expiration time.
Go
Branch: master
Clone or download

Latest commit

Latest commit a29669d Feb 25, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.drone.yml Cleanup Feb 26, 2020
.gitignore Cleanup Oct 21, 2019
Cache.go Cleanup Feb 26, 2020
Cache_test.go Cleanup Feb 26, 2020
LICENSE Updated linter version Oct 21, 2019
README.md Cleanup Oct 21, 2019
README.src.md Cleanup Oct 21, 2019
go.mod Cleanup Oct 21, 2019

README.md

cache

Godoc Report Tests Coverage Sponsor

Cache arbitrary data with an expiration time.

Features

  • 0 dependencies
  • About 100 lines of code
  • 100% test coverage

Usage

// New cache
c := cache.New(5 * time.Minute)

// Put something into the cache
c.Set("a", "b", 1 * time.Minute)

// Read from the cache
obj, found := c.Get("a")

// Convert the type
fmt.Println(obj.(string))

Benchmarks

BenchmarkGet-12         300000000                3.88 ns/op            0 B/op          0 allocs/op
BenchmarkSet-12         10000000               183 ns/op              48 B/op          2 allocs/op
BenchmarkNew-12         10000000               112 ns/op             352 B/op          5 allocs/op

Style

Please take a look at the style guidelines if you'd like to make a pull request.

Sponsors

Cedric Fung Scott Rayapoullé Eduard Urbach
Cedric Fung Scott Rayapoullé Eduard Urbach

Want to see your own name here?

You can’t perform that action at this time.