Skip to content

ngerakines/yacache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yet another cache

Build Status GoDoc

Cache some things and stuff.

Installation

Install:

go get -u github.com/ngerakines/yacache

Import:

import "github.com/ngerakines/yacache"

Quickstart

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
}

About

Yet Another Cache

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages