Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngerakines/yacache
Yet Another Cache
https://github.com/ngerakines/yacache
caching
Last synced: 7 days ago
JSON representation
Yet Another Cache
- Host: GitHub
- URL: https://github.com/ngerakines/yacache
- Owner: ngerakines
- License: mit
- Created: 2019-01-28T20:51:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-31T16:12:55.000Z (almost 6 years ago)
- Last Synced: 2024-11-09T09:44:22.455Z (2 months ago)
- Topics: caching
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# yet another cache
[![Build Status](https://travis-ci.org/ngerakines/yacache.png?branch=master)](https://travis-ci.org/ngerakines/yacache)
[![GoDoc](https://godoc.org/github.com/ngerakines/yacache?status.svg)](https://godoc.org/github.com/ngerakines/yacache)Cache some things and stuff.
## Installation
Install:
```shell
go get -u github.com/ngerakines/yacache
```Import:
```go
import "github.com/ngerakines/yacache"
```## Quickstart
```go
func ExampleNewCache_Get() {
ctx := context.Background()
c := NewCache()
key := Key("foo")
fetcher := func(ctx context.Context, fkey yacache.Key) (yacache.Cacheable, error) {
return NewCacheableValue("bar", 1*time.Hour), nil
}
if item, err := c.Get(ctx, key, fetcher); err == nil {
fmt.Println(item.Value())
}
if item, err := c.Get(ctx, key, fetcher); err == nil {
fmt.Println(item.Value())
}
// Output: bar
// bar
}
```