Class SolutionCache

java.lang.Object
mazealgo.model.server.SolutionCache

public class SolutionCache extends Object
Caches solved Solutions on disk keyed by SHA-256 of the maze's byte representation. A second solve request for the same maze short-circuits the search and reads the cached solution instead — orders of magnitude faster than re-running BestFirstSearch.

Storage layout: one serialized Solution per file under the configured directory (default $TMPDIR/MazeAlgo/cache), named <sha256>.sol.

  • Constructor Details

    • SolutionCache

      public SolutionCache()
    • SolutionCache

      public SolutionCache(Path cacheDir)
  • Method Details

    • getCacheDir

      public Path getCacheDir()
    • get

      public Optional<Solution> get(byte[] mazeBytes)
    • put

      public void put(byte[] mazeBytes, Solution solution)