Redstone is a Redis pub-sub implementation using Jedis which enables easy and effective handling of data.
An example implementation can be found here if you don't want a step-by-step walkthrough.
Implementing Redstone is incredibly easy. First you'll need to obtain an instance of the Redstone
interface:
final Redstone redstone = Redstone.builder()
.address("127.0.0.1")
.port(6379)
.channel("redis-channel-here")
.build();
Packets can be published with the redstone#sendPacket
method.
A packet is simply a class that implements RedstonePacket
:
public class SomePacket implements RedstonePacket {
private final String someString;
private final UUID someUuid;
private final double someDouble;
public SomePacket(String someDouble, UUID someUuid, double someDouble) {
this.someString = someString;
this.someUuid = someUuid;
this.someDouble = someDouble;
}
@Override
public void onReceive() {
// Handle receiving of this packet here
}
}
When receiving a packet, it will automatically be deserialzied using the Google Gson library, meaning you might have to add support for non-supported objects.
This project uses the MIT license, meaning you're pretty much free to do whatever with it!