You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
568 B
Go
25 lines
568 B
Go
package cache
|
|
|
|
//go:generate mockgen -destination=../cache_mock/cache_mock.go -package=cache_mock . Cache
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
// NoTTL define an entry that lives forever
|
|
NoTTL = time.Duration(0)
|
|
// ErrNIL is returned when there's no value for given key
|
|
ErrNIL = errors.New("value is nil")
|
|
)
|
|
|
|
// Cache represent a KV database
|
|
type Cache interface {
|
|
GetBytes(key string) ([]byte, error)
|
|
SetBytes(key string, value []byte, TTL time.Duration) error
|
|
|
|
GetInt64(key string) (int64, error)
|
|
SetInt64(key string, value int64, TTL time.Duration) error
|
|
}
|