Class UserPlayTimeCache

java.lang.Object
de.murmelmeister.murmelapi.user.playtime.UserPlayTimeCache
All Implemented Interfaces:
RefreshListener, AutoCloseable

public class UserPlayTimeCache extends Object implements RefreshListener, AutoCloseable
  • Field Details

    • ALL_KEY

      private static final String ALL_KEY
      See Also:
    • database

      private final de.murmelmeister.library.database.Database database
    • tableName

      private final String tableName
    • cache

      private final com.github.benmanes.caffeine.cache.LoadingCache<Integer,UserPlayTime> cache
    • listCache

      private final com.github.benmanes.caffeine.cache.LoadingCache<String,List<UserPlayTime>> listCache
    • fetchLimit

      private final Long fetchLimit
  • Constructor Details

    • UserPlayTimeCache

      public UserPlayTimeCache(de.murmelmeister.library.database.Database database, String tableName, Long fetchLimit, long cacheCapcity, Duration refreshInterval)
  • Method Details

    • onRefresh

      public void onRefresh(RefreshEvent<?> event)
      Specified by:
      onRefresh in interface RefreshListener
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • refreshAll

      private void refreshAll()
    • refreshSingle

      private void refreshSingle(int userId)
    • loadAllFromDatabase

      private List<UserPlayTime> loadAllFromDatabase()
    • loadById

      private UserPlayTime loadById(int userId)
    • get

      public UserPlayTime get(int userId)
    • put

      public void put(UserPlayTime playTime)
    • remove

      public void remove(int userId)
    • clear

      public void clear()
    • getCachedPlayTimes

      public List<UserPlayTime> getCachedPlayTimes()