diff --git a/ledis/t_set.go b/ledis/t_set.go index d164752..b81496d 100644 --- a/ledis/t_set.go +++ b/ledis/t_set.go @@ -374,6 +374,8 @@ func (db *DB) SMembers(key []byte) ([][]byte, error) { v := make([][]byte, 0, 16) it := db.bucket.RangeLimitIterator(start, stop, store.RangeROpen, 0, -1) + defer it.Close() + for ; it.Valid(); it.Next() { _, m, err := db.sDecodeSetKey(it.Key()) if err != nil { @@ -383,8 +385,6 @@ func (db *DB) SMembers(key []byte) ([][]byte, error) { v = append(v, m) } - it.Close() - return v, nil }