Skip to content
No description, website, or topics provided.
Go Makefile
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
.gitignore
CHANGELOG.md
LICENSE
Makefile
README.md
go.mod
go.sum
smartcache.go
smartcache_test.go
version.go

README.md

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

You can’t perform that action at this time.