Package com.rvandoosselaer.blocks
Class ChunkCache
java.lang.Object
com.rvandoosselaer.blocks.ChunkCache
- All Implemented Interfaces:
ChunkResolver
An in memory threadsafe chunk cache implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
evict
(@NonNull com.simsilica.mathd.Vec3i location) void
evictAll()
get
(@NonNull com.simsilica.mathd.Vec3i location) Return a Chunk optional.long
getSize()
void
maintain()
By default, Caffeine does not perform cleanup and evict values "automatically" or instantly after a value expires.void
-
Constructor Details
-
ChunkCache
public ChunkCache() -
ChunkCache
public ChunkCache(int cacheSize)
-
-
Method Details
-
get
Description copied from interface:ChunkResolver
Return a Chunk optional.- Specified by:
get
in interfaceChunkResolver
- Parameters:
location
- of the chunk- Returns:
- chunk
-
evict
public void evict(@NonNull @NonNull com.simsilica.mathd.Vec3i location) -
evictAll
public void evictAll() -
put
-
getSize
public long getSize() -
maintain
public void maintain()By default, Caffeine does not perform cleanup and evict values "automatically" or instantly after a value expires. Instead, it performs small amounts of maintenance work after write operations or occasionally after read operations if writes are rare. If your cache is high-throughput then you don't have to worry about performing cache maintenance to clean up expired entries and the like. If your cache is read and written to rarely, you may wish to leverage an external thread, that calls Cache.cleanUp() when appropriate.
-