🐛 Fix cache issue
This commit is contained in:
@ -1,11 +1,18 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
|
||||
"github.com/eko/gocache/lib/v4/cache"
|
||||
"github.com/eko/gocache/lib/v4/marshaler"
|
||||
|
||||
localCache "git.solsynth.dev/hypernet/paperclip/pkg/internal/cache"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -70,6 +77,19 @@ type Attachment struct {
|
||||
IsMature bool `json:"is_mature" gorm:"-"`
|
||||
}
|
||||
|
||||
func (v *Attachment) AfterUpdate(tx *gorm.DB) error {
|
||||
cacheManager := cache.New[any](localCache.S)
|
||||
marshal := marshaler.New(cacheManager)
|
||||
ctx := context.Background()
|
||||
|
||||
_ = marshal.Delete(
|
||||
ctx,
|
||||
fmt.Sprintf("attachment#%s", v.Rid),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Data model for in progress multipart attachments
|
||||
type AttachmentFragment struct {
|
||||
cruda.BaseModel
|
||||
|
Reference in New Issue
Block a user