Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/develop/data-types/sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Because the members expire, each example recreates the `bikes:reserved` set firs

Add two members with a TTL of 15 minutes, add a third member with no expiration, and then retrieve the remaining TTL of each member:

```redis
{{< clients-example set="sets_tutorial" step="member_expiration" lang_filter="Java-Sync" description="Member expiration: Add set members with a TTL using SADDEX, then read each member's remaining TTL with STTL" difficulty="intermediate" buildsUpon="sadd" >}}
> DEL bikes:reserved
(integer) 0
> SADDEX bikes:reserved EX 900 MEMBERS 2 bike:1 bike:2
Expand All @@ -234,7 +234,7 @@ Add two members with a TTL of 15 minutes, add a third member with no expiration,
1) (integer) 900
2) (integer) 900
3) (integer) -1
```
{{< /clients-example >}}

Set a member's TTL in milliseconds, retrieve the remaining TTL in milliseconds, and then remove the expiration:

Expand Down
21 changes: 21 additions & 0 deletions local_examples/tmp/datatypes/sets/SetsExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// REMOVE_END
// HIDE_START
import redis.clients.jedis.RedisClient;
import redis.clients.jedis.params.SAddExParams;

import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -190,6 +191,26 @@ public void run() {
assertEquals(1,res19);
// REMOVE_END

// STEP_START member_expiration
jedis.del("bikes:reserved");

long res23 = jedis.saddex("bikes:reserved", SAddExParams.sAddExParams().ex(900), "bike:1", "bike:2");
System.out.println(res23); // >>> 1

long res24 = jedis.sadd("bikes:reserved", "bike:3");
System.out.println(res24); // >>> 1

List<Long> res25 = jedis.sttl("bikes:reserved", "bike:1", "bike:2", "bike:3");
System.out.println(res25); // >>> [900, 900, -1]
// STEP_END

// REMOVE_START
assertEquals(1, res23);
assertEquals(1, res24);
assertEquals(List.of(900L, 900L, -1L), res25);
jedis.del("bikes:reserved");
// REMOVE_END

// HIDE_START
jedis.close();
// HIDE_END
Expand Down
Loading