Better tracing

Not done yet, still need to add them to just about every other function
This commit is contained in:
Melody Becker 2024-11-06 16:57:44 +01:00
parent 83f47d17be
commit 529d106351
13 changed files with 148 additions and 22 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/redis/go-redis/v9"
"github.com/rs/zerolog/log"
"gitlab.com/mstarongitlab/linstrom/config"
"gitlab.com/mstarongitlab/linstrom/util"
)
type Cache struct {
@ -72,6 +73,7 @@ func NewCache(maxSize int64, redisUrl *string) (*Cache, error) {
}
func (c *Cache) Get(key string, target any) (bool, error) {
defer util.Untrace(util.Trace(&log.Logger))
return false, nil
data, err := c.cache.Get(ctxBackground, key)
if err != nil {
@ -85,6 +87,7 @@ func (c *Cache) Get(key string, target any) (bool, error) {
}
func (c *Cache) Set(key string, value any) error {
defer util.Untrace(util.Trace(&log.Logger))
return nil
data, err := c.encoders.Encode(value)
if err != nil {
@ -95,6 +98,7 @@ func (c *Cache) Set(key string, value any) error {
}
func (c *Cache) Delete(key string) {
defer util.Untrace(util.Trace(&log.Logger))
// Error return doesn't matter here. Delete is delete is gone
_ = c.cache.Delete(ctxBackground, key)
}