Move refreshChannels to own method

This commit is contained in:
Peter Stuifzand 2018-10-03 18:41:46 +02:00
parent 4829ce0192
commit ab7e654f7c
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -108,12 +108,15 @@ func (b *memoryBackend) load() error {
return err
}
return nil
}
func (b *memoryBackend) refreshChannels() {
conn := pool.Get()
defer conn.Close()
conn.Do("SETNX", "channel_sortorder_notifications", 1)
conn.Do("DEL", "channels")
conn.Do("SETNX", "channel_sortorder_notifications", 1)
b.lock.RLock()
defer b.lock.RUnlock()
@ -123,8 +126,6 @@ func (b *memoryBackend) load() error {
conn.Do("SADD", "channels", uid)
conn.Do("SETNX", "channel_sortorder_"+uid, 99999)
}
return nil
}
func (b *memoryBackend) save() {
@ -145,6 +146,7 @@ func loadMemoryBackend() microsub.Microsub {
log.Printf("Error while loadingbackend: %v\n", err)
return nil
}
backend.refreshChannels()
return backend
}