Class ChunkCache

java.lang.Object
com.rvandoosselaer.blocks.ChunkCache
All Implemented Interfaces:
ChunkResolver

public class ChunkCache extends Object implements ChunkResolver
An in memory threadsafe chunk cache implementation.
  • Constructor Details

    • ChunkCache

      public ChunkCache()
    • ChunkCache

      public ChunkCache(int cacheSize)
  • Method Details

    • get

      public Optional<Chunk> get(@NonNull @NonNull com.simsilica.mathd.Vec3i location)
      Description copied from interface: ChunkResolver
      Return a Chunk optional.
      Specified by:
      get in interface ChunkResolver
      Parameters:
      location - of the chunk
      Returns:
      chunk
    • evict

      public void evict(@NonNull @NonNull com.simsilica.mathd.Vec3i location)
    • evictAll

      public void evictAll()
    • put

      public void put(@NonNull @NonNull Chunk chunk)
    • 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.