Skip to content

Songmu/smartcache

Repository files navigation

smartcache

Test Status Coverage Status MIT License GoDoc

The smartcache realizes smart in memory cache generation to minimize process blocks by using soft expire limit

Synopsis

var (
    expire     = 5*time.Minute
    softExpire = 1*time.Minute
)
ca := smartcache.New(expire, softExpire, func(ctx context.Context) (interface{}, error) {
    val, err := genCache(ctx)
    return val, err
})

val, err := ca.Get(context.Background())

Description

The smartcache is an in-memory cache library with avoiding the following problems.

  • thundering herd
  • block processing when regenerating
  • etc.

To avoid the above problems, you can set a soft expire limit to Cache. The soft expired cached value is internally pre-warmed by a single goroutine and the value is replaced seamlessly.

Installation

% go get github.com/Songmu/smartcache

Author

Songmu

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published