Skip to content

importcjj/localcache

Repository files navigation

localcache

Build Status GoDoc

Dangerous but concurrent local cache wrapper service with high performance.

How to use?

// new serivce
dangerous := localcache.NewService(&localcache.Options{})

// Register Upstream
dangerous.Register("getterName", 5*time.Second, func(key RequestKey, sink Sink) error {
     strVal, err := upstream()
     if err != nil {
         return err
    }
    sink.SetBytes([]byte(strVal))
    return nil
})

// Get Cache
cache := dangerous.Get(&Key{
    GetterName: "getterName",
    CacheName:  "cachename",
    Value:      context,
})

w.Write(cache.Bytes())

About

Dangerous but concurrent local cache wrapper service with high performance.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages