Package com.kheops.jmap.client.layers
Class JMapLocalTileCache
java.lang.Object
com.kheops.jmap.client.layers.JMapLocalTileCache
This class manages and stores tile as disk cache to reduce tile request
on the sever
- See Also:
-
Constructor Summary
ConstructorDescriptionJMapLocalTileCache
(String jmsUID, File path, long diskCacheSize) Constructs the JMapLocalTileCache instance the data will be stored on the specified path -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
destroy()
long
getStoredTimestamp
(int projectId, int layerId) long
getTilesSize
(int projectId, int layerId) Returns the size on disk for a layer in a projectvoid
init()
boolean
isInCache
(int projectId, int layerId, int tilePos) Checks if specific tile is in cachebyte[]
retrieveTile
(int projectId, int layerId, int tilePos) Retrieves a compressed tile from the cachevoid
setStoredTimestamp
(int projectId, int layerId, long timeStamp) void
storeTile
(byte[] tileData, int projectId, int layerId, int tilePos, long expiration) Stores the tile on disk
-
Constructor Details
-
JMapLocalTileCache
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 tilesdiskCacheSize
- 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 storedprojectId
- the id of the projectlayerId
- the id of the layer from which the tile will be storedtilePos
- 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 projectlayerId
- the id of the layer from which the tile will be retrievedtilePos
- 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 projectlayerId
- the id of the layer of the tile search fortilePos
- 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
- Throws:
IOException
-
setStoredTimestamp
- Throws:
IOException
-