Class SQLDialect

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

public class SQLDialect extends Dialect
SQL dialect for a specific type of database
  • Field Details

  • Constructor Details

  • Method Details

    • getStats

      @NotNull public @NotNull Dialect.Stats getStats()
      Specified by:
      getStats in class Dialect
    • getFromCacheImpl

      @Nullable public @Nullable CachedValue 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 CachedValue, null if it isn't cached
    • setToCacheImpl

      public void setToCacheImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull String key, @NotNull @NotNull CachedValue 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 CachedValue
    • 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 public @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 List<FailedSet> setToDatabaseImpl(@NotNull @NotNull String table, @NotNull @NotNull String target, @NotNull @NotNull Map<String,String> 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:
      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
    • createTablesKeys

      public void createTablesKeys(@NotNull @NotNull Map<String,Set<String>> tablesKeys)
      Create the given tables and keys in the database
      Parameters:
      tablesKeys - the tables and keys to create
    • warmup

      public void warmup(@NotNull @NotNull String rawTable)
      Warms up jOOQ's SELECT/UPDATE/INSERT code paths for the given table so the classloading/JIT cost of first use doesn't impact real get/set/remove call
      Uses a sentinel target that can never match a real row, so nothing is ever written or needs cleaning up
      Parameters:
      rawTable - the (unprefixed) table to warm up against