Search in sources :

Example 1 with ListMultiDecoder2

use of org.redisson.client.protocol.decoder.ListMultiDecoder2 in project redisson by redisson.

the class RedissonGeo method posAsync.

@Override
public RFuture<Map<V, GeoPosition>> posAsync(V... members) {
    List<Object> params = new ArrayList<Object>(members.length + 1);
    params.add(getRawName());
    for (Object member : members) {
        params.add(encode(member));
    }
    MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder2(new GeoPositionMapDecoder((List<Object>) Arrays.asList(members)), new GeoPositionDecoder());
    RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOPOS", decoder);
    return commandExecutor.readAsync(getRawName(), StringCodec.INSTANCE, command, params.toArray());
}
Also used : GeoPositionMapDecoder(org.redisson.client.protocol.decoder.GeoPositionMapDecoder) ListMultiDecoder2(org.redisson.client.protocol.decoder.ListMultiDecoder2) RedisCommand(org.redisson.client.protocol.RedisCommand) GeoPositionDecoder(org.redisson.client.protocol.decoder.GeoPositionDecoder)

Example 2 with ListMultiDecoder2

use of org.redisson.client.protocol.decoder.ListMultiDecoder2 in project redisson by redisson.

the class RedissonLiveObjectService method findIds.

@Override
public <K> Iterable<K> findIds(Class<?> entityClass, int count) {
    NamingScheme namingScheme = commandExecutor.getObjectBuilder().getNamingScheme(entityClass);
    String pattern = namingScheme.getNamePattern(entityClass);
    RedissonKeys keys = new RedissonKeys(commandExecutor);
    RedisCommand<ListScanResult<String>> command = new RedisCommand<>("SCAN", new ListMultiDecoder2(new ListScanResultReplayDecoder(), new ObjectListReplayDecoder<Object>()), new Convertor<Object>() {

        @Override
        public Object convert(Object obj) {
            if (!(obj instanceof String)) {
                return obj;
            }
            return namingScheme.resolveId(obj.toString());
        }
    });
    return keys.getKeysByPattern(command, pattern, 0, count);
}
Also used : ListScanResult(org.redisson.client.protocol.decoder.ListScanResult) NamingScheme(org.redisson.liveobject.resolver.NamingScheme) ListMultiDecoder2(org.redisson.client.protocol.decoder.ListMultiDecoder2) RedisCommand(org.redisson.client.protocol.RedisCommand) ListScanResultReplayDecoder(org.redisson.client.protocol.decoder.ListScanResultReplayDecoder) ObjectListReplayDecoder(org.redisson.client.protocol.decoder.ObjectListReplayDecoder)

Aggregations

RedisCommand (org.redisson.client.protocol.RedisCommand)2 ListMultiDecoder2 (org.redisson.client.protocol.decoder.ListMultiDecoder2)2 GeoPositionDecoder (org.redisson.client.protocol.decoder.GeoPositionDecoder)1 GeoPositionMapDecoder (org.redisson.client.protocol.decoder.GeoPositionMapDecoder)1 ListScanResult (org.redisson.client.protocol.decoder.ListScanResult)1 ListScanResultReplayDecoder (org.redisson.client.protocol.decoder.ListScanResultReplayDecoder)1 ObjectListReplayDecoder (org.redisson.client.protocol.decoder.ObjectListReplayDecoder)1 NamingScheme (org.redisson.liveobject.resolver.NamingScheme)1