List of usage examples for org.springframework.data.redis.connection RedisConnection set
@Nullable Boolean set(byte[] key, byte[] value);
From source file:org.springframework.data.redis.cache.RedisCache.java
public void clear() { // need to del each key individually template.execute(new RedisCallback<Object>() { public Object doInRedis(RedisConnection connection) throws DataAccessException { // another clear is on-going if (connection.exists(cacheLockName)) { return null; }// w ww .jav a 2s.co m try { connection.set(cacheLockName, cacheLockName); int offset = 0; boolean finished = false; do { // need to paginate the keys Set<byte[]> keys = connection.zRange(setName, (offset) * PAGE_SIZE, (offset + 1) * PAGE_SIZE - 1); finished = keys.size() < PAGE_SIZE; offset++; if (!keys.isEmpty()) { connection.del(keys.toArray(new byte[keys.size()][])); } } while (!finished); connection.del(setName); return null; } finally { connection.del(cacheLockName); } } }, true); }