https://github.com/pkg6/go-cache
Golang Cache package
https://github.com/pkg6/go-cache
Last synced: 4 months ago
JSON representation
Golang Cache package
- Host: GitHub
- URL: https://github.com/pkg6/go-cache
- Owner: pkg6
- License: apache-2.0
- Created: 2023-05-24T09:39:14.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-21T14:49:17.000Z (over 1 year ago)
- Last Synced: 2025-01-09T11:41:14.917Z (6 months ago)
- Language: Go
- Size: 61.5 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## GoCache
[](https://goreportcard.com/report/github.com/pkg6/go-cache)
[](https://pkg.go.dev/github.com/pkg6/go-cache?tab=doc)
[](https://sourcegraph.com/github.com/pkg6/go-cache?badge)
[](https://github.com/pkg6/go-cache/releases)## Installation
Make sure you have a working Go environment (Go 1.18 or higher is required). See the [install instructions](https://golang.org/doc/install.html).
To install [GoCache](https://github.com/pkg6/go-cache), simply run:
```
go get github.com/pkg6/go-cache
```## Example
```
package mainimport (
"github.com/pkg6/go-cache"
)func main() {
c := cache.New()
c.Extend(cache.NewFileCache())
c.Set("cache", "test", 0)
c.Get("cache")
c.GetMulti([]string{"cache"})
c.Delete("cache")
c.Has("cache")
c.Increment("cache_inc", 1)
c.Decrement("cache_dec", 1)
c.Clear()
c.Pull("cache")
c.Remember("cache", func() any {
return "test1"
}, 0)
}
```