Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command LSET #312

Merged
merged 7 commits into from
May 28, 2024
Merged

Add command LSET #312

merged 7 commits into from
May 28, 2024

Conversation

tjzhang-BQ
Copy link

Adding command LSet

java/client/src/test/java/glide/api/RedisClientTest.java Outdated Show resolved Hide resolved
java/client/src/test/java/glide/api/RedisClientTest.java Outdated Show resolved Hide resolved
java/client/src/test/java/glide/api/RedisClientTest.java Outdated Show resolved Hide resolved
String response = client.lset(key, index, element).get();
assertEquals(OK, response);
String[] updatedList = client.lrange(key, 0, -1).get();
assertArrayEquals(updatedList, expectedList);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the expected list at this point should be:

        String[] expectedList = {"zero", "three", "two", "one"};

since you're only modifying the value at index 0

Copy link
Author

@tjzhang-BQ tjzhang-BQ May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lpush pushes each element in the input array to the front of the list, so the list starts as {"one", "two", "three", "four"}

@@ -298,6 +302,9 @@ private static Object[] listCommands(BaseTransaction<?> transaction) {
4L, // linsert(listKey3, AFTER, value2, value2)
new String[] {listKey3, value3}, // blpop(new String[] { listKey3 }, 0.01)
new String[] {listKey3, value1}, // brpop(new String[] { listKey3 }, 0.01)
2L, // lpush(listKey5, new String[] {value2, value3})
OK, // lset(listKey5, 0, value1)
new String[] {value1, value2} // lrange(listKey5, 0, -1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new String[] {value1, value2} // lrange(listKey5, 0, -1)
new String[] {value1, value3} // lrange(listKey5, 0, -1)

aren't we changing the value at index 0 only?

Copy link
Author

@tjzhang-BQ tjzhang-BQ May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since lpush pushes to the front, the list looks like {value3, value2} after first being pushed to, and after setting index 0 it becomes {value1, value2}

@tjzhang-BQ tjzhang-BQ merged commit 4e3f976 into java/integ_tjz_lset May 28, 2024
44 checks passed
@tjzhang-BQ tjzhang-BQ deleted the java/dev_tjz_lset branch May 28, 2024 05:35
tjzhang-BQ added a commit that referenced this pull request May 28, 2024
* Add command LSET

---------

Co-authored-by: TJ Zhang <tj.zhang@improving.com>
acarbonetto pushed a commit that referenced this pull request May 28, 2024
Add command LSET (#312)

* Add command LSET

---------

Co-authored-by: TJ Zhang <tj.zhang@improving.com>
cyip10 pushed a commit that referenced this pull request Jun 24, 2024
Add command LSET (#312)

* Add command LSET

---------

Co-authored-by: TJ Zhang <tj.zhang@improving.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants