Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A simple Redis client written in Groovy and using Jedis
@GrabResolver(name='Maven Central', root='')
@Grab(group='redis.clients', module='jedis', version='3.5.2')
import redis.clients.jedis.Jedis
import redis.clients.jedis.JedisPubSub
class DefaultPubSubImpl extends JedisPubSub {
public void onMessage(String channel, String message) {
println "channel: $channel, message: $message"
public void onPMessage(String pattern, String channel, String message) {}
public void onSubscribe(String channel, int subscribedChannels) {}
public void onUnsubscribe(String channel, int subscribedChannels) {}
public void onPUnsubscribe(String pattern, int subscribedChannels) {}
public void onPSubscribe(String pattern, int subscribedChannels) {}
def subscriber = new DefaultPubSubImpl ()
Jedis jedis = new Jedis("localhost", 6379, 0)
jedis.subscribe (subscriber, "updates")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment