java.lang.Object
id.luckynetwork.lyrams.lyralibs.core.database.redis.RedisHandler

public class RedisHandler extends Object
  • Constructor Details

  • Method Details

    • connect

      public boolean connect()
      We create three JedisPools, one for each of the Jedis instances we'll be using, and then we ping each of them to make sure they're working.
      Returns:
      A boolean value.
    • isConnected

      public boolean isConnected()
      If any of the three pools are not connected, or if the pubSub is not subscribed, then return false.
      Returns:
      A boolean value.
    • reconnect

      public CompletableFuture<Void> reconnect()
      It tries to reconnect to the redis server
      Returns:
      A CompletableFuture that will run the reconnection process.
    • registerObject

      public void registerObject(Class<?> clazz)
      If the class has the RedisObject annotation, add it to the objectMap
      Parameters:
      clazz - The class that is being registered.
    • registerListener

      public void registerListener(Object clazz)
      It loops through all the methods in the class, and if it finds a method with the RedisListener annotation, it checks if the method has one parameter, and if it does, it adds the method to the dataMap
      Parameters:
      clazz - The class that contains the method that will be called when a packet is received.
    • broadcastObject

      public void broadcastObject(Object object)
      This function sends an object to all connected clients
      Parameters:
      object - The object to send.
    • sendObject

      public void sendObject(Object object, @NotNull @NotNull String targetServer)
      It sends an object to a specific server
      Parameters:
      object - The object to send
      targetServer - The server to send the object to.
    • close

      public void close()
      > Close the redis client