Closed gebn closed 3 years ago
func main() { base := ttlcache.NewBase(&ttlcache.BaseOpts{ Name: "name", PeerPicker: PeerPicker{}, AuthoritativeCacheCapacity: 5_000_000, HotCacheCapacity: 5_000, ParallelRequests: 50, }) cache := base.Configure(&ttlcache.ConfigureOpts{ OriginLoader: ttlcache.OriginLoaderFunc(func(_ context.Context, key string) ([]byte, lifetime.Lifetime, error) { log.Printf("origin load for %v", key) return []byte(key+"-value"), lifetime.New(time.Minute), nil }), }) } type PeerPicker struct{} func (p PeerPicker) PickPeer(key string) *memberlist.Node { return nil }