github.com/unionj-cloud/go-doudou@v1.3.8-0.20221011095552-0088008e5b31/framework/cache/arccache.go (about)

     1  package cache
     2  
     3  import (
     4  	lru "github.com/hashicorp/golang-lru"
     5  	"github.com/pkg/errors"
     6  	"github.com/unionj-cloud/go-doudou/toolkit/caller"
     7  	"time"
     8  )
     9  
    10  type ARCCache struct {
    11  	*base
    12  }
    13  
    14  func NewARCCache(size int, ttl time.Duration) *ARCCache {
    15  	store, err := lru.NewARC(size)
    16  	if err != nil {
    17  		panic(errors.Wrap(err, caller.NewCaller().String()))
    18  	}
    19  	return &ARCCache{
    20  		newBase(store, ttl),
    21  	}
    22  }