Sync GetKeysForPrefix for InternalDB with other DataDBs

This commit is contained in:
TeoV
2019-11-11 11:36:44 +02:00
committed by Dan Christian Bogos
parent 65113f2739
commit 769edb94ff

View File

@@ -81,17 +81,13 @@ func (iDB *InternalDB) SelectDatabase(dbName string) (err error) {
return nil
}
func (iDB *InternalDB) GetKeysForPrefix(prefix string) (ids []string, err error) {
func (iDB *InternalDB) GetKeysForPrefix(prefix string) ([]string, error) {
keyLen := len(utils.DESTINATION_PREFIX)
if len(prefix) < keyLen {
return nil, fmt.Errorf("unsupported prefix in GetKeysForPrefix: %s", prefix)
}
category := prefix[:keyLen] // prefix length
ids = iDB.db.GetItemIDs(utils.CachePrefixToInstance[category], prefix)
if len(ids) == 0 {
return nil, utils.ErrNotFound
}
return
return iDB.db.GetItemIDs(utils.CachePrefixToInstance[category], prefix), nil
}
func (iDB *InternalDB) RebuildReverseForPrefix(prefix string) (err error) {