List of usage examples for org.springframework.data.redis.core ConvertingCursor ConvertingCursor
public ConvertingCursor(Cursor<S> cursor, Converter<S, T> converter)
From source file:com.mauersu.util.redis.DefaultHashOperations.java
@Override public Cursor<Entry<HK, HV>> scan(K key, final ScanOptions options) { final byte[] rawKey = rawKey(key); return execute(new RedisCallback<Cursor<Map.Entry<HK, HV>>>() { @Override/*from w ww . j a v a 2s.c o m*/ public Cursor<Entry<HK, HV>> doInRedis(RedisConnection connection) throws DataAccessException { return new ConvertingCursor<Map.Entry<byte[], byte[]>, Map.Entry<HK, HV>>( connection.hScan(rawKey, options), new Converter<Map.Entry<byte[], byte[]>, Map.Entry<HK, HV>>() { @Override public Entry<HK, HV> convert(final Entry<byte[], byte[]> source) { return new Map.Entry<HK, HV>() { @Override public HK getKey() { return deserializeHashKey(source.getKey()); } @Override public HV getValue() { return deserializeHashValue(source.getValue()); } @Override public HV setValue(HV value) { throw new UnsupportedOperationException( "Values cannot be set when scanning through entries."); } }; } }); } }, true); }
From source file:com.mauersu.util.redis.DefaultSetOperations.java
@Override public Cursor<V> scan(K key, final ScanOptions options) { final byte[] rawKey = rawKey(key); return execute(new RedisCallback<Cursor<V>>() { @Override//from w w w . j a va 2 s. co m public Cursor<V> doInRedis(RedisConnection connection) throws DataAccessException { return new ConvertingCursor<byte[], V>(connection.sScan(rawKey, options), new Converter<byte[], V>() { @Override public V convert(byte[] source) { return deserializeValue(source); } }); } }, true); }
From source file:com.mauersu.util.redis.DefaultZSetOperations.java
@Override public Cursor<TypedTuple<V>> scan(K key, final ScanOptions options) { final byte[] rawKey = rawKey(key); Cursor<Tuple> cursor = execute(new RedisCallback<Cursor<Tuple>>() { @Override/*from w ww. ja v a 2 s .c om*/ public Cursor<Tuple> doInRedis(RedisConnection connection) throws DataAccessException { connection.select(dbIndex); return connection.zScan(rawKey, options); } }, true); return new ConvertingCursor<Tuple, TypedTuple<V>>(cursor, new Converter<Tuple, TypedTuple<V>>() { @Override public TypedTuple<V> convert(Tuple source) { return deserializeTuple(source); } }); }
From source file:org.springframework.data.redis.connection.DefaultStringRedisConnection.java
@Override public Cursor<Entry<String, String>> hScan(String key, ScanOptions options) { return new ConvertingCursor<Map.Entry<byte[], byte[]>, Map.Entry<String, String>>( this.delegate.hScan(this.serialize(key), options), new Converter<Map.Entry<byte[], byte[]>, Map.Entry<String, String>>() { @Override//w w w. j a va 2s.c om public Entry<String, String> convert(final Entry<byte[], byte[]> source) { return new Map.Entry<String, String>() { @Override public String getKey() { return bytesToString.convert(source.getKey()); } @Override public String getValue() { return bytesToString.convert(source.getValue()); } @Override public String setValue(String value) { throw new UnsupportedOperationException("Cannot set value for entry in cursor"); } }; } }); }
From source file:org.springframework.data.redis.connection.DefaultStringRedisConnection.java
@Override public Cursor<String> sScan(String key, ScanOptions options) { return new ConvertingCursor<byte[], String>(this.delegate.sScan(this.serialize(key), options), bytesToString);/*from ww w .ja v a2 s . com*/ }
From source file:org.springframework.data.redis.connection.DefaultStringRedisConnection.java
@Override public Cursor<StringTuple> zScan(String key, ScanOptions options) { return new ConvertingCursor<Tuple, StringRedisConnection.StringTuple>( delegate.zScan(this.serialize(key), options), new TupleConverter()); }