/** * The time that the stored tile resource was created * * @return */ public long getTSCreated() { return stObj.getCreated(); }
/** Store a tile. */ public void put(TileObject stObj) throws StorageException { final File fh = getFileHandleTile(stObj, true); final long oldSize = fh.length(); final boolean existed = oldSize > 0; writeFile(fh, stObj, existed); // mark the last modification as the tile creation time if set, otherwise // we'll leave it to the writing time if (stObj.getCreated() > 0) { try { fh.setLastModified(stObj.getCreated()); } catch (Exception e) { log.debug("Failed to set the last modified time to match the tile request time", e); } } /* * This is important because listeners may be tracking tile existence */ stObj.setBlobSize((int) padSize(stObj.getBlobSize())); if (existed) { listeners.sendTileUpdated(stObj, padSize(oldSize)); } else { listeners.sendTileStored(stObj); } }
public boolean retrieve(long maxAge) throws GeoWebCacheException { try { if (isMetaTileCacheOnly) { boolean cached = storageBroker.getTransient((TileObject) stObj); this.setCacheResult(cached ? CacheResult.HIT : CacheResult.MISS); return cached; } boolean ret = storageBroker.get((TileObject) stObj); // Do we use expiration, and if so, is the tile recent enough ? if (ret && maxAge > 0 && stObj.getCreated() + maxAge < System.currentTimeMillis()) { ret = false; } if (ret) { this.setCacheResult(CacheResult.HIT); } else { this.setCacheResult(CacheResult.MISS); } return ret; } catch (StorageException se) { log.warn(se.getMessage()); return false; } }
assertEquals(to2.getCreated(), to3.getCreated());
assertThat(resourceToString(getTile.getBlob()), is("IMAGE-10-50-5")); assertThat(getTile.getCreated(), greaterThan(System.currentTimeMillis() - 60000));
tileProto.getStorageBroker().put(tile); tileProto.getStorageObject().setCreated(tile.getCreated()); } catch (StorageException e) { throw new GeoWebCacheException(e);