Class JMapLocalTileCache

java.lang.Object
com.kheops.jmap.client.layers.JMapLocalTileCache

public class JMapLocalTileCache extends Object
This class manages and stores tile as disk cache to reduce tile request on the sever
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    JMapLocalTileCache(String jmsUID, File path, long diskCacheSize)
    Constructs the JMapLocalTileCache instance the data will be stored on the specified path
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    deleteTile(int projectId, int layerId, int tilePos)
    Remove the specified tile from the cache of the specified layer.
    void
    deleteTiles(int projectId, int layerId)
    Removes all tiles from the cache of the specified layer.
    void
     
    long
    getStoredTimestamp(int projectId, int layerId)
     
    long
    getTilesSize(int projectId, int layerId)
    Returns the size on disk for a layer in a project
    void
     
    boolean
    isInCache(int projectId, int layerId, int tilePos)
    Checks if specific tile is in cache
    byte[]
    retrieveTile(int projectId, int layerId, int tilePos)
    Retrieves a compressed tile from the cache
    void
    setStoredTimestamp(int projectId, int layerId, long timeStamp)
     
    void
    storeTile(byte[] tileData, int projectId, int layerId, int tilePos, long expiration)
    Stores the tile on disk

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JMapLocalTileCache

      public JMapLocalTileCache(String jmsUID, File path, long diskCacheSize)
      Constructs the JMapLocalTileCache instance the data will be stored on the specified path
      Parameters:
      jmsUID - the JMapServer Unique ID (Serial Number)
      path - the base directory for storing the tiles
      diskCacheSize - the allowed size to be used as disk cache. -1 means unlimited.
  • Method Details

    • init

      public void init()
    • destroy

      public void destroy()
    • storeTile

      public void storeTile(byte[] tileData, int projectId, int layerId, int tilePos, long expiration)
      Stores the tile on disk
      Parameters:
      tileData - the tile data to be stored
      projectId - the id of the project
      layerId - the id of the layer from which the tile will be stored
      tilePos - the tile position on the layer from which the tile will be stored
    • retrieveTile

      public byte[] retrieveTile(int projectId, int layerId, int tilePos)
      Retrieves a compressed tile from the cache
      Parameters:
      projectId - the id of the project
      layerId - the id of the layer from which the tile will be retrieved
      tilePos - the tile position on the layer from which the tile will be retrieved
      Returns:
      the compressed tile
    • isInCache

      public boolean isInCache(int projectId, int layerId, int tilePos)
      Checks if specific tile is in cache
      Parameters:
      projectId - the id of the project
      layerId - the id of the layer of the tile search for
      tilePos - the position of the tile in the layer
      Returns:
      true if the cache contains the specific tile false otherwise
    • deleteTile

      public void deleteTile(int projectId, int layerId, int tilePos)
      Remove the specified tile from the cache of the specified layer.
      Parameters:
      projectId - the project Id.
      layerId - the layer id.
      tilePos - the position of the tile in the layer
    • deleteTiles

      public void deleteTiles(int projectId, int layerId)
      Removes all tiles from the cache of the specified layer.
      Parameters:
      projectId - the project Id.
      layerId - the layer id.
    • getTilesSize

      public long getTilesSize(int projectId, int layerId)
      Returns the size on disk for a layer in a project
      Parameters:
      projectId - the project id.
      layerId - the layer id.
      Returns:
      the size on disk for a layer in a project.
    • getStoredTimestamp

      public long getStoredTimestamp(int projectId, int layerId) throws IOException
      Throws:
      IOException
    • setStoredTimestamp

      public void setStoredTimestamp(int projectId, int layerId, long timeStamp) throws IOException
      Throws:
      IOException