本文整理了Java中net.spy.memcached.MemcachedClient.delete()
方法的一些代码示例,展示了MemcachedClient.delete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MemcachedClient.delete()
方法的具体详情如下:
包路径:net.spy.memcached.MemcachedClient
类名称:MemcachedClient
方法名:delete
[英]Delete the given key from the cache.
[中]从缓存中删除给定的密钥。
代码示例来源:origin: ninjaframework/ninja
public void delete(String key) {
client.delete(key);
}
代码示例来源:origin: ninjaframework/ninja
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;
}
代码示例来源:origin: brianfrankcooper/YCSB
@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;
}
}
代码示例来源:origin: apache/hbase
@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;
}
代码示例来源:origin: qiujiayu/AutoLoadCache
@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);
}
}
}
代码示例来源:origin: apache/httpcomponents-client
@Override
protected void delete(final String storageKey) throws ResourceIOException {
client.delete(storageKey);
}
代码示例来源:origin: magro/memcached-session-manager
@Override
public Future<Boolean> delete(String key) {
return _memcached.delete(key);
}
代码示例来源:origin: pippo-java/pippo
@Override
public void delete(String sessionId) {
this.sessions.delete(sessionId);
}
代码示例来源:origin: apache/httpcomponents-client
@Override
protected Cancellable delete(final String storageKey, final FutureCallback<Boolean> callback) {
return operation(client.delete(storageKey), callback);
}
代码示例来源:origin: magro/memcached-session-manager
@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();
}
代码示例来源:origin: magro/memcached-session-manager
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 ) );
代码示例来源:origin: net.spy/spymemcached
/**
* 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);
}
代码示例来源:origin: apache/apex-malhar
@Override
public void remove(Object key)
{
memcacheClient.delete(key.toString());
}
代码示例来源:origin: org.apache.apex/malhar-contrib
@Override
public void remove(Object key)
{
memcacheClient.delete(key.toString());
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play
@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;
}
代码示例来源:origin: org.wicketstuff/wicketstuff-datastore-memcached
@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);
}
}
代码示例来源:origin: org.datanucleus/datanucleus-cache
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
}
代码示例来源:origin: indeedeng/lsmtree
public void delete(K key) {
String str = keyStringifier.toString(key);
if (log.isTraceEnabled()) {
log.trace("Deleting key " + str);
}
memcache.delete(prefix + str);
}
代码示例来源:origin: io.snappydata/gemfire-junit
public void testDelete() throws Exception {
MemcachedClient client = bootstrapClient();
Future<Boolean> b = client.delete("key");
assertTrue(b.get());
b = client.delete("nonExistentkey");
assertFalse(b.get());
}
代码示例来源:origin: mugglmenzel/serverless-examples-cached-rds-ws
@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;
}
}
内容来源于网络,如有侵权,请联系作者删除!