Fix LPOS when member not in list.

This commit ensures an empty List is returned in the case the member does not exist in the target list.

See #1957.
Original pull request: #1962.
This commit is contained in:
Christoph Strobl
2021-02-10 14:35:34 +01:00
committed by Mark Paluch
parent 19eb0930cd
commit 840c7f50ca
4 changed files with 22 additions and 2 deletions

View File

@@ -72,7 +72,7 @@ class JedisListCommands implements RedisListCommands {
return connection.invoke().just(BinaryJedis::lpos, MultiKeyPipelineBase::lpos, key, element, params, count);
}
return connection.invoke().from(BinaryJedis::lpos, MultiKeyPipelineBase::lpos, key, element, params).get(Collections::singletonList);
return connection.invoke().from(BinaryJedis::lpos, MultiKeyPipelineBase::lpos, key, element, params).getOrElse(Collections::singletonList, Collections::emptyList);
}
/*

View File

@@ -71,7 +71,7 @@ class LettuceListCommands implements RedisListCommands {
return connection.invoke().just(RedisListAsyncCommands::lpos, key, element, count, args);
}
return connection.invoke().from(RedisListAsyncCommands::lpos, key, element, args).get(Collections::singletonList);
return connection.invoke().from(RedisListAsyncCommands::lpos, key, element, args).getOrElse(Collections::singletonList, Collections::emptyList);
}
/*