feat: cache + paths (#1)
- Added helper function `ExpandUser` - Added basic cache impmentations for in-memory and file based caches. Reviewed-on: #1 Co-authored-by: Felipe M. <me@fmartingr.com> Co-committed-by: Felipe M. <me@fmartingr.com>
This commit is contained in:
parent
ef80892aa5
commit
98eb17d9f3
10 changed files with 984 additions and 0 deletions
22
model/cache.go
Normal file
22
model/cache.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue