@@ -10,6 +10,7 @@ import (
1010 "github.com/webhookx-io/webhookx/admin"
1111 "github.com/webhookx-io/webhookx/admin/api"
1212 "github.com/webhookx-io/webhookx/config"
13+ "github.com/webhookx-io/webhookx/constants"
1314 "github.com/webhookx-io/webhookx/db"
1415 "github.com/webhookx-io/webhookx/db/entities"
1516 "github.com/webhookx-io/webhookx/db/migrator"
@@ -321,13 +322,14 @@ func registerEventHandler(bus *eventbus.EventBus) {
321322 }
322323 bus .Broadcast (eventbus .EventCRUD , eventData )
323324 })
324- bus .Subscribe (eventbus .EventCRUD , func (data interface {}) {
325- eventData := data .(* eventbus.CrudData )
326- err := mcache .Invalidate (context .TODO (), eventData .CacheKey )
325+ bus .Subscribe (eventbus .EventCRUD , func (d interface {}) {
326+ data := d .(* eventbus.CrudData )
327+ cacheKey := constants .CacheKeyFrom (data .CacheName )
328+ err := mcache .Invalidate (context .TODO (), cacheKey .Build (data .ID ))
327329 if err != nil {
328- zap .S ().Errorf ("failed to invalidate cache: key=%s %v" , eventData . CacheKey , err )
330+ zap .S ().Errorf ("failed to invalidate cache: key=%s %v" , cacheKey . Build ( data . ID ) , err )
329331 }
330- bus .Broadcast (fmt .Sprintf ("%s.crud" , eventData .Entity ), eventData )
332+ bus .Broadcast (fmt .Sprintf ("%s.crud" , data .Entity ), data )
331333 })
332334}
333335
0 commit comments