Interface PubSubBaseCommands

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.String> publish​(GlideString message, GlideString channel)
      Publishes message on pubsub channel.
      java.util.concurrent.CompletableFuture<java.lang.String> publish​(java.lang.String message, java.lang.String channel)
      Publishes message on pubsub channel.
      java.util.concurrent.CompletableFuture<java.lang.String[]> pubsubChannels()
      Lists the currently active channels.
      java.util.concurrent.CompletableFuture<GlideString[]> pubsubChannels​(GlideString pattern)
      Lists the currently active channels.
      java.util.concurrent.CompletableFuture<java.lang.String[]> pubsubChannels​(java.lang.String pattern)
      Lists the currently active channels.
      java.util.concurrent.CompletableFuture<GlideString[]> pubsubChannelsBinary()
      Lists the currently active channels.
      Unlike of pubsubChannels(), returns channel names as GlideStrings.
      java.util.concurrent.CompletableFuture<java.lang.Long> pubsubNumPat()
      Returns the number of unique patterns that are subscribed to by clients.
      java.util.concurrent.CompletableFuture<java.util.Map<GlideString,​java.lang.Long>> pubsubNumSub​(GlideString[] channels)
      Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Long>> pubsubNumSub​(java.lang.String[] channels)
      Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
    • Method Detail

      • publish

        java.util.concurrent.CompletableFuture<java.lang.String> publish​(java.lang.String message,
                                                                         java.lang.String channel)
        Publishes message on pubsub channel.
        Parameters:
        message - The message to publish.
        channel - The channel to publish the message on.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.publish("The cat said 'meow'!", "announcements").get();
         assert response.equals("OK");
         
      • publish

        java.util.concurrent.CompletableFuture<java.lang.String> publish​(GlideString message,
                                                                         GlideString channel)
        Publishes message on pubsub channel.
        Parameters:
        message - The message to publish.
        channel - The channel to publish the message on.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.publish(gs("The cat said 'meow'!"), gs("announcements")).get();
         assert response.equals("OK");
         
      • pubsubChannels

        java.util.concurrent.CompletableFuture<java.lang.String[]> pubsubChannels()
        Lists the currently active channels.
        Returns:
        An Array of all active channels.
        See Also:
        valkey.io for details.
        Example:
        
         String[] response = client.pubsubChannels().get();
         assert Arrays.equals(new String[] { "channel1", "channel2" });
         
      • pubsubChannelsBinary

        java.util.concurrent.CompletableFuture<GlideString[]> pubsubChannelsBinary()
        Lists the currently active channels.
        Unlike of pubsubChannels(), returns channel names as GlideStrings.
        Returns:
        An Array of all active channels.
        See Also:
        valkey.io for details.
        Example:
        
         GlideString[] response = client.pubsubChannels().get();
         assert Arrays.equals(new GlideString[] { "channel1", "channel2" });
         
      • pubsubChannels

        java.util.concurrent.CompletableFuture<java.lang.String[]> pubsubChannels​(java.lang.String pattern)
        Lists the currently active channels.
        Parameters:
        pattern - A glob-style pattern to match active channels.
        Returns:
        An Array of currently active channels matching the given pattern.
        See Also:
        valkey.io for details.
        Example:
        
         String[] response = client.pubsubChannels("news.*").get();
         assert Arrays.equals(new String[] { "news.sports", "news.weather" });
         
      • pubsubChannels

        java.util.concurrent.CompletableFuture<GlideString[]> pubsubChannels​(GlideString pattern)
        Lists the currently active channels.
        Parameters:
        pattern - A glob-style pattern to match active channels.
        Returns:
        An Array of currently active channels matching the given pattern.
        See Also:
        valkey.io for details.
        Example:
        
         GlideString[] response = client.pubsubChannels(gs("news.*")).get();
         assert Arrays.equals(new GlideString[] { gs("news.sports"), gs("news.weather") });
         
      • pubsubNumPat

        java.util.concurrent.CompletableFuture<java.lang.Long> pubsubNumPat()
        Returns the number of unique patterns that are subscribed to by clients.
        Returns:
        The number of unique patterns.
        See Also:
        valkey.io for details.
        Example:
        
         Long result = client.pubsubNumPat().get();
         assert result == 3L;
         
      • pubsubNumSub

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Long>> pubsubNumSub​(java.lang.String[] channels)
        Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
        Parameters:
        channels - The list of channels to query for the number of subscribers.
        Returns:
        A Map where keys are the channel names and values are the numbers of subscribers.
        See Also:
        valkey.io for details.
        Example:
        
         Map<String, Long> result = client.pubsubNumSub(new String[] {"channel1", "channel2"}).get();
         assert result.equals(Map.of("channel1", 3L, "channel2", 5L));
         
      • pubsubNumSub

        java.util.concurrent.CompletableFuture<java.util.Map<GlideString,​java.lang.Long>> pubsubNumSub​(GlideString[] channels)
        Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
        Parameters:
        channels - The list of channels to query for the number of subscribers.
        Returns:
        A Map where keys are the channel names and values are the numbers of subscribers.
        See Also:
        valkey.io for details.
        Example:
        
         Map<GlideString, Long> result = client.pubsubNumSub(new GlideString[] {gs("channel1"), gs("channel2")}).get();
         assert result.equals(Map.of(gs("channel1"), 3L, gs("channel2"), 5L));