CleanupChannelPollingLocks removes locks for channels that no longer exist This is optional and can be called periodically to prevent memory leaks
()
| 505 | // CleanupChannelPollingLocks removes locks for channels that no longer exist |
| 506 | // This is optional and can be called periodically to prevent memory leaks |
| 507 | func CleanupChannelPollingLocks() { |
| 508 | var activeChannelIds []int |
| 509 | DB.Model(&Channel{}).Pluck("id", &activeChannelIds) |
| 510 | |
| 511 | activeChannelSet := make(map[int]bool) |
| 512 | for _, id := range activeChannelIds { |
| 513 | activeChannelSet[id] = true |
| 514 | } |
| 515 | |
| 516 | channelPollingLocks.Range(func(key, value interface{}) bool { |
| 517 | channelId := key.(int) |
| 518 | if !activeChannelSet[channelId] { |
| 519 | channelPollingLocks.Delete(channelId) |
| 520 | } |
| 521 | return true |
| 522 | }) |
| 523 | } |
| 524 | |
| 525 | func handlerMultiKeyUpdate(channel *Channel, usingKey string, status int) { |
| 526 | keys := channel.getKeys() |