tests: cache
This commit is contained in:
parent
92732f9682
commit
597feb7b54
8 changed files with 822 additions and 32 deletions
|
@ -2,17 +2,21 @@ package model
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
var ErrCacheKeyDontExist = errors.New("cache key don't exist")
|
||||
|
||||
type Cache interface {
|
||||
Get(key string) (any, error)
|
||||
GetWithOptions(key string, opts ...CacheGetOption)
|
||||
Set(key string, value any) error
|
||||
SetWithOptions(key string, value any, opts ...CacheSetOption)
|
||||
Set(key string, value any, opts ...CacheOption) error
|
||||
Delete(key string) error
|
||||
}
|
||||
|
||||
type CacheGetOption func()
|
||||
type CacheSetOption func()
|
||||
type CacheItem struct {
|
||||
Key string
|
||||
Value any
|
||||
TTL *time.Time
|
||||
}
|
||||
|
||||
type CacheOption func(item *CacheItem)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue