public class CacheToDatabaseReaderWriter extends java.lang.Object implements CacheReaderWriter
Constructor and Description |
---|
CacheToDatabaseReaderWriter(SqlDataManager dataManager,
java.lang.String cacheTableName) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getMainTable()
Validates that the cache can be read from and written to, and if so returns the name of the main table (which the cache references)
|
java.util.List<CacheBlock> |
readCache(long id)
Reads all the cache blocks for the given id from the database
|
java.util.List<CacheBlock> |
readCache(long id,
int maxNum)
Reads up to the maximum number of cache blocks for the given id from the database
|
boolean |
validateCacheStructure()
Validates that the cache can be read from and written to
|
void |
writeCache(long id,
CacheBlock block)
Writes a cache block for the given id
|
public CacheToDatabaseReaderWriter(@NotNull SqlDataManager dataManager, @NotNull java.lang.String cacheTableName)
@NotNull public java.util.List<CacheBlock> readCache(long id)
CacheReaderWriter
readCache
in interface CacheReaderWriter
id
- The id of the main table row in the database@NotNull public java.util.List<CacheBlock> readCache(long id, int maxNum)
CacheReaderWriter
readCache
in interface CacheReaderWriter
id
- The id of the main table row in the databasemaxNum
- The maximum number of blocks to load, or negative to indicate infinitepublic void writeCache(long id, @NotNull CacheBlock block)
writeCache
in interface CacheReaderWriter
id
- The id of the main table row in the database (can be null if the main row failed to write)block
- The block of data to write@Nullable public java.lang.String getMainTable()
CacheReaderWriter
getMainTable
in interface CacheReaderWriter
public boolean validateCacheStructure()
validateCacheStructure
in interface CacheReaderWriter