Java Code Examples for io.lettuce.core.api.async.RedisAsyncCommands#del()
The following examples show how to use
io.lettuce.core.api.async.RedisAsyncCommands#del() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LettuceRedisCacheManager.java From AutoLoadCache with Apache License 2.0 | 5 votes |
@Override public void delete(Set<CacheKeyTO> keys) { // 为了提升性能,开启pipeline this.connection.setAutoFlushCommands(false); RedisAsyncCommands<byte[], byte[]> asyncCommands = connection.async(); try { for (CacheKeyTO cacheKeyTO : keys) { String cacheKey = cacheKeyTO.getCacheKey(); if (null == cacheKey || cacheKey.isEmpty()) { continue; } if (log.isDebugEnabled()) { log.debug("delete cache {}", cacheKey); } String hfield = cacheKeyTO.getHfield(); if (null == hfield || hfield.isEmpty()) { asyncCommands.del(KEY_SERIALIZER.serialize(cacheKey)); } else { asyncCommands.hdel(KEY_SERIALIZER.serialize(cacheKey), KEY_SERIALIZER.serialize(hfield)); } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { this.connection.flushCommands(); } }
Example 2
Source File: LettuceIntegrationLiveTest.java From tutorials with MIT License | 3 votes |
@Test public void givenValues_thenSaveAsRedisListAsync() throws Exception { RedisAsyncCommands<String, String> asyncCommands = redisConnection.async(); String listName = "tasks"; String firstTask = "firstTask"; String secondTask = "secondTask"; asyncCommands.del(listName); asyncCommands.lpush(listName, firstTask); asyncCommands.lpush(listName, secondTask); RedisFuture<String> redisFuture = asyncCommands.rpop(listName); String nextTask = redisFuture.get(); Assert.assertEquals(firstTask, nextTask); asyncCommands.del(listName); asyncCommands.lpush(listName, firstTask); asyncCommands.lpush(listName, secondTask); redisFuture = asyncCommands.lpop(listName); nextTask = redisFuture.get(); Assert.assertEquals(secondTask, nextTask); }