@Override public void evict(final Object key) { final String sKey = String.valueOf(key); final byte[] prefixKey = prefixKey(key); if (logger.isDebugEnabled()) { logger.debug( "Removing from cache, key " + (sKey.endsWith("*") ? "pattern:" : ":") + new String(prefixKey, charset)); } client.nativeExecute( new JedisOperation() { @Override public void call(Jedis jedis) { if (sKey.endsWith("*")) { Set<byte[]> keys = jedis.keys(prefixKey); if (keys != null && keys.size() > 0) { jedis.del(keys.toArray(new byte[0][0])); } } else { jedis.del(prefixKey); } } }); }
@Override public void clear() { if (logger.isDebugEnabled()) { logger.debug("Clearing caches, key pattern:" + keyPrefix.concat("*")); } client.nativeExecute( new JedisOperation() { @Override public void call(Jedis jedis) { if (keyPrefix.isEmpty()) { jedis.flushDB(); } else { Set<byte[]> keys = jedis.keys(keyPrefix.concat("*").getBytes(charset)); jedis.del(keys.toArray(new byte[0][0])); } } }); }