Fix flushdb command

This commit is contained in:
DanB
2015-11-16 14:00:18 +01:00
parent faee4e2bf8
commit ebe9dc4f35

View File

@@ -79,7 +79,7 @@ func (rs *RedisStorage) Close() {
}
func (rs *RedisStorage) Flush(ignore string) error {
return rs.db.Cmd("FLUSH").Err
return rs.db.Cmd("FLUSHDB").Err
}
func (rs *RedisStorage) GetKeysForPrefix(prefix string) ([]string, error) {
@@ -620,18 +620,6 @@ func (rs *RedisStorage) GetAccount(key string) (ub *Account, err error) {
}
func (rs *RedisStorage) SetAccount(ub *Account) (err error) {
// never override existing account with an empty one
// UPDATE: if all balances expired and were cleaned it makes
// sense to write empty balance map
if len(ub.BalanceMap) == 0 {
if ac, err := rs.GetAccount(ub.Id); err == nil && !ac.allBalancesExpired() {
ac.ActionTriggers = ub.ActionTriggers
ac.UnitCounters = ub.UnitCounters
ac.AllowNegative = ub.AllowNegative
ac.Disabled = ub.Disabled
ub = ac
}
}
result, err := rs.ms.Marshal(ub)
err = rs.db.Cmd("SET", utils.ACCOUNT_PREFIX+ub.Id, result).Err
return