public void delete(String key) { client.delete(key); }
public boolean safeDelete(String key) { Future<Boolean> future = client.delete(key); try { return future.get(1, TimeUnit.SECONDS); } catch (Exception e) { future.cancel(false); } return false; }
@Override public Status delete(String table, String key) { key = createQualifiedKey(table, key); try { OperationFuture<Boolean> future = memcachedClient().delete(key); return getReturnCode(future); } catch (Exception e) { logger.error("Error deleting value", e); return Status.ERROR; } }
@Override public boolean evictBlock(BlockCacheKey cacheKey) { try { cacheStats.evict(); return client.delete(cacheKey.toString()).get(); } catch (InterruptedException e) { LOG.warn("Error deleting " + cacheKey.toString(), e); Thread.currentThread().interrupt(); } catch (ExecutionException e) { if (LOG.isDebugEnabled()) { LOG.debug("Error deleting " + cacheKey.toString(), e); } } return false; }
@Override public void delete(Set<CacheKeyTO> keys) throws CacheCenterConnectionException { if (null == memcachedClient || null == keys || keys.isEmpty()) { return; } String hfield; for (CacheKeyTO cacheKeyTO : keys) { if (null == cacheKeyTO) { continue; } String cacheKey = cacheKeyTO.getCacheKey(); if (null == cacheKey || cacheKey.isEmpty()) { continue; } hfield = cacheKeyTO.getHfield(); if (null != hfield && hfield.length() > 0) { throw new RuntimeException("memcached does not support hash cache."); } try { String allKeysPattern = "*"; if (allKeysPattern.equals(cacheKey)) { memcachedClient.flush(); } else { memcachedClient.delete(cacheKey); } } catch (Exception e) { log.error(e.getMessage(), e); } } }
@Override protected void delete(final String storageKey) throws ResourceIOException { client.delete(storageKey); }
@Override public Future<Boolean> delete(String key) { return _memcached.delete(key); }
@Override public void delete(String sessionId) { this.sessions.delete(sessionId); }
@Override protected Cancellable delete(final String storageKey, final FutureCallback<Boolean> callback) { return operation(client.delete(storageKey), callback); }
@SuppressWarnings("unchecked") @BeforeMethod public void setup() throws Exception { final StandardContext context = createContext(); context.setBackgroundProcessorDelay( 1 ); // needed for test of updateExpiration final SessionManager manager = createSessionManager(context); _service = manager.getMemcachedSessionService(); _service.setMemcachedNodes( "n1:127.0.0.1:11211" ); _service.setSessionBackupAsync( false ); _service.setSticky( true ); _memcachedMock = mock( MemcachedClient.class ); final OperationFuture<Boolean> setResultMock = mock( OperationFuture.class ); when( setResultMock.get( ) ).thenReturn( Boolean.TRUE ); when( setResultMock.get( anyInt(), any( TimeUnit.class ) ) ).thenReturn( Boolean.TRUE ); when( _memcachedMock.set( any( String.class ), anyInt(), any(), any( Transcoder.class ) ) ).thenReturn( setResultMock ); final OperationFuture<Boolean> deleteResultMock = mock( OperationFuture.class ); when( deleteResultMock.get() ).thenReturn( Boolean.TRUE ); when( _memcachedMock.delete( anyString() ) ).thenReturn( deleteResultMock ); startInternal( manager, _memcachedMock ); _executor = Executors.newCachedThreadPool(); }
verify( _memcachedMock, times( 1 ) ).delete( eq( oldSessionId ) ); verify( _memcachedMock, times( 1 ) ).set( eq( session.getId() ), anyInt(), any(), any( Transcoder.class ) ); Thread.sleep(200l); verify( _memcachedMock, times( 1 ) ).delete( eq( new SessionIdFormat().createValidityInfoKeyName( oldSessionId ) ) ); verify( _memcachedMock, times( 1 ) ).set( eq( new SessionIdFormat().createValidityInfoKeyName( session.getId() ) ), anyInt(), any(), any( Transcoder.class ) );
/** * Delete the given key from the cache. * * @param key the key to delete * @return whether or not the operation was performed * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public OperationFuture<Boolean> delete(String key) { return delete(key, 0L); }
@Override public void remove(Object key) { memcacheClient.delete(key.toString()); }
@Override public void remove(Object key) { memcacheClient.delete(key.toString()); }
@Override public boolean safeDelete(String key) { Future<Boolean> future = client.delete(key); try { return future.get(1, TimeUnit.SECONDS); } catch (Exception e) { future.cancel(false); } return false; }
@Override public void removeData(String sessionId) { Set<String> keys = keysPerSession.get(sessionId); if (keys != null) { for (String key : keys) { client.delete(key); } keysPerSession.remove(sessionId); LOG.debug("Removed the data for session '{}'", sessionId); } }
public void evict(Query query) { String baseKey = QueryUtils.getKeyForQueryResultsCache(query, null); client.delete(keyPrefix + baseKey); // TODO Delete all entries for this query (with any possible set of params) i.e key starting baseKey }
public void delete(K key) { String str = keyStringifier.toString(key); if (log.isTraceEnabled()) { log.trace("Deleting key " + str); } memcache.delete(prefix + str); }
@Override public boolean delete(String key) { try { return getClient().delete(key).get(timeout, timeoutUnit); } catch (Exception e) { logger.log(String.format("Exception or timeout while deleting key %s in cache. %s", key, e.getMessage())); return false; } }