22 lines
355 B
Go
22 lines
355 B
Go
package model
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
var ErrCacheKeyDontExist = errors.New("cache key don't exist")
|
|
|
|
type Cache interface {
|
|
Get(key string) (any, error)
|
|
Set(key string, value any, opts ...CacheOption) error
|
|
Delete(key string) error
|
|
}
|
|
|
|
type CacheItem struct {
|
|
Key string
|
|
Value any
|
|
TTL *time.Time
|
|
}
|
|
|
|
type CacheOption func(item *CacheItem)
|