@DELETE @Path("{route_id}") @Produces(MediaType.APPLICATION_JSON) public String deletePlace(@PathParam("route_id") String routeID) { syncCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO)); JSONObject reply = new JSONObject(); try { syncCache.delete(routeID); return reply .append("status", "OK") .append("message", "successfully deleted route " + routeID + " from " + "memcache") .toString(); } catch (Exception e) { return new JSONObject().append("status", "fail").append("message", e.getMessage()).toString(); } }
@DELETE public void deleteIt() { // delete an entity from the datastore // just print a message upon exception (don't throw) DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService(); if (syncCache.get(keyname) != null) { syncCache.delete(keyname); } Key entKey = KeyFactory.createKey("TaskData", keyname); try { Entity ent = datastore.get(entKey); datastore.delete(entKey); System.err.println("TaskData deleted in Datastore"); } catch (EntityNotFoundException e) { System.err.println("TaskData not found in Datastore"); } }
@Override public void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { final MemcacheService cacheShared = MemcacheServiceFactory.getMemcacheService(); if (cacheShared.contains(MemCacheKey.activePoints)) { try { final Map<String, Point> points = (Map<String, Point>) cacheShared.get(MemCacheKey.activePoints); cacheShared.delete( MemCacheKey.activePoints); // TODO possible race condition with record value service for (final Point point : points.values()) { TaskFactory.getInstance().startMoveCachedValuesToStoreTask(point); } } catch (InvalidValueException e) { cacheShared.clearAll(); } } }