/** Invoked after a non-sticky session is removed from memcached. */ protected void onAfterDeleteFromMemcached(@Nonnull final String sessionId) { final long start = System.currentTimeMillis(); final String validityInfoKey = _sessionIdFormat.createValidityInfoKeyName(sessionId); _memcached.delete(validityInfoKey); if (_storeSecondaryBackup) { _memcached.delete(_sessionIdFormat.createBackupKey(sessionId)); _memcached.delete(_sessionIdFormat.createBackupKey(validityInfoKey)); } _stats.registerSince(NON_STICKY_AFTER_DELETE_FROM_MEMCACHED, start); }
@Override public void del(String key) { if (StringTools.isEmpty(key) || !enable) { return; } client.delete(buildKey(key)); }
/** * 移除一个对象 * * @see * @param key * @param value * @return * @author futuremining * @date 2009-1-12 * @version 1.0.0 */ @Override public boolean remove(String key) { boolean ret = false; Future<Boolean> f = mc1.delete(key); Future<Boolean> f2 = mc2.delete(key); try { ret = f.get(opTimeout, TimeUnit.SECONDS) && f2.get(opTimeout, TimeUnit.SECONDS); // !! // 该行的判断只限于2台不同的memcached服务器 } catch (TimeoutException e) { // Since we don't need this, go ahead and cancel the // operation. This // is not strictly necessary, but it'll save some work on // the server. log.info("[FAIL]time out when getting objects from cache server2..."); f.cancel(false); f2.cancel(false); // Do other timeout related stuff } catch (InterruptedException e) { // TODO Auto-generated catch block log.error("[ERROR]exception when deleting fengchao cache - thread been interrupted...", e); f.cancel(false); f2.cancel(false); ret = false; } catch (ExecutionException e) { // TODO Auto-generated catch block log.error( "[ERROR]exception when deleting fengchao cache - exception when getting status...", e); f.cancel(false); f2.cancel(false); ret = false; } catch (Exception e) { log.error("[ERROR]exception when deleting fengchao cache - other exceptions...", e); f.cancel(false); f2.cancel(false); ret = false; } log.info("[REMOVE]" + ret + "\tKey=" + key); return ret; // 如果配了相同的,即使 remove成功 // ,也会返回false,因此此返回值有意义仅当配置两台不同memcached服务器 }
public V remove(Object key) { V myObj = (V) get(key); memcachedClient.delete(key.toString()); // Key index update String index = (String) get(name + KEYS_LOCATION); index = index.replace(key.toString() + KEY_SEPARATOR, ""); memcachedClient.set(name + KEYS_LOCATION, NOT_EXPIRE, index); return myObj; }
protected void releaseLock(@Nonnull final String sessionId) { try { if (_log.isDebugEnabled()) { _log.debug("Releasing lock for session " + sessionId); } final long start = System.currentTimeMillis(); _memcached.delete(_sessionIdFormat.createLockName(sessionId)).get(); _stats.registerSince(RELEASE_LOCK, start); } catch (final Exception e) { _log.warn("Caught exception when trying to release lock for session " + sessionId, e); } }
@DELETE @Path("delete") public String delete(@QueryParam("key") String key) { try { MemcachedClient client = MccFactory.getConst("localhost").getMemcachedClient(); String keys = (String) client.get("mykeys"); keys = (keys == null) ? "" : keys; keys = keys.replace(key + "/", ""); client.replace("mykeys", 30000, keys); client.delete(key); } catch (Exception e) { e.printStackTrace(); return getStringStackTrace(e); } return "Removed value at " + key; }
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); /* Get Session */ HttpSession s = req.getSession(true); /* Make sure user is logged in */ if (s.getAttribute("login") == null || (String) s.getAttribute("login") != "go") { req.getRequestDispatcher("login.jsp").forward(req, res); } try { String dbuser = this.getServletContext().getInitParameter("dbuser"); String dbpassword = this.getServletContext().getInitParameter("dbpassword"); Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/project", dbuser, dbpassword); Statement stmt = conn.createStatement(); stmt.execute( "INSERT INTO songs VALUES(null, '" + req.getParameter("song_name") + "', '" + req.getParameter("artist") + "', '" + req.getParameter("album") + "', '" + req.getParameter("genre") + "', 0)"); stmt.close(); conn.close(); // delete memcache since new song is now added MemcachedClient c = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211)); c.delete("master"); req.getRequestDispatcher("add_song_success.jsp").forward(req, res); } catch (Exception e) { out.println(e.getMessage()); } }
@Override public void remove(String key, String category) { writeClient.delete(key); }
@Override public void remove(String key) { memcached.delete(key.toString()); }
public void remove(String key) { client.delete(key); }