Class JSONDialect

java.lang.Object
xyz.srnyx.annoyingapi.storage.dialects.Dialect
xyz.srnyx.annoyingapi.storage.dialects.JSONDialect

public class JSONDialect extends Dialect
Data dialect for JSON database
  • Constructor Details

  • Method Details

    • getFromCacheImpl

      @Nullable public @Nullable Value getFromCacheImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull String key)
      Description copied from class: Dialect
      Get a value from the cache
      Specified by:
      getFromCacheImpl in class Dialect
      Parameters:
      table - the table
      target - the target
      key - the key
      Returns:
      the value inside a Value, null if it isn't cached
    • setToCacheImpl

      public void setToCacheImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull String key, @NotNull @NotNull Value value)
      Description copied from class: Dialect
      Set a value to the cache
      Specified by:
      setToCacheImpl in class Dialect
      Parameters:
      table - the table
      target - the target
      key - the key
      value - the value inside a Value
    • markRemovedInCacheImpl

      public void markRemovedInCacheImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull String key)
      Description copied from class: Dialect
      Mark a value as removed in the cache
      Specified by:
      markRemovedInCacheImpl in class Dialect
      Parameters:
      table - the table
      target - the target
      key - the key
    • saveCacheImpl

      public void saveCacheImpl()
      Description copied from class: Dialect
      Save all cache data to the database
      Specified by:
      saveCacheImpl in class Dialect
    • saveCacheImpl

      public void saveCacheImpl(@NotNull @NotNull String table, @NotNull @NotNull String target)
      Description copied from class: Dialect
      Save a specific target in a table to the cache
      Specified by:
      saveCacheImpl in class Dialect
      Parameters:
      table - the table to save in
      target - the target to save
    • getMigrationDataFromDatabaseImpl

      @NotNull protected @NotNull Optional<Dialect.MigrationData> getMigrationDataFromDatabaseImpl(@NotNull @NotNull DataManager newManager)
      Description copied from class: Dialect
      Get migration data from the database
      Specified by:
      getMigrationDataFromDatabaseImpl in class Dialect
      Parameters:
      newManager - the new DataManager to migrate to
      Returns:
      the migration data, empty if something went wrong
    • getFromDatabaseImpl

      @NotNull protected @NotNull Optional<String> getFromDatabaseImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull String key)
      Description copied from class: Dialect
      Get a value from the database
      Specified by:
      getFromDatabaseImpl in class Dialect
      Parameters:
      table - the table to get from
      target - the target to get from
      key - the key to get
      Returns:
      the value, empty if not found
    • setToDatabaseImpl

      @Nullable protected @Nullable FailedSet setToDatabaseImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull String key, @NotNull @NotNull String value)
      Description copied from class: Dialect
      Set a value to the database
      Specified by:
      setToDatabaseImpl in class Dialect
      Parameters:
      table - the table to set to
      target - the target to set to
      key - the key to set
      value - the value to set
      Returns:
      the failed value information, null if successful
    • setToDatabaseImpl

      @NotNull protected @NotNull Set<FailedSet> setToDatabaseImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull ConcurrentHashMap<String,Value> data)
      Description copied from class: Dialect
      Set multiple values to the database
      Specified by:
      setToDatabaseImpl in class Dialect
      Parameters:
      table - the table to set to
      target - the target to set to
      data - the data to set
      Returns:
      set of failed values as FailedSets
    • removeFromDatabaseImpl

      protected boolean removeFromDatabaseImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull String key)
      Description copied from class: Dialect
      Remove a value from the database
      Specified by:
      removeFromDatabaseImpl in class Dialect
      Parameters:
      table - the table to remove from
      target - the target to remove from
      key - the key to remove
      Returns:
      true if the value was successfully removed, false otherwise