github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/app/bcache/cache.go (about)

     1  package bcache
     2  
     3  import "time"
     4  
     5  type Cache[K comparable, V any] interface {
     6  	Set(k K, v V, d time.Duration)
     7  	SetDefault(k K, v V)
     8  	SetNoExpire(k K, v V)
     9  	SetIfAbsent(k K, v V, d time.Duration) bool
    10  	Replace(k K, v V, d time.Duration) bool
    11  	Delete(k K)
    12  	Get(k K) (V, bool)
    13  	GetWithExpire(k K) (V, time.Time, bool)
    14  	Count() int
    15  	Clear()
    16  	Load(data []byte) error
    17  	Export() ([]byte, error)
    18  	Marshal() ([]byte, error)
    19  	Unmarshal(data []byte) error
    20  }