tests: cache

This commit is contained in:
Felipe M 2025-03-23 23:37:26 +01:00
parent 92732f9682
commit 597feb7b54
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
8 changed files with 822 additions and 32 deletions

View file

@ -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)