Skip to content

HyperSkys/pRedis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pRedis [v1.0.8-RELEASE]

Java GitHub GitHub Discord

pRedis is a universal Redis and MongoDB library.

Download Instructions

To download and use pRedis go to the releases tab download the pRedis.jar file and add it to your artifacts or dependencies, via the JitPack repository.

API Introduction

Below is an example of how you would create a packet that you would listen for.

import dev.hyperskys.predis.redis.packets.RedisPacket;
import dev.hyperskys.predis.redis.packets.annotations.Packet;
import org.json.JSONObject;

@Packet(name = "broadcast")
public class BroadcastPacket extends RedisPacket {
    @Override
    public void onReceive(JSONObject jsonObject) {
        System.out.println(jsonObject.getString("message"));
    }
}

Below is an example of how you would send a broadcast packet.

import dev.hyperskys.predis.redis.RedisDB;
import dev.hyperskys.predis.redis.utils.PacketBuilder;

public class PacketSender {

    private static final RedisDB redisDB = new RedisDB(
            "localhost",
            6379,
            false,
            null,
            5000
    );

    public static void main(String[] args) {
        PRedis.init(PacketSender.class, redisDB);
        redisDB.write(new PacketBuilder("broadcast").addData("message", "Hello, World!").build());
    }
}

Below is an example of creating a database and a collection and adding a document to that collection.

import dev.hyperskys.predis.mongodb.MongoDB;
import dev.hyperskys.predis.mongodb.utils.DocumentBuilder;

public class MongoTest {
    
    private static final MongoDB mongoDB = new MongoDB("root:password@localhost:27017");
    
    public static void main(String[] args) {
        mongoDB.insertDocument("RandomTest", "testing", new DocumentBuilder("test", "test")
                .add("another-test", 123)
                .build()
        );
    }
}

Project Intergration

There are two major different types of ways of integrating this API into your project, below will list the way of integrating while using Maven and Gradle.

Maven

For maven please add these to your repositories and dependencies.

<repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
</repository>
 <dependency>
    <groupId>com.github.HyperSkys</groupId>
    <artifactId>pRedis</artifactId>
    <version>1.0.8-RELEASE</version>
</dependency>

Gradle

For gradle add this to your repositories and dependencies.

maven { url 'https://jitpack.io' }
implementation 'com.github.HyperSkys:Configurator:1.0.8-RELEASE'

Thanks

Thanks to Badbird5907 for some example code, and some ideas that were used in this project, it would have not been possible without his code and help.

Discord

You can join my discord using this invite https://discord.gg/Y59DddqZZR please join the server if you have any issues or suggestions that you would like to make do not make random issues when you could just use the discord.

License

This project is licensed under Eclipse Public License